Package: jsonfromschema
IN SHORTjsonfromschemais used to generate JSON data (file.json) from JSON Schema (.json, seehttps://json-schema.org)
Project is written in Python for Python purposes, but it is also stand-alone tool.SPDX-License-Identifier: 0BSDProject name: jsonfromschema
License: 0BSD / Free Public License 1.0.0
More information about license:https://opensource.org/licenses/0BSDNON-INSTALLgitclonegit@github.com:NIC-MichalLabedzki/jsonfromschema.gitYou can run it from sources without any dependancies* (python and some modules delivered with it)python./jsonfromschemaSee:python./jsonfromschema--helpSee CLI section for more details.INSTALLATIONpipinstalljsonfromschemaorpipinstall-egit@github.com:NIC-MichalLabedzki/jsonfromschema.gitorpipinstall-ehttps://github.com/NIC-MichalLabedzki/jsonfromschema.gitorgitclonegit@github.com:NIC-MichalLabedzki/jsonfromschema.gitcdjsonfromschemapythonsetup.py# or pip install -e .INTERFACEThere are two kind of interfaces:CLIandPython module.CLICLI is Command Line Interface. So you have tool called: jsonfromschema$jsonfromschema--helpusage:jsonfromschema[-h][-v][-w[VALIDATE]][--no-default][--no-examples][--maximum][--subschemaSUBSCHEMA][--from-python-packageFROM_PYTHON_PACKAGE]schemaoutputGenerateJSONdatafile(*.json)fromJSONSchemapositionalarguments:schemapathtoJSONSchemafileorpythonpackagesresource[--from-python-package]outputpathtoJSONdataoutputfileoptionalarguments:-h,--helpshowthishelpmessageandexit-v,--verboseverbosemode-w[VALIDATE],--validate[VALIDATE]usejsonschematovalidateoutputandcheckifschemaisvalid[3,4,6,7(default)]--no-defaultdonotuse'default'fieldsinjsonschema--no-examplesdonotuse'default'fieldsinjsonschema--maximumgenerateascomplexjsonaspossible(byimplementation);forexampleignore"required"andfavor"object"overlesscomplicatedfields--subschemaSUBSCHEMAextractsubschemaonlybythisjsonfragmentpointer--from-python-packageFROM_PYTHON_PACKAGE'schema'ispathtopythonpackageresource,thisoptionneedspackagenameasargumentSome examples:$jsonfromschemainput_schema.jsonoutput_json_data.jsonVerbose:$jsonfromschemainput_schema.jsonoutput_json_data.json-vValidate output:
It use “jsonschema” module (pip install jsonschema) to validate output json to be valid with given schema.$jsonfromschemainput_schema.jsonoutput_json_data.json-wGenerate subschema:
Use JSON pointer (schema side) to generate only part of schema:$jsonfromschematests/test_schema_main.json.jsonoutput.json-w--subschema=/properties/string_default$catoutput.json"foo"Use JSON Schema resources from some python packages:$jsonfromschema../tests/test_schema_main.jsonoutput.json-vw--subschema=/properties/string_default--from-python-packagejsonfromschema$catoutput.json"foo"Python ModuleAPI is not stable right now.importjsonfromschema.libgenerate_dict_from_text(root_name,schema_text,optional_args=None)generate_dict_from_file(schema_file,optional_args=None)generate_dict_from_package(package,path,optional_args=None)optional_args:Default values are:{'verbose':False,'no-default':False,'no-examples':False,'maximum':False,'pkg_resource_root':None,'subschema':None,}Where:pkg_resource_rootis package name, for example “jsonschema”Changelogv0.1.4:try use –maximum value for more json typesremove anoying python version from cli outputTODOJsonSchema Draft-7 support (in progress)Check Draft-4 supportSection about Contributions