Saravanan666/pypi-org huggingface dataset:
Package: jsonschema-extended
jsonschemais an implementation ofJSON Schemafor Python (supporting 2.7+ including Python 3).>>>fromjsonschemaimportvalidate>>># A sample schema, like what we'd get from json.load()>>>schema={..."type":"object",..."properties":{..."price":{"type":"number"},..."name":{"type":"string"},...},...}>>># If no exception is raised by validate(), the instance is valid.>>>validate({"name":"Eggs","price":34.99},schema)>>>validate(...{"name":"Eggs","price":"Invalid"},schema...)# doctest: +IGNORE_EXCEPTION_DETAILTraceback(mostrecentcalllast):...ValidationError:'Invalid'isnotoftype'number'It can also be used from console:$jsonschema-isample.jsonsample.schemaFeaturesFull support forDraft 6,Draft 4andDraft 3Lazy validationthat can iteratively reportallvalidation errors.Small and extensibleProgrammatic queryingof which properties or items failed validation.Release NotesVersion 2.6.0 drops support for Python 2.6.X (ha ha) and contains a
number of small improvements in error messages, as well as a bug fix forErrorTree.Running the Test SuiteIf you havetoxinstalled (perhaps viapip install toxor your
package manager), runningtoxin the directory of your source checkout will
runjsonschema’s test suite on all of the versions of Pythonjsonschemasupports. Note that you’ll need to have all of those versions installed in
order to run the tests on each of them, otherwisetoxwill skip (and fail)
the tests on that version.Of course you’re also free to just run the tests on a single version with your
favorite test runner. The tests live in thejsonschema.testspackage.Benchmarksjsonschema’s benchmarks make use ofperf.Running them can be done viatox-eperf, or by invoking theperfcommands externally (after ensuring that both it andjsonschemaitself are
installed):$ python -m perf jsonschema/benchmarks/test_suite.py --hist --output results.jsonTo compare to a previous run, use:$ python -m perf compare_to --table reference.json results.jsonSee theperfdocumentation for more details.CommunityThere’s amailing listfor this implementation on Google Groups.Please join, and feel free to send questions there.ContributingI’m Julian Berman.jsonschemais onGitHub.Get in touch, via GitHub or otherwise, if you’ve got something to contribute,
it’d be most welcome!You can also generally find me on Freenode (nick:tos9) in various
channels, including#python.If you feel overwhelmingly grateful, you can woo me with beer money via
Google Pay with the email in my GitHub profile.
Package: jsonschema-extractor
jsonschema-extractor is a library and extensible framework for
extractingjson schemafrom various object and
primitives.Out of the box support exists for:attrstypingUsagefromtypingimportListimportjsonschema_extractorassertjsonschema_extractor.extract(List[int])=={"type":"array","items":{"type":"integer"}}Attrs-exampleimportattrfromattr.validatorsimportinstance_ofimportjsonschema_extractor@attr.defineclassExample(object):integer:int=attr.field()foo=attr.field(metadata={"jsonschema":{"type":"string","format":"uuid"}})validator_list:List[float]=attr.field()string:str=attr.field(default="foo",metadata={"description":"This is an description."})assertextractor.extract(Example)=={"type":"object","title":"Example","properties":{"string":{"description":"This is an description.","type":"string"},"integer":{"type":"integer"},"validator_list":{"items":{"type":"number"},"type":"array"},"foo":{"type":"string","format":"uuid"},},"required":["integer","foo","validator_list"],}
Package: json-schema-filter
json-schema-filterA library that usesjsonschemato filter the objectsUsagefromjson_schema_filterimportJsonSchemaFilterschema={"properties":{"name":{"type":"string","equals":"Shakespeare"}},"required":["name"]}input_data=[{"name":"what is in the name"},{"name":"Shakespeare"},{"name":"hamlet"},]print(JsonSchemaFilter(schema).filter(input_data))# output"""Total Selected: 1Filtered Item: [0]1. name: Values not equal. Expected: Shakespeare, Found: what is in the nameFiltered Item: [2]1. name: Values not equal. Expected: Shakespeare, Found: hamlet"""Supported additional propertiesPropertySupported typeequals*iequalsstring
Package: json_schema_generator
=JSON Schema Genarotor=# AboutIt is a json schema genarator from any json source.# ExampleSince you have a json file with the above structure":{"item_1": "string_value_1","item_2": 123,"item_3": [1, 2, 3],"item_4": true,"item_5": null,"item_6": { "key": "value"},"item_7": {"item_7.1": "string_value_1","item_7.2": 123,"item_7.3": [1, 2, 3],"item_7.4": true,"item_7.5": null,"item_7.6": { "key": "value"}}}It should generate a json schema as":{"$schema": "http://json-schema.org/draft-03/schema","id": "#","required": true,"type": "object","properties": {"item_1": {"id": "item_1","required": true,"type": "string"},"item_2": {"id": "item_2","required": true,"type": "number"},"item_3": {"id": "item_3","required": true,"type": "array" ,"items": {"id": "0","required": true,"type": "number"}},"item_4": {"id": "item_4","required": true,"type": "boolean"},"item_5": {"id": "item_5","required": true,"type": "null"},"item_6": {"id": "item_6","required": true,"type": "object" ,"properties": {"key": {"id": "key","required": true,"type": "string"}}},"item_7": {"id": "item_7","required": true,"type": "object" ,"properties": {"item_7.1": {"id": "item_7.1","required": true,"type": "string"},"item_7.2": {"id": "item_7.2","required": true,"type": "number"},"item_7.3": {"id": "item_7.3","required": true,"type": "array" ,"items": {"id": "0","required": true,"type": "number"}},"item_7.4": {"id": "item_7.4","required": true,"type": "boolean"},"item_7.5": {"id": "item_7.5","required": true,"type": "null"},"item_7.6": {"id": "item_7.6","required": true,"type": "object" ,"properties": {"key": {"id": "key","required": true,"type": "string"}}}}}}}
Package: jsonschema-gentypes
JSON Schema generate Python typesTools to generate Python types based on TypedDict from a JSON schemaQuick startinstall:python3-mpipinstall--userjsonschema-gentypesConvert a JSON schema to a Python file contains the types:jsonschema-gentypes--json-schema=<JSONschema>--python=<destinationPythonfile>Config fileYou can also write a config file namedjsonschema-gentypes.yamlwith:headers:># Automatically generated file from a JSON schema# Used to correctly format the generated filecallbacks:--black--isortgenerate:-# JSON schema file pathsource:jsonschema_gentypes/schema.json# Python file pathdestination:jsonschema_gentypes/configuration.py# The name of the root elementroot_name:Config# Argument passed to the APIapi_arguments:additional_properties:Only explicit# Rename an elementname_mapping:{}# The minimum Python version that the code should support. By default the# currently executing Python version is chosen. Note that the output# may require typing_extensions to be installed.python_version:'3.11'And just run:jsonschema-gentypesDefaultThe default values are exported in the Python file, then you can do something like that:value_with_default=my_object.get('field_name',my_schema.FIELD_DEFAULT)LimitationsRequires Python 3.8See theissues with label "limitation".Pre-commit hooksThis project provides pre-commit hooks to automatically generate the files.repos:-repo:https://github.com/camptocamp/jsonschema-gentypesrev:<version># Use the ref you want to point athools:-id:jsonschema-gentypesfiles:|(?x)^(jsonschema-gentypes\.yaml|<schema_path>\.json)$See also the pre_commit section in the configuration to run the pre-commit just after the generation, for example with:pre_commit:enabled:truearguments:---color=neverOpenAPI3We can also generate types for OpenAPI3 schemas (automatically detected).The result of our example intests/openapi3.jsoncan be used in pyramid with for example:importpyramid.requestfrompyramid.viewimportview_configfromopenaoi3import*defopen_api(func):defwrapper(request:pyramid.request.Request,**kwargs)->Any:typed_request={}try:typed_request{'request_body'}=request.jsonexceptExceptionase:passtyped_request{'path'}=request.matchdicttyped_request{'query'}=request.paramsreturn=func(request,request_typed=typed_request,**kwargs)returnwrapper@view_config(route_name="route_name",renderer="json")@open_apidefview(request:pyramid.request.Request,request_typed:OgcapiCollectionsCollectionidGet,)->OgcapiCollectionsCollectionidGetResponse:return{...}ContributingInstall the pre-commit hooks:pipinstallpre-commit
pre-commitinstall--allow-missing-configTheprospectortests should pass.The code should be typed.The code should be tested withpytests.
Package: jsonschema-lint
jsonschema-lintLinter for JSON Schema instances.InstallationThis project is not currently packaged and so must be installed manually.Clone the project with the following command:git clone https://github.com/jacksmith15/jsonschema-lint.gitUsageThe linter is invoked on the command line:$ jsonschema-lintSelecting instancesBy default, the linter will attempt to lint every file matching extension under the currect directory. This means every.jsonfile, plus every.yaml/.ymlfile ifPyYAMLis installed. A file will only be linted if a matching schema can be detected (seebelow).You can override this behaviour by passing arguments to the linter, e.g.$ jsonschema-lint **/*.avscSchema resolutionThere are three ways schemas can be selected for a given instance. In order of priority:If provided, the--schemaoption will be used to validate all target instances.A matching rule in a.jsonschema-lintfile, in the instance directory or its parents (see below).If the--schema-storeflag is provided, then matching rules fromSchema Storewill be used..jsonschema-lintfiles.jsonschema-lintfiles follow similar logic to.gitignoreandGithubCODEOWNERSfiles, in that they apply to all files under their directory tree.Each line in a.jsonschema-lintfile is a rule, matching a filepath pattern to a particular schema. For example:**/.circleci/config.yml  https://json.schemastore.org/circleciconfig.json  yamlThere are three parts to each rule, separated by whitespace. These are:the pattern/glob, in this case matching any files namedconfig.ymlin a directory named.circlecithe location of the schema. This can be a remote URL, or a path on the local filesystem. If this is a relative path, it is resolved relative to the.jsonschema-lintfile.(optional) the expected file format of any instances. If this is omitted, the linter will attempt to detect the correct type from the file extension. If it cannot be detected, both will be attempted.DevelopmentInstall dependencies:pyenvshell3.9.4# Or other 3.9.xpre-commitinstall# Configure commit hookspoetryinstall# Install Python dependenciesRun tests:poetryruninvverifyLicenseThis project is distributed under the MIT license.
Package: jsonschema-markdown
jsonschema-markdownGenerate markdown documentation from JSON Schema files. The main goal is to generate
documentation that is easy to read and understand.Can be used as a command line tool or as a library.Installationpipxinstalljsonschema-markdownUsageTo usejsonschema-markdownas a CLI, just pass the filename as an argument and redirect
the output to a file.$jsonschema-markdown--help
Usage:jsonschema-markdown[OPTIONS]FILENAMELoadFILENAMEandoutputamarkdownversion.Use'-'asFILENAMEtoreadfromstdin.

