Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected object or boolean as schema, got string #13

Open
MisinformedDNA opened this issue Oct 12, 2018 · 2 comments
Open

Expected object or boolean as schema, got string #13

MisinformedDNA opened this issue Oct 12, 2018 · 2 comments

Comments

@MisinformedDNA
Copy link

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

@philsturgeon
Copy link
Contributor

Can you try this again? We've made some improvements.

@postatum
Copy link

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"
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants