Skip to main content

No project description provided

Project description

A simple package that convert dictionary or a list into json-schema using the OpenAPI standards.

Installation

to-json-schema can be installed via pip:

$ pip install to-json-schema

Quickstart

You can now convert your python dict into json-schema:

from to_json_schema.to_json_schema import SchemaBuilder

 data = {
     "country": "Pakistan",
     "city": "Karachi",
     "population": 16051521,
     "is_capital": False,
     "key_qualities": ["food", "multi-cultural"],
 }

 schema_builder = SchemaBuilder()
 json_schema = schema_builder.to_json_schema(data)

 >>> {'type': 'object', 'properties': {'country': {'type': 'string'}, 'city': {'type': 'string'}, 'population': {'type': 'integer'}, 'is_capital': {'type': 'boolean'}, 'key_qualities': {'type': 'array', 'items': {'type': 'string'}}}}

You can also convert list of dict, string, integer into-json schema

from to_json_schema.to_json_schema import SchemaBuilder

data = [{"foo": 12, "bar": 14}, {"moo": 52, "car": 641}, {"doo": 6, "tar": 84}]

schema_builder = SchemaBuilder()
json_schema = schema_builder.to_json_schema(data)

>>> {'type': 'array', 'items': {'type': 'object', 'properties': {'foo': {'type': 'integer'}, 'bar': {'type': 'integer'}, 'moo': {'type': 'integer'}, 'car': {'type': 'integer'}, 'doo': {'type': 'integer'}, 'tar': {'type': 'integer'}}}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

to_json_schema-1.0.1.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

to_json_schema-1.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file to_json_schema-1.0.1.tar.gz.

File metadata

  • Download URL: to_json_schema-1.0.1.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for to_json_schema-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ec747bd5129256dd571105f66a7bc9a4546228cd5e5fbf5e06dc9776e255400e
MD5 712f496078ba016c69f66f205bcda5c9
BLAKE2b-256 faa9b428933adad9f954a7d1054cbb3a3a40ba33645be36ea87b8a3efa30ea88

See more details on using hashes here.

File details

Details for the file to_json_schema-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: to_json_schema-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for to_json_schema-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5708663f1c81815e4ff01fce910ac32ee3964d0c6b3587fd4fff2e38d5c9aa7b
MD5 17f4c98bc89b8d3dc377703dc4701ea9
BLAKE2b-256 26abf404e0359ada957231e1009de13f337665e38f87c62f0d5b1733af010640

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page