Options:-t,--titleTEXTDonotusethetitlefromtheschema,usethistitleinstead.--footer/--no-footerAddafooterwithalinktotheproject.[default:footer]--resolve/--no-resolve[Experimental]Resolve$refpointers.[default:no-resolve]--debug/--no-debugEnabledebugoutput.[default:no-debug]--versionShowtheversionandexit.--helpShowthismessageandexit.# Example$jsonschema-markdownschema.json>schema.mdUsage with DockerThejsonschema-markdowncommand is also available as a Docker image. To use it, you can mount the schema file as a volume.catmy-schema.json|dockerrun--rm-ielisiariocouto/jsonschema-markdown->schema.md⚠️Warning: Do not pass the-tflag.The Docker image is available at:elisiariocouto/jsonschema-markdownghcr.io/elisiariocouto/jsonschema-markdownUsage as a libraryTo use it as a library, load your JSON schema file as Pythondictand pass it to generate.
The function will return a string with the markdown.importjsonschema_markdownwithopen('schema.json')asf:schema=json.load(f)markdown=jsonschema_markdown.generate(schema)FeaturesPartially inspired byjson-schema-for-humans,
this project does not currently support all features of JSON Schema, but it should support:Required fieldsString patternsEnumerationsDefault valuesDescriptions and titlesNested objectsBasic OneOf, AnyOf, AllOf functionalityArraysIntegers with minimum, maximum values and exclusivesBoolean valuesDeprecation notices (searches for case-insensitivedeprecatedin the field description)CaveatsThis project is still in early development, and the output may change in the future.Custom definitions are expected to be in the same file as the schema that uses them,
in thedefinitionsor$defsparameter at the root of the document.
Package: json-schema-matchers
PyHamcrest matchers extension for json schema validationThe schema should be implemented following syntax ofDraft-07 to 2019-09version.
Schema example:single_user_schema={"title":"Single User Info","type":"object","properties":{"first_name":{"type":"string","minLength":3},"last_name":{"type":"string","minLength":3},"phone_number":{"type":"number"}},"required":["first_name","last_name",]}all_users_info_schema={"title":"All Users Info","type":"array","items":single_user_schema}Then you can usematches_json_schemamatcher with all hamcrest matchers:fromhamcrestimportassert_thatfromjson_schema_matchers.common_matcherimportmatches_json_schemausers_list_json_obj=[{"first_name":'John',"last_name":"Johnson","phone_number":123456789},{"first_name":'Jim',"last_name":'Jefferson'}]assert_that(users_list_json_obj,matches_json_schema(all_users_info_schema))assert_that(users_list_json_obj[0],matches_json_schema(single_user_schema))In case of validation fail the matcher will return all mismatches iteratively:users_list_json_obj=[{"first_name":'John',"last_name":"Johnson","phone_number":'123456789'},{"first_name":None,"last_name":'Je'}]assert_that(users_list_json_obj,matches_json_schema(all_users_info_schema))AssertionError:Expected:JSONobjectshouldmatchschema"All Users Info"but:mismatchesoccurred:'123456789'isnotoftype'number'Failedvalidating'type'inschema['items']['properties']['phone_number']:{'type':'number'}Oninstance[0]['phone_number']:'123456789'------------'Je'istooshortFailedvalidating'minLength'inschema['items']['properties']['last_name']:{'minLength':3,'type':'string'}Oninstance[1]['last_name']:'Je'------------Noneisnotoftype'string'Failedvalidating'type'inschema['items']['properties']['first_name']:{'minLength':3,'type':'string'}Oninstance[1]['first_name']:None------------Dependencies:jsonschema==3.2.0
PyHamcrest==2.0.2
Package: jsonschema-model
Build python objects using JSON schemas:>>> import jsonschema_model
>>> Model = jsonschema_model.model_factory({
...    "name": "Model",
...    "properties": {
...        "foo": {"type": "string"},
...        "bar": {"type": "array", "items": {
...            "type": "object",
...            "name": "Bar",
...            "properties": {
...                "zaz": {"type": "string"},
...            },
...        }},
...    }})

