Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonschema-to-openapi

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonschema-to-openapi

Converts a JSON schema to an OpenAPI specification version 3.0.

  • 0.2.1
  • PyPI
  • Socket score

Maintainers
1

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc