This Python library provides a utility to convert OpenAPI 3.0 Schema Objects into compatible JSON Schema Draft 4 representations. It addresses key discrepancies between the two specifications, such as `nullable` handling and removal of OpenAPI-specific keywords, to enable validation with standard JSON Schema validators. This package is a direct Python port of the JavaScript library `mikunn/openapi-schema-to-json-schema` (v2.1.0).
pip install py-openapi-schema-to-json-schemaVerified import paths — ran on the pinned version, not inferred.
Demonstrates converting a simple OpenAPI schema object, including handling `nullable` and an OpenAPI extension field `x-patternProperties`.
Use a separate library (e.g., `jsonref` or an OpenAPI parser) to dereference `$ref`s in your OpenAPI schema before conversion.
Be aware of the target JSON Schema draft. If you require conversion to a newer JSON Schema version or are working with OpenAPI 3.1, this library might not be suitable or may require post-processing.
Use the `keepNotSupported` option (a list of strings) to explicitly retain specific OpenAPI-only fields if they are critical for your use case and your JSON Schema validator can handle them as extensions.
Use the correct module name in your import statement: `from openapi_schema_to_json_schema import to_json_schema`.
Call the correct conversion function: `from openapi_schema_to_json_schema import to_json_schema` then `to_json_schema(your_schema)`.
Import the specific `to_json_schema` function and call it: `from openapi_schema_to_json_schema import to_json_schema` then `json_schema = to_json_schema(openapi_schema)`.
No dependency data recorded yet.