# Simple object creation
>>> obj = Model(foo="bar")
>>> assert obj == {"foo": "bar"}

# Nested and array are implemented
# HINT: Use add() instead of append()
>>> obj.bar.add(zaz="qux")
{'zaz': 'qux'}
>>> assert obj == {'foo': 'bar', 'bar': [{'zaz': 'qux'}]}

# You can access via attribute or via dict like interface
>>> obj["bar"][0].zaz
'qux'

# Array have a special get_or_create() method
# to avoid dupplicates within an array
>>> obj.bar.get_or_create(zaz="xuq")
{'zaz': 'xuq'}
>>> obj.bar
[{'zaz': 'qux'}, {'zaz': 'xuq'}]
>>> obj.bar.get_or_create(zaz="xuq")
{'zaz': 'xuq'}
>>> obj.bar
[{'zaz': 'qux'}, {'zaz': 'xuq'}]
Package: jsonschemanlplab
This is a fork ofhttps://github.com/Julian/jsonschemawhich exists only to circumvent dependency incompatibilities.jsonschemanlplabis an implementation ofJSON Schemafor Python (supporting 2.7+ including Python 3).>>>fromjsonschemanlplabimportvalidate>>># A sample schema, like what we'd get from json.load()>>>schema={..."type":"object",..."properties":{..."price":{"type":"number"},..."name":{"type":"string"},...},...}>>># If no exception is raised by validate(), the instance is valid.>>>validate(instance={"name":"Eggs","price":34.99},schema=schema)>>>validate(...instance={"name":"Eggs","price":"Invalid"},schema=schema,...)# doctest: +IGNORE_EXCEPTION_DETAILTraceback(mostrecentcalllast):...ValidationError:'Invalid'isnotoftype'number'It can also be used from console:$jsonschemanlplab-isample.jsonsample.schemaFeaturesFull support forDraft 7,Draft 6,Draft 4andDraft 3Lazy validationthat can iteratively reportallvalidation errors.Programmatic queryingof which properties or items failed validation.Installationjsonschemanlplabis available onPyPI. You can install usingpip:$pipinstalljsonschemanlplabRelease NotesVersion 3.0 brings support for Draft 7 (and 6). The interface for redefining
types has also been majorly overhauled to support easier redefinition of the
types a Validator will accept or allow.jsonschemanlplab is also now tested under Windows via AppVeyor.Thanks to all who contributed pull requests along the way.Running the Test SuiteIf you havetoxinstalled (perhaps viapip install toxor your
package manager), runningtoxin the directory of your source
checkout will runjsonschemanlplab’s test suite on all of the versions
of Pythonjsonschemanlplabsupports. If you don’t have all of the
versions thatjsonschemanlplabis tested under, you’ll likely want to run
usingtox’s--skip-missing-interpretersoption.Of course you’re also free to just run the tests on a single version with your
favorite test runner. The tests live in thejsonschemanlplab.testspackage.Benchmarksjsonschemanlplab’s benchmarks make use ofperf.Running them can be done viatox-eperf, or by invoking theperfcommands externally (after ensuring that both it andjsonschemanlplabitself are
installed):$ python -m perf jsonschemanlplab/benchmarks/test_suite.py --hist --output results.jsonTo compare to a previous run, use:$ python -m perf compare_to --table reference.json results.jsonSee theperfdocumentation for more details.CommunityThere’s amailing listfor this implementation on Google Groups.Please join, and feel free to send questions there.ContributingI’m Julian Berman.jsonschemais onGitHub.Get in touch, via GitHub or otherwise, if you’ve got something to contribute,
it’d be most welcome!You can also generally find me on Freenode (nick:tos9) in various
channels, including#python.If you feel overwhelmingly grateful, you can woo me with beer money via
Google Pay with the email in my GitHub profile.
Package: jsonschema-path
AboutObject-oriented JSONSchemaKey featuresTraverse schema like pathsAccess schema on demand with separate dereferencing accessor layerInstallationpip install jsonschema-pathAlternatively you can download the code and install from the repository:pip install -e git+https://github.com/p1c2u/jsonschema-path.git#egg=jsonschema_pathUsage>>>fromjsonschema_pathimportSchemaPath>>>d={..."properties":{..."info":{..."$ref":"#/$defs/Info",...},...},..."$defs":{..."Info":{..."properties":{..."title":{..."$ref":"http://example.com",...},..."version":{..."type":"string",..."default":"1.0",...},...},...},...},...}>>>path=SchemaPath.from_dict(d)>>># Stat keys>>>"properties"inpathTrue>>># Concatenate paths with />>>info_path=path/"properties"/"info">>># Stat keys with implicit dereferencing>>>"properties"ininfo_pathTrue>>># Concatenate paths with implicit dereferencing>>>version_path=info_path/"properties"/"version">>># Open content with implicit dereferencing>>>withversion_path.open()ascontents:...print(contents){'type':'string','default':'1.0'}Related projectsopenapi-corePython library that adds client-side and server-side support for the OpenAPI.openapi-spec-validatorPython library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0 specificationopenapi-schema-validatorPython library that validates schema against the OpenAPI Schema Specification v3.0.LicenseCopyright (c) 2017-2022, Artur Maciag, All rights reserved. Apache-2.0
Package: jsonschema-pydantic
jsonschema-pydanticSimple transform of jsonschema to pydantic models.Supported jsonschema featuresprimitive typesobjectsarraysnested objectsoptional fieldsdefault valuesInstallpip install jsonschema-pydanticUsagefrom jsonschema_pydantic import jsonschema_to_pydantic

