Converts a JSON schema to an OpenAPI specification version 3.0.
Project description
jsonschema-to-openapi
Converts a JSON schema to an OpenAPI specification version 3.0.
Installation
pip install jsonschema-to-openapi
Usage
CLI
jsonschema-to-openapi my_json_schema.json my_open_api_spec.json
Package
>>> from jsonschema_to_openapi.convert import convert
>>> schema = {} # Your json schema as dictionary.
>>> convert(schema)
{} # Your OpenAPI specification as dictionary.
Caveats and Limitations
- If you have a complex schema, where you extend a base schema with the
$ref
operator, you will need to put all base schemas under a "definitions" key in root. - Abitrarily nested
xOf
s cannot be resolved yet. The program won't fail and will procude valid OpenAPI specification, but the result will still contain nestedxOf
operators.-
Input:
{ "anyOf": [{"$ref": "#/definitions/my_object"}, { "anyOf": [{"type": "null"}] }], "definitions": { "my_object": {"type": "string"} } }
-
Output:
{ "anyOf": [ { "$ref": "#/definitions/my_object" }, { "anyOf": [ { "type": "null" } ] } ], "definitions": { "my_object": { "nullable": false, "type": "string" } } }
-
Changelog
Please take a look at the CHANGELOG.md for notable changes to jsonschema-to-openapi.
License
See the LICENSE for details.
Development
We welcome new contributions to this project!
Source Code
You can check the latest source code with the command:
git clone git@gitlab.com:InstaffoOpenSource/DataScience/jsonschema-to-openapi.git
Linting
After cloning and installing the dependencies, you can lint the project by executing:
make lint
Testing
After cloning and installing the dependencies, you can test the project by executing:
make test
Help and Support
Authors
- Jan-Benedikt Jagusch jan@instaffo.de
Acknowledgements
- This project started as a Python port of json-schema-to-openapi-schema.
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
Built Distribution
Close
Hashes for jsonschema-to-openapi-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3316a646c54f0b2cde4412dc58fcc64b64d6d77fd8f7412ea74daf821751675f |
|
MD5 | 8c5d12bacf32a2a8ccfa12f83dd293a5 |
|
BLAKE2b-256 | c87e0522bfe5acef5e6a33abed4fb34d6f9194d43a5554a03ede83d2685fc0bc |
Close
Hashes for jsonschema_to_openapi-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9fcd260b623feec31cc11ac5ecd1606f54a7ddd31c304178d4bab7c9844b3af |
|
MD5 | 85e7e0f3fe40e923098cfb994aef9220 |
|
BLAKE2b-256 | 39ac1ba3f85a98ce5c0c1258ecfe1c00bab373b2e578a10d34afe335c699ee75 |