You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package aims at full conversion support except reference resolution, but isn't there yet. Currently supports:
null/nullable conversion
$ref's being converted #/definitions <-> #/components/schemas
const ➡ enum when converting to OpenAPI
$id/$comment ➡ info['x-id']/info['x-comment'] when converting to OpenAPI
PR's are welcome.
JSON $refs are not resolved.
This package has no dependencies, and will continue to have no dependencies - re: minimalistic.
Versions
Since v2 this is a pure ESM package, and requires Node.js >=14.13.1. It cannot be used from CommonJS.
Usage
import{jsonSchemaToOpenApiSchema,openApiSchemaToJsonSchema,}from'openapi-json-schema'// JSON Schema to Open APIconstopenApi=jsonSchemaToOpenApiSchema(jsonSchema);// Open API to JSON SchemaconstjsonSchema=openApiSchemaToJsonSchema(openApi);
Utilities
The library exports utilities; encodeRefNameJsonSchema, decodeRefNameJsonSchema, encodeRefNameOpenApi and decodeRefNameOpenApi used to convert to/from references names, and their corresponding encoding in JSON Schema and Open API.