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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for to_json_schema-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5708663f1c81815e4ff01fce910ac32ee3964d0c6b3587fd4fff2e38d5c9aa7b |
|
MD5 | 17f4c98bc89b8d3dc377703dc4701ea9 |
|
BLAKE2b-256 | 26abf404e0359ada957231e1009de13f337665e38f87c62f0d5b1733af010640 |