jsonschema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "integer"},
    },
    "required": ["name"],
}

pydantic_model = jsonschema_to_pydantic(jsonschema)DevelopmentRun pytest test suite:make testLintingRun all lintersmake lintFormattingFormat python code:make fmtDocumentationGenerate documentation:make docsContributionsRead theCONTRIBUTING.mdfile.
Package: json-schema-reducer
Extract from a JSON/dict only whats in the JSON Schema. Assumes that the
JSON/dict you supply is valid according to the JSON Schema you also supply.InstallationSimple install withpip:pip install json-schema-reducerHow to use itSuppose you have two files on disk:schema.jsonandmything.json.
And suppose that theschema.jsononly lists the propertiesfooandbarbut the filemything.jsoncontains many more things:>>> from json_schema_reducer import make_reduced_dict
>>> make_reduced_dict('schema.json', 'mything.json')
{'foo': 'value1', 'bar': 'value2'}The arguments are flexible. You can also do this:>>> make_reduced_dict(open('schema.json'), open('mything.json'))Or this:>>> make_reduced_dict(open('schema.json').read(), open('mything.json').read())Or this:>>> make_reduced_dict(
...   json.load(open('schema.json')),
...   json.load(open('mything.json')))Runnings testsSimply run:python setup.py testVersion History0.1.4Universal wheel0.1.3Better, but basic, cli (e.g.--help)Support for optional nested keys0.1.2Correct README restructured text0.1.1Tidying up loose ends0.1.0First, hopefully, working version.
Package: jsonschema-spec
AboutObject-oriented JSONSchemaKey featuresTraverse schema like pathsAccess schema on demand with separate dereferencing accessor layerInstallationpip install jsonschema-specAlternatively you can download the code and install from the repository:pip install -e git+https://github.com/p1c2u/jsonschema-spec.git#egg=jsonschema_specUsage>>>fromjsonschema_specimportSchemaPath>>>d={..."properties":{..."info":{..."$ref":"#/$defs/Info",...},...},..."$defs":{..."Info":{..."properties":{..."title":{..."$ref":"http://example.com",...},..."version":{..."type":"string",..."default":"1.0",...},...},...},...},...}>>>path=SchemaPath.from_dict(d)>>># Stat keys>>>"properties"inpathTrue>>># Concatenate paths with />>>info_path=path/"properties"/"info">>># Stat keys with implicit dereferencing>>>"properties"ininfo_pathTrue>>># Concatenate paths with implicit dereferencing>>>version_path=info_path/"properties"/"version">>># Open content with implicit dereferencing>>>withversion_path.open()ascontents:...print(contents){'type':'string','default':'1.0'}Related projectsopenapi-corePython library that adds client-side and server-side support for the OpenAPI.openapi-spec-validatorPython library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0 specificationopenapi-schema-validatorPython library that validates schema against the OpenAPI Schema Specification v3.0.LicenseCopyright (c) 2017-2022, Artur Maciag, All rights reserved. Apache-2.0