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
$refoperator, you will need to put all base schemas under a "definitions" key in root. - Abitrarily nested
xOfs cannot be resolved yet. The program won't fail and will procude valid OpenAPI specification, but the result will still contain nestedxOfoperators.-
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsonschema-to-openapi-0.1.0.tar.gz.
File metadata
- Download URL: jsonschema-to-openapi-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/3.6.9 Linux/4.19.78-coreos
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8def798287e5ed9435eb77abcb29ff34939678227e5ffefd27236deaddee6b86
|
|
| MD5 |
81bb5a29b6b3beadc6b4db1609cce2f2
|
|
| BLAKE2b-256 |
6b2cefbd37de1d50e35ec47faf5ebd66d3aed37305a220ca98c37cb289726de0
|
File details
Details for the file jsonschema_to_openapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jsonschema_to_openapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/3.6.9 Linux/4.19.78-coreos
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dec9e335f7d3d367ea0eb39521d44d9bb3cd073ef464f2288fc6638374ba2c79
|
|
| MD5 |
0a08047f5ddf28d360502de15c593e3c
|
|
| BLAKE2b-256 |
6129e3c199c57efdd86ed3d6933e024a93b8e5f6f6e240e5df6e77715757a477
|