{"id":5013,"library":"py-openapi-schema-to-json-schema","title":"OpenAPI Schema to JSON Schema Converter","description":"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).","status":"maintenance","version":"0.0.3","language":"en","source_language":"en","source_url":"https://github.com/pglass/py-openapi-schema-to-json-schema","tags":["openapi","json-schema","conversion","validation","api-design"],"install":[{"cmd":"pip install py-openapi-schema-to-json-schema","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"symbol":"to_json_schema","correct":"from openapi_schema_to_json_schema import to_json_schema"}],"quickstart":{"code":"import json\nfrom openapi_schema_to_json_schema import to_json_schema\n\nopenapi_schema = {\n    \"type\": \"object\",\n    \"properties\": {\n        \"name\": {\n            \"type\": \"string\",\n            \"nullable\": True,\n        }\n    },\n    \"x-patternProperties\": {\n        \"^[a-z]+$\": {\n            \"type\": \"number\",\n        }\n    }\n}\n\n# Options can be passed to control conversion behavior\n# For example, to enable conversion of 'x-patternProperties' to 'patternProperties'\noptions = {\"supportPatternProperties\": True}\n\nconverted_schema = to_json_schema(openapi_schema, options)\nprint(json.dumps(converted_schema, indent=2))","lang":"python","description":"Demonstrates converting a simple OpenAPI schema object, including handling `nullable` and an OpenAPI extension field `x-patternProperties`."},"warnings":[{"fix":"Use a separate library (e.g., `jsonref` or an OpenAPI parser) to dereference `$ref`s in your OpenAPI schema before conversion.","message":"The library does not dereference `$ref` fields within the OpenAPI schema. If your schema uses `$ref`s, you must resolve them using another tool or library before passing the schema to `to_json_schema`.","severity":"gotcha","affected_versions":"0.0.3"},{"fix":"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.","message":"This library converts OpenAPI 3.0 schemas to JSON Schema Draft 4. It does not support newer JSON Schema drafts (e.g., Draft 2019-09, 2020-12) or OpenAPI 3.1, which aligns with newer JSON Schema versions. Using it for newer standards may lead to incompatible or incomplete conversions.","severity":"gotcha","affected_versions":"0.0.3"},{"fix":"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.","message":"By default, several OpenAPI-specific keywords (e.g., `discriminator`, `readOnly`, `writeOnly`, `xml`, `externalDocs`, `example`, `deprecated`) are removed from the resulting JSON Schema as they are not standard in JSON Schema Draft 4. The `nullable` keyword is converted into a `type` array that includes `\"null\"`.","severity":"gotcha","affected_versions":"0.0.3"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}