- Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Hi, does this routine support the definitions keyword as described in the JSON Schema documentation? Using json-schema-to-openapi-schema, converting a JSON Schema with a "definitions" property does not seem to handle nullable types properly (sending the individual interfaces to json-schema-to-openapi-schema works. Note that I am not using #refs.
Here is an example:
JSON Schema:
{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "Product": { "type": "object", "properties": { "name": { "type": "string" }, "price": { "type": "number" }, "rating": { "type": [ "null", "number" ] } }, "required": [ "name", "price", "rating" ] }, "ProductList": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" }, "products": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "price": { "type": "number" }, "rating": { "type": [ "null", "number" ] } }, "required": [ "name", "price", "rating" ] } } }, "required": [ "name", "products", "version" ] } } }Results in OpenAPI JSON (note "null" types):
{ "Product": { "type": "object", "properties": { "name": { "type": "string" }, "price": { "type": "number" }, "rating": { "type": [ "null", "number" ] } }, "required": [ "name", "price", "rating" ] }, "ProductList": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" }, "products": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "price": { "type": "number" }, "rating": { "type": [ "null", "number" ] } }, "required": [ "name", "price", "rating" ] } } }, "required": [ "name", "products", "version" ] } }I was hoping to see something like this:
{ "Product": { "type": "object", "properties": { "name": { "type": "string" }, "price": { "type": "number" }, "rating": { "type": "number", "nullable": true } }, "required": [ "name", "price", "rating" ] }, "ProductList": { "type": "object", "properties": { "name": { "type": "string" }, "version": { "type": "string" }, "products": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "price": { "type": "number" }, "rating": { "type": "number", "nullable": true } }, "required": [ "name", "price", "rating" ] } } }, "required": [ "name", "products", "version" ] } }Metadata
Metadata
Assignees
Labels
No labels