json-schema-to-openapi-schema
json-schema-to-openapi-schema copied to clipboard
Expected object or boolean as schema, got string
I wanted to convert the JSON schema here, but I get an error message:
D:\Repos\swagger-editor\node_modules@cloudflare\json-schema-walker\lib\schemaWalk.js:92 throw 'Expected object or boolean as schema, got ' + ^ Expected object or boolean as schema, got string
Can you try this again? We've made some improvements.
I'm having the same issue on Linux. Lib version 0.4.0. Here's a JSON Schema I use. It uses some features of newer drafts but online JSON Schema validation tools say it's a valid Draft4-5 schema.
{
"$schema": "https://json-schema.org/draft-04/schema",
"definitions": {
"address": {
"type": "object",
"properties": {
"street_address": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
}
},
"required": [
"street_address",
"city",
"state"
]
}
},
"links": [
{
"rel": "self",
"href": ""
},
{
"rel": "about",
"href": "/docs",
"targetSchema": {
"$ref": "/author/schema"
}
}
],
"$id": "hello",
"type": "object",
"required": ["dependenciesProp"],
"properties": {
"dependenciesProp": {
"type": "object",
"properties": {
"a": {
"type": "string"
}
},
"dependencies": {
"one": ["emailFormat"]
}
},
"exclusiveMaximumProp": {
"type": "number",
"maximum": 99,
"minimum": 1,
"exclusiveMaximum": true,
"exclusiveMinimum": true
},
"emailFormat": {
"type": "string",
"format": "email"
},
"hostnameFormat": {
"type": "string",
"format": "hostname"
},
"ipv4Format": {
"type": "string",
"format": "ipv4"
},
"ipv6Format": {
"type": "string",
"format": "ipv6"
},
"uriFormat": {
"type": "string",
"format": "uri"
},
"allOfProp": {
"allOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"oneOfProp": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"notProp": {
"not": {
"type": "string"
}
},
"itemsArray": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"containsProp": {
"type": "array",
"contains": {
"type": "number"
}
},
"readOnlyProp": {
"type": "number",
"readOnly": true
},
"writeOnlyProp": {
"type": "number",
"writeOnly": true
},
"additionalItemsProp": {
"type": "array",
"additionalItems": false
},
"propertyNamesProp": {
"type": "object",
"propertyNames": {
"pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
}
},
"patternPropertiesProp": {
"type": "object",
"^S_": {
"type": "string"
},
"^I_": {
"type": "integer"
}
},
"mediaProp": {
"type": "string",
"media": "text/html"
}
}
}