Last active
August 29, 2015 14:04
-
-
Save maxlinc/cc8a4c518d5e09f74ae0 to your computer and use it in GitHub Desktop.
ZSchema bug?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "http://json-schema.org/draft-04/schema#", | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"description": "Core schema meta-schema", | |
"definitions": { | |
"schemaArray": { | |
"type": "array", | |
"minItems": 1, | |
"items": { "$ref": "#" } | |
}, | |
"positiveInteger": { | |
"type": "integer", | |
"minimum": 0 | |
}, | |
"positiveIntegerDefault0": { | |
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ] | |
}, | |
"simpleTypes": { | |
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ] | |
}, | |
"stringArray": { | |
"type": "array", | |
"items": { "type": "string" }, | |
"minItems": 1, | |
"uniqueItems": true | |
} | |
}, | |
"type": "object", | |
"properties": { | |
"id": { | |
"type": "string", | |
"format": "uri" | |
}, | |
"$schema": { | |
"type": "string", | |
"format": "uri" | |
}, | |
"title": { | |
"type": "string" | |
}, | |
"description": { | |
"type": "string" | |
}, | |
"default": {}, | |
"multipleOf": { | |
"type": "number", | |
"minimum": 0, | |
"exclusiveMinimum": true | |
}, | |
"maximum": { | |
"type": "number" | |
}, | |
"exclusiveMaximum": { | |
"type": "boolean", | |
"default": false | |
}, | |
"minimum": { | |
"type": "number" | |
}, | |
"exclusiveMinimum": { | |
"type": "boolean", | |
"default": false | |
}, | |
"maxLength": { "$ref": "#/definitions/positiveInteger" }, | |
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" }, | |
"pattern": { | |
"type": "string", | |
"format": "regex" | |
}, | |
"additionalItems": { | |
"anyOf": [ | |
{ "type": "boolean" }, | |
{ "$ref": "#" } | |
], | |
"default": {} | |
}, | |
"items": { | |
"anyOf": [ | |
{ "$ref": "#" }, | |
{ "$ref": "#/definitions/schemaArray" } | |
], | |
"default": {} | |
}, | |
"maxItems": { "$ref": "#/definitions/positiveInteger" }, | |
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" }, | |
"uniqueItems": { | |
"type": "boolean", | |
"default": false | |
}, | |
"maxProperties": { "$ref": "#/definitions/positiveInteger" }, | |
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" }, | |
"required": { "$ref": "#/definitions/stringArray" }, | |
"additionalProperties": { | |
"anyOf": [ | |
{ "type": "boolean" }, | |
{ "$ref": "#" } | |
], | |
"default": {} | |
}, | |
"definitions": { | |
"type": "object", | |
"additionalProperties": { "$ref": "#" }, | |
"default": {} | |
}, | |
"properties": { | |
"type": "object", | |
"additionalProperties": { "$ref": "#" }, | |
"default": {} | |
}, | |
"patternProperties": { | |
"type": "object", | |
"additionalProperties": { "$ref": "#" }, | |
"default": {} | |
}, | |
"dependencies": { | |
"type": "object", | |
"additionalProperties": { | |
"anyOf": [ | |
{ "$ref": "#" }, | |
{ "$ref": "#/definitions/stringArray" } | |
] | |
} | |
}, | |
"enum": { | |
"type": "array", | |
"minItems": 1, | |
"uniqueItems": true | |
}, | |
"type": { | |
"anyOf": [ | |
{ "$ref": "#/definitions/simpleTypes" }, | |
{ | |
"type": "array", | |
"items": { "$ref": "#/definitions/simpleTypes" }, | |
"minItems": 1, | |
"uniqueItems": true | |
} | |
] | |
}, | |
"allOf": { "$ref": "#/definitions/schemaArray" }, | |
"anyOf": { "$ref": "#/definitions/schemaArray" }, | |
"oneOf": { "$ref": "#/definitions/schemaArray" }, | |
"not": { "$ref": "#" } | |
}, | |
"dependencies": { | |
"exclusiveMaximum": [ "maximum" ], | |
"exclusiveMinimum": [ "minimum" ] | |
}, | |
"default": {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"swagger": 2, | |
"info": { | |
"version": "1.0.0", | |
"title": "Swagger Petstore", | |
"contact": { | |
"name": "wordnik api team", | |
"url": "http://developer.wordnik.com" | |
}, | |
"license": { | |
"name": "Creative Commons 4.0 International", | |
"url": "http://creativecommons.org/licenses/by/4.0/" | |
} | |
}, | |
"host": "http://petstore.swagger.wordnik.com", | |
"basePath": "/api", | |
"schemes": [ | |
"http" | |
], | |
"paths": { | |
"/pets": { | |
"get": { | |
"tags": [ | |
"Pet Operations" | |
], | |
"summary": "finds pets in the system", | |
"responses": { | |
"200": { | |
"description": "pet response", | |
"schema": { | |
"type": "array", | |
"items": { | |
"$ref": "#/models/Pet" | |
} | |
}, | |
"headers": [ | |
{ | |
"x-expires": { | |
"type": "string" | |
} | |
} | |
] | |
}, | |
"default": { | |
"description": "unexpected error", | |
"schema": { | |
"$ref": "#/models/Error" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"schemas": { | |
"Pet": { | |
"required": [ | |
"id", | |
"name" | |
], | |
"properties": { | |
"id": { | |
"type": "integer", | |
"format": "int64" | |
}, | |
"name": { | |
"type": "string" | |
}, | |
"tag": { | |
"type": "string" | |
} | |
} | |
}, | |
"Error": { | |
"required": [ | |
"code", | |
"message" | |
], | |
"properties": { | |
"code": { | |
"type": "integer", | |
"format": "int32" | |
}, | |
"message": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "A JSON Schema for Swagger 2.0 API.", | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"type": "object", | |
"required": [ "swagger", "info", "paths" ], | |
"definitions": { | |
"info": { | |
"type": "object", | |
"description": "General information about the API.", | |
"required": [ "version", "title" ], | |
"additionalProperties": false, | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"version": { | |
"type": "string", | |
"description": "A semantic version number of the API." | |
}, | |
"title": { | |
"type": "string", | |
"description": "A unique and precise title of the API." | |
}, | |
"description": { | |
"type": "string", | |
"description": "A longer description of the API. Should be different from the title." | |
}, | |
"termsOfService": { | |
"type": "string", | |
"description": "The terms of service for the API." | |
}, | |
"contact": { | |
"type": "object", | |
"description": "Contact information for the owners of the API.", | |
"additionalProperties": false, | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "The identifying name of the contact person/organization." | |
}, | |
"url": { | |
"type": "string", | |
"description": "The URL pointing to the contact information.", | |
"format": "uri" | |
}, | |
"email": { | |
"type": "string", | |
"description": "The email address of the contact person/organization.", | |
"format": "email" | |
} | |
} | |
}, | |
"license": { | |
"type": "object", | |
"required": [ "name" ], | |
"additionalProperties": false, | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "The name of the license type. It's encouraged to use an OSI compatible license." | |
}, | |
"url": { | |
"type": "string", | |
"description": "The URL pointing to the license.", | |
"format": "uri" | |
} | |
} | |
} | |
} | |
}, | |
"example": { | |
"type": "object", | |
"patternProperties": { | |
"^[a-z0-9-]+/[a-z0-9-+]+$": {} | |
}, | |
"additionalProperties": false | |
}, | |
"mimeType": { | |
"type": "string", | |
"pattern": "^[a-z0-9-]+/[a-z0-9-+]+$", | |
"description": "The MIME type of the HTTP message." | |
}, | |
"operation": { | |
"type": "object", | |
"required": [ "responses" ], | |
"additionalProperties": false, | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"tags": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
} | |
}, | |
"summary": { | |
"type": "string", | |
"description": "A brief summary of the operation." | |
}, | |
"description": { | |
"type": "string", | |
"description": "A longer description of the operation." | |
}, | |
"operationId": { | |
"type": "string", | |
"description": "A friendly name of the operation" | |
}, | |
"produces": { | |
"type": "array", | |
"description": "A list of MIME types the API can produce.", | |
"additionalItems": false, | |
"items": { | |
"$ref": "#/definitions/mimeType" | |
} | |
}, | |
"parameters": { | |
"type": "array", | |
"description": "The parameters needed to send a valid API call.", | |
"minItems": 1, | |
"additionalItems": false, | |
"items": { | |
"$ref": "#/definitions/parameter" | |
} | |
}, | |
"responses": { | |
"$ref": "#/definitions/responses" | |
}, | |
"schemes": { | |
"type": "array", | |
"description": "The transfer protocol of the API.", | |
"items": { | |
"type": "string", | |
"enum": [ "http", "https", "ws", "wss" ] | |
} | |
} | |
} | |
}, | |
"responses": { | |
"type": "object", | |
"description": "Response objects names can either be any valid HTTP status code or 'default'.", | |
"minProperties": 1, | |
"additionalProperties": false, | |
"patternProperties": { | |
"^([0-9]+)$|^(default)$": { | |
"$ref": "#/definitions/response" | |
}, | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
} | |
}, | |
"response": { | |
"type": "object", | |
"required": [ "description" ], | |
"properties": { | |
"description": { | |
"type": "string" | |
}, | |
"schema": { | |
"$ref": "#/definitions/schema" | |
}, | |
"headers": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/schema" | |
} | |
}, | |
"examples": { | |
"$ref": "#/definitions/example" | |
} | |
}, | |
"additionalProperties": false | |
}, | |
"vendorExtension": { | |
"description": "Any property starting with x- is valid.", | |
"additionalProperties": true, | |
"additionalItems": true | |
}, | |
"parameter": { | |
"type": "object", | |
"required": [ "name", "in"], | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "The name of the parameter." | |
}, | |
"in": { | |
"type": "string", | |
"description": "Determines the location of the parameter.", | |
"enum": [ "query", "header", "path", "formData", "body" ], | |
"default": "query" | |
}, | |
"description": { | |
"type": "string", | |
"description": "A brief description of the parameter. This could contain examples of use." | |
}, | |
"required": { | |
"type": "boolean", | |
"description": "Determines whether or not this parameter is required or optional." | |
}, | |
"schema": { | |
"$ref": "#/definitions/schema" | |
} | |
} | |
}, | |
"schema": { | |
"type": "object", | |
"description": "A deterministic version of a JSON Schema object.", | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"$ref": { "type": "string" }, | |
"format": { "type": "string" }, | |
"title": { "$ref": "http://json-schema.org/draft-04/schema#/properties/title" }, | |
"description": { "$ref": "http://json-schema.org/draft-04/schema#/properties/description" }, | |
"default": { "$ref": "http://json-schema.org/draft-04/schema#/properties/default" }, | |
"multipleOf": { "$ref": "http://json-schema.org/draft-04/schema#/properties/multipleOf" }, | |
"maximum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/maximum" }, | |
"exclusiveMaximum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMaximum" }, | |
"minimum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/minimum" }, | |
"exclusiveMinimum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum" }, | |
"maxLength": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" }, | |
"minLength": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" }, | |
"pattern": { "$ref": "http://json-schema.org/draft-04/schema#/properties/pattern" }, | |
"discriminator": { "type": "string" }, | |
"xml": { "$ref": "#/definitions/xml"}, | |
"items": { | |
"anyOf": [ | |
{ "$ref": "#/definitions/schema" }, | |
{ | |
"type": "array", | |
"minItems": 1, | |
"items": { "$ref": "#/definitions/schema" } | |
} | |
], | |
"default": { } | |
}, | |
"maxItems": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" }, | |
"minItems": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" }, | |
"uniqueItems": { "$ref": "http://json-schema.org/draft-04/schema#/properties/uniqueItems" }, | |
"maxProperties": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger" }, | |
"minProperties": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveIntegerDefault0" }, | |
"required": { "$ref": "http://json-schema.org/draft-04/schema#/definitions/stringArray" }, | |
"definitions": { | |
"type": "object", | |
"additionalProperties": { "$ref": "#/definitions/schema" }, | |
"default": { } | |
}, | |
"properties": { | |
"type": "object", | |
"additionalProperties": { "$ref": "#/definitions/schema" }, | |
"default": { } | |
}, | |
"enum": { "$ref": "http://json-schema.org/draft-04/schema#/properties/enum" }, | |
"type": { "$ref": "http://json-schema.org/draft-04/schema#/properties/type" }, | |
"allOf": { | |
"type": "array", | |
"minItems": 1, | |
"items": { "$ref": "#/definitions/schema" } | |
} | |
} | |
}, | |
"xml": { | |
"properties": { | |
"namespace": { "type": "string" }, | |
"prefix": { "type": "string" }, | |
"attribute": { "type": "boolean" }, | |
"wrapped": { "type": "boolean" } | |
}, | |
"additionalProperties": false | |
} | |
}, | |
"additionalProperties": false, | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"swagger": { | |
"type": "number", | |
"enum": [ 2.0 ], | |
"description": "The Swagger version of this document." | |
}, | |
"info": { | |
"$ref": "#/definitions/info" | |
}, | |
"host": { | |
"type": "string", | |
"format": "uri", | |
"description": "The fully qualified URI to the host of the API." | |
}, | |
"basePath": { | |
"type": "string", | |
"pattern": "^/", | |
"description": "The base path to the API. Example: '/api'." | |
}, | |
"schemes": { | |
"type": "array", | |
"description": "The transfer protocol of the API.", | |
"items": { | |
"type": "string", | |
"enum": [ "http", "https", "ws", "wss" ] | |
} | |
}, | |
"consumes": { | |
"type": "array", | |
"description": "A list of MIME types accepted by the API.", | |
"items": { | |
"$ref": "#/definitions/mimeType" | |
} | |
}, | |
"produces": { | |
"type": "array", | |
"description": "A list of MIME types the API can produce.", | |
"items": { | |
"$ref": "#/definitions/mimeType" | |
} | |
}, | |
"paths": { | |
"type": "object", | |
"description": "Relative paths to the individual endpoints. They should be relative to the 'basePath'.", | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"additionalProperties": { | |
"type": "object", | |
"minProperties": 1, | |
"additionalProperties": false, | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"get": { | |
"$ref": "#/definitions/operation" | |
}, | |
"put": { | |
"$ref": "#/definitions/operation" | |
}, | |
"post": { | |
"$ref": "#/definitions/operation" | |
}, | |
"delete": { | |
"$ref": "#/definitions/operation" | |
}, | |
"options": { | |
"$ref": "#/definitions/operation" | |
}, | |
"head": { | |
"$ref": "#/definitions/operation" | |
}, | |
"patch": { | |
"$ref": "#/definitions/operation" | |
}, | |
"parameters": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/parameter" | |
} | |
} | |
} | |
} | |
}, | |
"schemas": { | |
"type": "object", | |
"description": "One or more JSON objects describing the schemas being consumed and produced by the API.", | |
"additionalProperties": { | |
"$ref": "#/definitions/schema" | |
} | |
}, | |
"security": { | |
"type": "array" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "A JSON Schema for Swagger 2.0 API.", | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"type": "object", | |
"required": [ "swagger", "info", "paths" ], | |
"definitions": { | |
"info": { | |
"type": "object", | |
"description": "General information about the API.", | |
"required": [ "version", "title" ], | |
"additionalProperties": false, | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"version": { | |
"type": "string", | |
"description": "A semantic version number of the API." | |
}, | |
"title": { | |
"type": "string", | |
"description": "A unique and precise title of the API." | |
}, | |
"description": { | |
"type": "string", | |
"description": "A longer description of the API. Should be different from the title." | |
}, | |
"termsOfService": { | |
"type": "string", | |
"description": "The terms of service for the API." | |
}, | |
"contact": { | |
"type": "object", | |
"description": "Contact information for the owners of the API.", | |
"additionalProperties": false, | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "The identifying name of the contact person/organization." | |
}, | |
"url": { | |
"type": "string", | |
"description": "The URL pointing to the contact information.", | |
"format": "uri" | |
}, | |
"email": { | |
"type": "string", | |
"description": "The email address of the contact person/organization.", | |
"format": "email" | |
} | |
} | |
}, | |
"license": { | |
"type": "object", | |
"required": [ "name" ], | |
"additionalProperties": false, | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "The name of the license type. It's encouraged to use an OSI compatible license." | |
}, | |
"url": { | |
"type": "string", | |
"description": "The URL pointing to the license.", | |
"format": "uri" | |
} | |
} | |
} | |
} | |
}, | |
"example": { | |
"type": "object", | |
"patternProperties": { | |
"^[a-z0-9-]+/[a-z0-9-+]+$": {} | |
}, | |
"additionalProperties": false | |
}, | |
"mimeType": { | |
"type": "string", | |
"pattern": "^[a-z0-9-]+/[a-z0-9-+]+$", | |
"description": "The MIME type of the HTTP message." | |
}, | |
"operation": { | |
"type": "object", | |
"required": [ "responses" ], | |
"additionalProperties": false, | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"tags": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
} | |
}, | |
"summary": { | |
"type": "string", | |
"description": "A brief summary of the operation." | |
}, | |
"description": { | |
"type": "string", | |
"description": "A longer description of the operation." | |
}, | |
"operationId": { | |
"type": "string", | |
"description": "A friendly name of the operation" | |
}, | |
"produces": { | |
"type": "array", | |
"description": "A list of MIME types the API can produce.", | |
"additionalItems": false, | |
"items": { | |
"$ref": "#/definitions/mimeType" | |
} | |
}, | |
"parameters": { | |
"type": "array", | |
"description": "The parameters needed to send a valid API call.", | |
"minItems": 1, | |
"additionalItems": false, | |
"items": { | |
"$ref": "#/definitions/parameter" | |
} | |
}, | |
"responses": { | |
"$ref": "#/definitions/responses" | |
}, | |
"schemes": { | |
"type": "array", | |
"description": "The transfer protocol of the API.", | |
"items": { | |
"type": "string", | |
"enum": [ "http", "https", "ws", "wss" ] | |
} | |
} | |
} | |
}, | |
"responses": { | |
"type": "object", | |
"description": "Response objects names can either be any valid HTTP status code or 'default'.", | |
"minProperties": 1, | |
"additionalProperties": false, | |
"patternProperties": { | |
"^([0-9]+)$|^(default)$": { | |
"$ref": "#/definitions/response" | |
}, | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
} | |
}, | |
"response": { | |
"type": "object", | |
"required": [ "description" ], | |
"properties": { | |
"description": { | |
"type": "string" | |
}, | |
"schema": { | |
"$ref": "#/definitions/schema" | |
}, | |
"headers": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/schema" | |
} | |
}, | |
"examples": { | |
"$ref": "#/definitions/example" | |
} | |
}, | |
"additionalProperties": false | |
}, | |
"vendorExtension": { | |
"description": "Any property starting with x- is valid.", | |
"additionalProperties": true, | |
"additionalItems": true | |
}, | |
"parameter": { | |
"type": "object", | |
"required": [ "name", "in"], | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "The name of the parameter." | |
}, | |
"in": { | |
"type": "string", | |
"description": "Determines the location of the parameter.", | |
"enum": [ "query", "header", "path", "formData", "body" ], | |
"default": "query" | |
}, | |
"description": { | |
"type": "string", | |
"description": "A brief description of the parameter. This could contain examples of use." | |
}, | |
"required": { | |
"type": "boolean", | |
"description": "Determines whether or not this parameter is required or optional." | |
}, | |
"schema": { | |
"$ref": "#/definitions/schema" | |
} | |
} | |
}, | |
"schema": { | |
"type": "object", | |
"description": "A deterministic version of a JSON Schema object.", | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"$ref": { "type": "string" }, | |
"format": { "type": "string" }, | |
"title": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/title" }, | |
"description": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/description" }, | |
"default": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/default" }, | |
"multipleOf": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/multipleOf" }, | |
"maximum": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/maximum" }, | |
"exclusiveMaximum": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/exclusiveMaximum" }, | |
"minimum": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/minimum" }, | |
"exclusiveMinimum": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/exclusiveMinimum" }, | |
"maxLength": { "$ref": "http://json-schema.orgx/draft-04/schema#/definitions/positiveInteger" }, | |
"minLength": { "$ref": "http://json-schema.orgx/draft-04/schema#/definitions/positiveIntegerDefault0" }, | |
"pattern": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/pattern" }, | |
"discriminator": { "type": "string" }, | |
"xml": { "$ref": "#/definitions/xml"}, | |
"items": { | |
"anyOf": [ | |
{ "$ref": "#/definitions/schema" }, | |
{ | |
"type": "array", | |
"minItems": 1, | |
"items": { "$ref": "#/definitions/schema" } | |
} | |
], | |
"default": { } | |
}, | |
"maxItems": { "$ref": "http://json-schema.orgx/draft-04/schema#/definitions/positiveInteger" }, | |
"minItems": { "$ref": "http://json-schema.orgx/draft-04/schema#/definitions/positiveIntegerDefault0" }, | |
"uniqueItems": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/uniqueItems" }, | |
"maxProperties": { "$ref": "http://json-schema.orgx/draft-04/schema#/definitions/positiveInteger" }, | |
"minProperties": { "$ref": "http://json-schema.orgx/draft-04/schema#/definitions/positiveIntegerDefault0" }, | |
"required": { "$ref": "http://json-schema.orgx/draft-04/schema#/definitions/stringArray" }, | |
"definitions": { | |
"type": "object", | |
"additionalProperties": { "$ref": "#/definitions/schema" }, | |
"default": { } | |
}, | |
"properties": { | |
"type": "object", | |
"additionalProperties": { "$ref": "#/definitions/schema" }, | |
"default": { } | |
}, | |
"enum": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/enum" }, | |
"type": { "$ref": "http://json-schema.orgx/draft-04/schema#/properties/type" }, | |
"allOf": { | |
"type": "array", | |
"minItems": 1, | |
"items": { "$ref": "#/definitions/schema" } | |
} | |
} | |
}, | |
"xml": { | |
"properties": { | |
"namespace": { "type": "string" }, | |
"prefix": { "type": "string" }, | |
"attribute": { "type": "boolean" }, | |
"wrapped": { "type": "boolean" } | |
}, | |
"additionalProperties": false | |
} | |
}, | |
"additionalProperties": false, | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"swagger": { | |
"type": "number", | |
"enum": [ 2.0 ], | |
"description": "The Swagger version of this document." | |
}, | |
"info": { | |
"$ref": "#/definitions/info" | |
}, | |
"host": { | |
"type": "string", | |
"format": "uri", | |
"description": "The fully qualified URI to the host of the API." | |
}, | |
"basePath": { | |
"type": "string", | |
"pattern": "^/", | |
"description": "The base path to the API. Example: '/api'." | |
}, | |
"schemes": { | |
"type": "array", | |
"description": "The transfer protocol of the API.", | |
"items": { | |
"type": "string", | |
"enum": [ "http", "https", "ws", "wss" ] | |
} | |
}, | |
"consumes": { | |
"type": "array", | |
"description": "A list of MIME types accepted by the API.", | |
"items": { | |
"$ref": "#/definitions/mimeType" | |
} | |
}, | |
"produces": { | |
"type": "array", | |
"description": "A list of MIME types the API can produce.", | |
"items": { | |
"$ref": "#/definitions/mimeType" | |
} | |
}, | |
"paths": { | |
"type": "object", | |
"description": "Relative paths to the individual endpoints. They should be relative to the 'basePath'.", | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"additionalProperties": { | |
"type": "object", | |
"minProperties": 1, | |
"additionalProperties": false, | |
"patternProperties": { | |
"^x-": { | |
"$ref": "#/definitions/vendorExtension" | |
} | |
}, | |
"properties": { | |
"get": { | |
"$ref": "#/definitions/operation" | |
}, | |
"put": { | |
"$ref": "#/definitions/operation" | |
}, | |
"post": { | |
"$ref": "#/definitions/operation" | |
}, | |
"delete": { | |
"$ref": "#/definitions/operation" | |
}, | |
"options": { | |
"$ref": "#/definitions/operation" | |
}, | |
"head": { | |
"$ref": "#/definitions/operation" | |
}, | |
"patch": { | |
"$ref": "#/definitions/operation" | |
}, | |
"parameters": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/parameter" | |
} | |
} | |
} | |
} | |
}, | |
"schemas": { | |
"type": "object", | |
"description": "One or more JSON objects describing the schemas being consumed and produced by the API.", | |
"additionalProperties": { | |
"$ref": "#/definitions/schema" | |
} | |
}, | |
"security": { | |
"type": "array" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ZSchema = require("z-schema"); | |
var fs = require('fs'); | |
var draft4 = String(fs.readFileSync('draft4.json')); | |
var modified_schema = JSON.parse(fs.readFileSync('swagger_draft_modified.json')); | |
var real_schema = JSON.parse(fs.readFileSync('swagger_draft.json')); | |
var json = JSON.parse(fs.readFileSync('sample.json')); | |
ZSchema.setRemoteReference('http://json-schema.org/draft-04/schema', draft4); // Correct URL | |
ZSchema.setRemoteReference('http://json-schema.orgx/draft-04/schema', draft4); // Modified URL | |
var validate = function(schema, title) { | |
try { | |
var validator = new ZSchema({ sync: true }); | |
var valid = validator.validate(json, schema); | |
if (!valid) { | |
console.log(title + " contained validation errors:" + validator.getLastError().errors); | |
} else { | |
console.log(title + " validated successfully!"); | |
} | |
} catch(err) { | |
console.log("Error while attempting to validate " + title + ": " + err); | |
} | |
}; | |
validate(modified_schema, "Modified URL schema"); | |
validate(real_schema, "Real URL schema"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment