Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this json schema invalid? using "any" type

Tags:

jsonschema

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "my json api",
    "description": "my json api",
    "type": "object",
    "properties": {
        "my_api_response": {
           "type": "object",
            "properties": {
                "MailboxInfo": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "ADSyncLinkEnabled": {
                                "type": "any"
                            }
                        }
                    }
                }
            }
        }
    },
    "required": ["response"]
}

I am using python jsonschema 2.0.0 and it gives me the following error:

{u'type': u'object', u'properties': {u'ADSyncLinkEnabled': {u'type': u'any'}}} is not valid under any of the given schemas
like image 285
tadasajon Avatar asked May 30 '13 00:05

tadasajon


People also ask

How do I check if a JSON Schema is valid?

The simplest way to check if JSON is valid is to load the JSON into a JObject or JArray and then use the IsValid(JToken, JsonSchema) method with the JSON Schema. To get validation error messages, use the IsValid(JToken, JsonSchema, IList<String> ) or Validate(JToken, JsonSchema, ValidationEventHandler) overloads.

What is type in JSON Schema?

The type keyword is fundamental to JSON Schema. It specifies the data type for a schema. At its core, JSON Schema defines the following basic types: string. number.

How do I set a schema in JSON?

At the top of the file, you can specify the schema's id, the schema that should be used to validate the format of your schema, and a descriptive title. These are all defined using the keywords id, $schema and title, all of which are provided in the draft JSON Schema.


1 Answers

This is because any is no longer a valid value for the type keyword.

If you want a schema which matches everything, just use the empty schema: {}.

like image 193
fge Avatar answered Sep 30 '22 17:09

fge