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'}}}}
Metadata
Release files for to-json-schema 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| to_json_schema-1.0.1.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| to_json_schema-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / to_json_schema-1.0.1.tar.gz
| Download URL | to_json_schema-1.0.1.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec747bd5129256dd571105f66a7bc9a4546228cd5e5fbf5e06dc9776e255400e
|
|
BLAKE2b-256 checksum How to use checksums |
faa9b428933adad9f954a7d1054cbb3a3a40ba33645be36ea87b8a3efa30ea88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.15
|
Release files / to_json_schema-1.0.1-py3-none-any.whl
| Download URL | to_json_schema-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5708663f1c81815e4ff01fce910ac32ee3964d0c6b3587fd4fff2e38d5c9aa7b
|
|
BLAKE2b-256 checksum How to use checksums |
26abf404e0359ada957231e1009de13f337665e38f87c62f0d5b1733af010640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.15
|