Skip to main content

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 xOfs cannot be resolved yet. The program won't fail and will procude valid OpenAPI specification, but the result will still contain nested xOf 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

Acknowledgements

Release files for jsonschema-to-openapi 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonschema-to-openapi 0.2.1
File Size Uploaded
jsonschema-to-openapi-0.2.1.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonschema-to-openapi 0.2.1
File Interpreter ABI Platform
jsonschema_to_openapi-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / jsonschema-to-openapi-0.2.1.tar.gz

Download URL jsonschema-to-openapi-0.2.1.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6bccbe72c8d4c0d76ff006309895afbb9b87bf67b7663fba4b5ab055f5253de5
BLAKE2b-256 checksum
How to use checksums
434c9808f3fbfa24b9d0337afb8f388db3b53de10ed593b89c460e76f3c86aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.2 CPython/3.6.9 Linux/5.3.0-45-generic

Release files / jsonschema_to_openapi-0.2.1-py3-none-any.whl

Download URL jsonschema_to_openapi-0.2.1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cac1b26f5625f33add3dfba113d950ec22b34381b060561f8412bf4f6a409c6
BLAKE2b-256 checksum
How to use checksums
e4cb1a7e6efa903b3fcdd41222579927b49209473bb22175b8432563cf6aedf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.2 CPython/3.6.9 Linux/5.3.0-45-generic

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page