From 1feb2731237ae8a240646523d26bddd4651d7bae Mon Sep 17 00:00:00 2001 From: jasonh-n-austin Date: Fri, 29 May 2015 16:58:46 -0500 Subject: [PATCH 1/7] Samples for #417: Separated files, yaml only for now --- .../v2.0/yaml/petstore-separate-common.yaml | 10 ++ .../yaml/petstore-separate/definitions.yaml | 21 ++++ .../yaml/petstore-separate/parameters.yaml | 16 +++ .../v2.0/yaml/petstore-separate/swagger.yaml | 100 ++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 examples/v2.0/yaml/petstore-separate-common.yaml create mode 100644 examples/v2.0/yaml/petstore-separate/definitions.yaml create mode 100644 examples/v2.0/yaml/petstore-separate/parameters.yaml create mode 100644 examples/v2.0/yaml/petstore-separate/swagger.yaml diff --git a/examples/v2.0/yaml/petstore-separate-common.yaml b/examples/v2.0/yaml/petstore-separate-common.yaml new file mode 100644 index 0000000000..750eb87141 --- /dev/null +++ b/examples/v2.0/yaml/petstore-separate-common.yaml @@ -0,0 +1,10 @@ +Error: + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/examples/v2.0/yaml/petstore-separate/definitions.yaml b/examples/v2.0/yaml/petstore-separate/definitions.yaml new file mode 100644 index 0000000000..7ead1c5467 --- /dev/null +++ b/examples/v2.0/yaml/petstore-separate/definitions.yaml @@ -0,0 +1,21 @@ +Pet: + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string +NewPet: + allOf: + - $ref: '#/definitions/Pet' + - required: + - name + properties: + id: + type: integer + format: int64 \ No newline at end of file diff --git a/examples/v2.0/yaml/petstore-separate/parameters.yaml b/examples/v2.0/yaml/petstore-separate/parameters.yaml new file mode 100644 index 0000000000..a95e16b4d1 --- /dev/null +++ b/examples/v2.0/yaml/petstore-separate/parameters.yaml @@ -0,0 +1,16 @@ +tagsParam: + name: tags + in: query + description: tags to filter by + required: false + type: array + collectionFormat: csv + items: + type: string +limitsParam: + name: limit + in: query + description: maximum number of results to return + required: false + type: integer + format: int32 \ No newline at end of file diff --git a/examples/v2.0/yaml/petstore-separate/swagger.yaml b/examples/v2.0/yaml/petstore-separate/swagger.yaml new file mode 100644 index 0000000000..9cdb4f95dd --- /dev/null +++ b/examples/v2.0/yaml/petstore-separate/swagger.yaml @@ -0,0 +1,100 @@ +swagger: "2.0" +info: + version: 1.0.0 + title: Swagger Petstore + description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification + termsOfService: http://helloreverb.com/terms/ + contact: + name: Wordnik API Team + email: foo@example.com + url: http://madskristensen.net + license: + name: MIT + url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT +host: petstore.swagger.wordnik.com +basePath: /api +schemes: + - http +consumes: + - application/json +produces: + - application/json +paths: + /pets: + get: + description: | + Returns all pets from the system that the user has access to + Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. + + Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. + operationId: findPets + parameters: + - $ref: 'parameters.yaml#/tagsParam' + - $ref: 'parameters.yaml#/limitsParam' + responses: + 200: + description: pet response + schema: + type: array + items: + $ref: 'definitions.yaml#/Pet' + default: + description: unexpected error + schema: + $ref: '../petstore-separate-common.yaml#/Error' + post: + description: Creates a new pet in the store. Duplicates are allowed + operationId: addPet + parameters: + - name: pet + in: body + description: Pet to add to the store + required: true + schema: + $ref: 'definitions.yaml#/NewPet' + responses: + 200: + description: pet response + schema: + $ref: 'definitions.yaml#/Pet' + default: + description: unexpected error + schema: + $ref: '../petstore-separate-common.yaml#/Error' + /pets/{id}: + get: + description: Returns a user based on a single ID, if the user does not have access to the pet + operationId: find pet by id + parameters: + - name: id + in: path + description: ID of pet to fetch + required: true + type: integer + format: int64 + responses: + 200: + description: pet response + schema: + $ref: 'definitions.yaml#/Pet' + default: + description: unexpected error + schema: + $ref: '../petstore-separate-common.yaml#/Error' + delete: + description: deletes a single pet based on the ID supplied + operationId: deletePet + parameters: + - name: id + in: path + description: ID of pet to delete + required: true + type: integer + format: int64 + responses: + 204: + description: pet deleted + default: + description: unexpected error + schema: + $ref: '../petstore-separate-common.yaml#/Error' \ No newline at end of file From 72630f7121c1032a2b57719dbae3c13e99568dfd Mon Sep 17 00:00:00 2001 From: jasonh-n-austin Date: Thu, 4 Jun 2015 12:52:29 -0500 Subject: [PATCH 2/7] Refactored petstore-separate examples into dir --- .../v2.0/yaml/petstore-separate-common.yaml | 10 --------- .../yaml/petstore-separate/common/Error.yaml | 10 +++++++++ .../yaml/petstore-separate/definitions.yaml | 21 ------------------- .../yaml/petstore-separate/spec/NewPet.yaml | 9 ++++++++ .../v2.0/yaml/petstore-separate/spec/Pet.yaml | 12 +++++++++++ .../{ => spec}/parameters.yaml | 0 .../petstore-separate/{ => spec}/swagger.yaml | 16 +++++++------- 7 files changed, 39 insertions(+), 39 deletions(-) delete mode 100644 examples/v2.0/yaml/petstore-separate-common.yaml create mode 100644 examples/v2.0/yaml/petstore-separate/common/Error.yaml delete mode 100644 examples/v2.0/yaml/petstore-separate/definitions.yaml create mode 100644 examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml create mode 100644 examples/v2.0/yaml/petstore-separate/spec/Pet.yaml rename examples/v2.0/yaml/petstore-separate/{ => spec}/parameters.yaml (100%) rename examples/v2.0/yaml/petstore-separate/{ => spec}/swagger.yaml (90%) diff --git a/examples/v2.0/yaml/petstore-separate-common.yaml b/examples/v2.0/yaml/petstore-separate-common.yaml deleted file mode 100644 index 750eb87141..0000000000 --- a/examples/v2.0/yaml/petstore-separate-common.yaml +++ /dev/null @@ -1,10 +0,0 @@ -Error: - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/examples/v2.0/yaml/petstore-separate/common/Error.yaml b/examples/v2.0/yaml/petstore-separate/common/Error.yaml new file mode 100644 index 0000000000..2d87b744fb --- /dev/null +++ b/examples/v2.0/yaml/petstore-separate/common/Error.yaml @@ -0,0 +1,10 @@ +type: object +required: + - code + - message +properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/examples/v2.0/yaml/petstore-separate/definitions.yaml b/examples/v2.0/yaml/petstore-separate/definitions.yaml deleted file mode 100644 index 7ead1c5467..0000000000 --- a/examples/v2.0/yaml/petstore-separate/definitions.yaml +++ /dev/null @@ -1,21 +0,0 @@ -Pet: - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string -NewPet: - allOf: - - $ref: '#/definitions/Pet' - - required: - - name - properties: - id: - type: integer - format: int64 \ No newline at end of file diff --git a/examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml b/examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml new file mode 100644 index 0000000000..531e8df34b --- /dev/null +++ b/examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml @@ -0,0 +1,9 @@ +type: object +allOf: + - $ref: 'Pet.yaml' + - required: + - name + properties: + description: + type: integer + format: int64 \ No newline at end of file diff --git a/examples/v2.0/yaml/petstore-separate/spec/Pet.yaml b/examples/v2.0/yaml/petstore-separate/spec/Pet.yaml new file mode 100644 index 0000000000..bb113196f1 --- /dev/null +++ b/examples/v2.0/yaml/petstore-separate/spec/Pet.yaml @@ -0,0 +1,12 @@ +type: object +required: + - id + - name +properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string diff --git a/examples/v2.0/yaml/petstore-separate/parameters.yaml b/examples/v2.0/yaml/petstore-separate/spec/parameters.yaml similarity index 100% rename from examples/v2.0/yaml/petstore-separate/parameters.yaml rename to examples/v2.0/yaml/petstore-separate/spec/parameters.yaml diff --git a/examples/v2.0/yaml/petstore-separate/swagger.yaml b/examples/v2.0/yaml/petstore-separate/spec/swagger.yaml similarity index 90% rename from examples/v2.0/yaml/petstore-separate/swagger.yaml rename to examples/v2.0/yaml/petstore-separate/spec/swagger.yaml index 9cdb4f95dd..6f4a50692d 100644 --- a/examples/v2.0/yaml/petstore-separate/swagger.yaml +++ b/examples/v2.0/yaml/petstore-separate/spec/swagger.yaml @@ -37,11 +37,11 @@ paths: schema: type: array items: - $ref: 'definitions.yaml#/Pet' + $ref: 'Pet.yaml' default: description: unexpected error schema: - $ref: '../petstore-separate-common.yaml#/Error' + $ref: '../common/Error.yaml' post: description: Creates a new pet in the store. Duplicates are allowed operationId: addPet @@ -51,16 +51,16 @@ paths: description: Pet to add to the store required: true schema: - $ref: 'definitions.yaml#/NewPet' + $ref: 'NewPet.yaml' responses: 200: description: pet response schema: - $ref: 'definitions.yaml#/Pet' + $ref: 'Pet.yaml' default: description: unexpected error schema: - $ref: '../petstore-separate-common.yaml#/Error' + $ref: '../common/Error.yaml' /pets/{id}: get: description: Returns a user based on a single ID, if the user does not have access to the pet @@ -76,11 +76,11 @@ paths: 200: description: pet response schema: - $ref: 'definitions.yaml#/Pet' + $ref: 'Pet.yaml' default: description: unexpected error schema: - $ref: '../petstore-separate-common.yaml#/Error' + $ref: '../common/Error.yaml' delete: description: deletes a single pet based on the ID supplied operationId: deletePet @@ -97,4 +97,4 @@ paths: default: description: unexpected error schema: - $ref: '../petstore-separate-common.yaml#/Error' \ No newline at end of file + $ref: '../common/Error.yaml' \ No newline at end of file From cd92a24ce985f3c6833f82d3ca35f59a2d414041 Mon Sep 17 00:00:00 2001 From: jasonh-n-austin Date: Fri, 5 Jun 2015 10:17:48 -0500 Subject: [PATCH 3/7] Exclude independent schema files from swagger validation --- test/validate.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/validate.js b/test/validate.js index ba8da6c095..9e5a814cc2 100644 --- a/test/validate.js +++ b/test/validate.js @@ -113,10 +113,17 @@ describe('YAML Samples', function() { before(function(done) { setupValidators(done); }) + exclusions = ["./examples/v2.0/yaml/petstore-separate/common/Error.yaml", + "./examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml", + "./examples/v2.0/yaml/petstore-separate/spec/Pet.yaml", + "./examples/v2.0/yaml/petstore-separate/spec/parameters.yaml"] + files = glob.sync("./examples/**/*.yaml") validators.forEach(function(validator) { files.forEach(function(file) { - createYAMLTest(file, validator); + if (exclusions.indexOf(file) == -1) { + createYAMLTest(file, validator); + } }) }) }) From 89abb2ddce3d3dec36efb95db5d510287db5ed1b Mon Sep 17 00:00:00 2001 From: jasonh-n-austin Date: Fri, 5 Jun 2015 10:29:35 -0500 Subject: [PATCH 4/7] Fixed allOf example in petstore-expanded --- examples/v2.0/json/petstore-expanded.json | 72 ++++++++--------------- examples/v2.0/yaml/petstore-expanded.yaml | 26 ++++---- 2 files changed, 38 insertions(+), 60 deletions(-) diff --git a/examples/v2.0/json/petstore-expanded.json b/examples/v2.0/json/petstore-expanded.json index e2395255fc..d3e1868e6c 100644 --- a/examples/v2.0/json/petstore-expanded.json +++ b/examples/v2.0/json/petstore-expanded.json @@ -7,8 +7,8 @@ "termsOfService": "http://swagger.io/terms/", "contact": { "name": "Swagger API Team", - "email": "apiteam@swagger.io", - "url": "http://swagger.io" + "email": "foo@example.com", + "url": "http://madskristensen.net" }, "license": { "name": "MIT", @@ -29,14 +29,8 @@ "paths": { "/pets": { "get": { - "description": "Returns all pets from the system that the user has access to", + "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", "operationId": "findPets", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], "parameters": [ { "name": "tags", @@ -44,10 +38,10 @@ "description": "tags to filter by", "required": false, "type": "array", + "collectionFormat": "csv", "items": { "type": "string" - }, - "collectionFormat": "csv" + } }, { "name": "limit", @@ -71,7 +65,7 @@ "default": { "description": "unexpected error", "schema": { - "$ref": "#/definitions/ErrorModel" + "$ref": "#/definitions/Error" } } } @@ -79,9 +73,6 @@ "post": { "description": "Creates a new pet in the store. Duplicates are allowed", "operationId": "addPet", - "produces": [ - "application/json" - ], "parameters": [ { "name": "pet", @@ -103,7 +94,7 @@ "default": { "description": "unexpected error", "schema": { - "$ref": "#/definitions/ErrorModel" + "$ref": "#/definitions/Error" } } } @@ -112,13 +103,7 @@ "/pets/{id}": { "get": { "description": "Returns a user based on a single ID, if the user does not have access to the pet", - "operationId": "findPetById", - "produces": [ - "application/json", - "application/xml", - "text/xml", - "text/html" - ], + "operationId": "find pet by id", "parameters": [ { "name": "id", @@ -139,7 +124,7 @@ "default": { "description": "unexpected error", "schema": { - "$ref": "#/definitions/ErrorModel" + "$ref": "#/definitions/Error" } } } @@ -164,7 +149,7 @@ "default": { "description": "unexpected error", "schema": { - "$ref": "#/definitions/ErrorModel" + "$ref": "#/definitions/Error" } } } @@ -173,31 +158,13 @@ }, "definitions": { "Pet": { - "required": [ - "id", - "name" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "tag": { - "type": "string" - } - } - }, - "NewPet": { "allOf": [ { - "$ref": "#/definitions/Pet" + "$ref": "#/definitions/NewPet" }, { "required": [ - "name" + "id" ], "properties": { "id": { @@ -208,7 +175,20 @@ } ] }, - "ErrorModel": { + "NewPet": { + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "Error": { "required": [ "code", "message" diff --git a/examples/v2.0/yaml/petstore-expanded.yaml b/examples/v2.0/yaml/petstore-expanded.yaml index 6db4c8f5d9..e450633a5e 100644 --- a/examples/v2.0/yaml/petstore-expanded.yaml +++ b/examples/v2.0/yaml/petstore-expanded.yaml @@ -112,26 +112,24 @@ paths: $ref: '#/definitions/Error' definitions: Pet: - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - NewPet: allOf: - - $ref: '#/definitions/Pet' + - $ref: '#/definitions/NewPet' - required: - - name + - id properties: id: type: integer format: int64 + + NewPet: + required: + - name + properties: + name: + type: string + tag: + type: string + Error: required: - code From a0cd3cf2a2ec423fcee4052a2abc1a6014b876ff Mon Sep 17 00:00:00 2001 From: jasonh-n-austin Date: Fri, 5 Jun 2015 10:41:26 -0500 Subject: [PATCH 5/7] JSON-ified petstore-separate examples --- .../v2.0/json/petstore-separate/NewPet.json | 19 +++ examples/v2.0/json/petstore-separate/Pet.json | 19 +++ .../json/petstore-separate/common/Error.json | 16 ++ .../json/petstore-separate/parameters.json | 21 +++ .../v2.0/json/petstore-separate/swagger.json | 146 ++++++++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 examples/v2.0/json/petstore-separate/NewPet.json create mode 100644 examples/v2.0/json/petstore-separate/Pet.json create mode 100644 examples/v2.0/json/petstore-separate/common/Error.json create mode 100644 examples/v2.0/json/petstore-separate/parameters.json create mode 100644 examples/v2.0/json/petstore-separate/swagger.json diff --git a/examples/v2.0/json/petstore-separate/NewPet.json b/examples/v2.0/json/petstore-separate/NewPet.json new file mode 100644 index 0000000000..27310836e4 --- /dev/null +++ b/examples/v2.0/json/petstore-separate/NewPet.json @@ -0,0 +1,19 @@ +{ + "type": "object", + "allOf": [ + { + "$ref": "Pet.yaml" + }, + { + "required": [ + "name" + ], + "properties": { + "description": { + "type": "integer", + "format": "int64" + } + } + } + ] +} diff --git a/examples/v2.0/json/petstore-separate/Pet.json b/examples/v2.0/json/petstore-separate/Pet.json new file mode 100644 index 0000000000..28e7d61c32 --- /dev/null +++ b/examples/v2.0/json/petstore-separate/Pet.json @@ -0,0 +1,19 @@ +{ + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } +} diff --git a/examples/v2.0/json/petstore-separate/common/Error.json b/examples/v2.0/json/petstore-separate/common/Error.json new file mode 100644 index 0000000000..9f0e0aeec0 --- /dev/null +++ b/examples/v2.0/json/petstore-separate/common/Error.json @@ -0,0 +1,16 @@ +{ + "type": "object", + "required": [ + "code", + "message" + ], + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } +} diff --git a/examples/v2.0/json/petstore-separate/parameters.json b/examples/v2.0/json/petstore-separate/parameters.json new file mode 100644 index 0000000000..98bb1ace91 --- /dev/null +++ b/examples/v2.0/json/petstore-separate/parameters.json @@ -0,0 +1,21 @@ +{ + "tagsParam": { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "required": false, + "type": "array", + "collectionFormat": "csv", + "items": { + "type": "string" + } + }, + "limitsParam": { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "required": false, + "type": "integer", + "format": "int32" + } +} diff --git a/examples/v2.0/json/petstore-separate/swagger.json b/examples/v2.0/json/petstore-separate/swagger.json new file mode 100644 index 0000000000..fa482c9b19 --- /dev/null +++ b/examples/v2.0/json/petstore-separate/swagger.json @@ -0,0 +1,146 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "Swagger Petstore", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Wordnik API Team", + "email": "foo@example.com", + "url": "http://madskristensen.net" + }, + "license": { + "name": "MIT", + "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT" + } + }, + "host": "petstore.swagger.wordnik.com", + "basePath": "/api", + "schemes": [ + "http" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n", + "operationId": "findPets", + "parameters": [ + { + "$ref": "parameters.yaml#/tagsParam" + }, + { + "$ref": "parameters.yaml#/limitsParam" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "$ref": "Pet.yaml" + } + } + }, + "default": { + "description": "unexpected error", + "schema": { + "$ref": "../common/Error.yaml" + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "parameters": [ + { + "name": "pet", + "in": "body", + "description": "Pet to add to the store", + "required": true, + "schema": { + "$ref": "NewPet.yaml" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "$ref": "Pet.yaml" + } + }, + "default": { + "description": "unexpected error", + "schema": { + "$ref": "../common/Error.yaml" + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "find pet by id", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "$ref": "Pet.yaml" + } + }, + "default": { + "description": "unexpected error", + "schema": { + "$ref": "../common/Error.yaml" + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "default": { + "description": "unexpected error", + "schema": { + "$ref": "../common/Error.yaml" + } + } + } + } + } + } +} From 72d307fe12cf8db767a9890e5d452288a196edd6 Mon Sep 17 00:00:00 2001 From: jasonh-n-austin Date: Fri, 5 Jun 2015 10:45:58 -0500 Subject: [PATCH 6/7] Fixed JSON examples into spec path, added JSON test exclusions --- .../json/petstore-separate/{ => spec}/NewPet.json | 0 .../v2.0/json/petstore-separate/{ => spec}/Pet.json | 0 .../petstore-separate/{ => spec}/parameters.json | 0 .../json/petstore-separate/{ => spec}/swagger.json | 0 test/validate.js | 12 +++++++++++- 5 files changed, 11 insertions(+), 1 deletion(-) rename examples/v2.0/json/petstore-separate/{ => spec}/NewPet.json (100%) rename examples/v2.0/json/petstore-separate/{ => spec}/Pet.json (100%) rename examples/v2.0/json/petstore-separate/{ => spec}/parameters.json (100%) rename examples/v2.0/json/petstore-separate/{ => spec}/swagger.json (100%) diff --git a/examples/v2.0/json/petstore-separate/NewPet.json b/examples/v2.0/json/petstore-separate/spec/NewPet.json similarity index 100% rename from examples/v2.0/json/petstore-separate/NewPet.json rename to examples/v2.0/json/petstore-separate/spec/NewPet.json diff --git a/examples/v2.0/json/petstore-separate/Pet.json b/examples/v2.0/json/petstore-separate/spec/Pet.json similarity index 100% rename from examples/v2.0/json/petstore-separate/Pet.json rename to examples/v2.0/json/petstore-separate/spec/Pet.json diff --git a/examples/v2.0/json/petstore-separate/parameters.json b/examples/v2.0/json/petstore-separate/spec/parameters.json similarity index 100% rename from examples/v2.0/json/petstore-separate/parameters.json rename to examples/v2.0/json/petstore-separate/spec/parameters.json diff --git a/examples/v2.0/json/petstore-separate/swagger.json b/examples/v2.0/json/petstore-separate/spec/swagger.json similarity index 100% rename from examples/v2.0/json/petstore-separate/swagger.json rename to examples/v2.0/json/petstore-separate/spec/swagger.json diff --git a/test/validate.js b/test/validate.js index 9e5a814cc2..243442d3e0 100644 --- a/test/validate.js +++ b/test/validate.js @@ -100,11 +100,19 @@ describe('JSON Samples', function() { before(function(done) { setupValidators(done); }) + exclusions = ["./examples/v2.0/json/petstore-separate/common/Error.json", + "./examples/v2.0/json/petstore-separate/spec/NewPet.json", + "./examples/v2.0/json/petstore-separate/spec/Pet.json", + "./examples/v2.0/json/petstore-separate/spec/parameters.json"] files = glob.sync("./examples/**/*.json") validators.forEach(function(validator) { files.forEach(function(file) { - createJSONTest(file, validator); + if (exclusions.indexOf(file) == -1) { + createJSONTest(file, validator); + } else { + //TODO: validate separate schema files in exclusion list + } }) }) }) @@ -123,6 +131,8 @@ describe('YAML Samples', function() { files.forEach(function(file) { if (exclusions.indexOf(file) == -1) { createYAMLTest(file, validator); + } else { + //TODO: validate separate schema files in exclusion list } }) }) From 94924733c072fb4784a35be529c37947ea99ed83 Mon Sep 17 00:00:00 2001 From: jasonh-n-austin Date: Fri, 5 Jun 2015 10:51:42 -0500 Subject: [PATCH 7/7] Adding for all JSON example definitions --- examples/v2.0/json/petstore-expanded.json | 3 +++ examples/v2.0/json/petstore-minimal.json | 1 + examples/v2.0/json/petstore-simple.json | 3 +++ examples/v2.0/json/petstore-with-external-docs.json | 3 +++ examples/v2.0/json/petstore.json | 2 ++ 5 files changed, 12 insertions(+) diff --git a/examples/v2.0/json/petstore-expanded.json b/examples/v2.0/json/petstore-expanded.json index d3e1868e6c..01d280973d 100644 --- a/examples/v2.0/json/petstore-expanded.json +++ b/examples/v2.0/json/petstore-expanded.json @@ -158,6 +158,7 @@ }, "definitions": { "Pet": { + "type": "object", "allOf": [ { "$ref": "#/definitions/NewPet" @@ -176,6 +177,7 @@ ] }, "NewPet": { + "type": "object", "required": [ "name" ], @@ -189,6 +191,7 @@ } }, "Error": { + "type": "object", "required": [ "code", "message" diff --git a/examples/v2.0/json/petstore-minimal.json b/examples/v2.0/json/petstore-minimal.json index 971134c5a6..0c70baed7e 100644 --- a/examples/v2.0/json/petstore-minimal.json +++ b/examples/v2.0/json/petstore-minimal.json @@ -46,6 +46,7 @@ }, "definitions": { "Pet": { + "type": "object", "required": [ "id", "name" diff --git a/examples/v2.0/json/petstore-simple.json b/examples/v2.0/json/petstore-simple.json index c2ffaf6615..a088d1a1be 100644 --- a/examples/v2.0/json/petstore-simple.json +++ b/examples/v2.0/json/petstore-simple.json @@ -170,6 +170,7 @@ }, "definitions": { "Pet": { + "type": "object", "required": [ "id", "name" @@ -188,6 +189,7 @@ } }, "PetInput": { + "type": "object", "allOf": [ { "$ref": "#/definitions/Pet" @@ -206,6 +208,7 @@ ] }, "ErrorModel": { + "type": "object", "required": [ "code", "message" diff --git a/examples/v2.0/json/petstore-with-external-docs.json b/examples/v2.0/json/petstore-with-external-docs.json index ac609dc79e..3e0fb73187 100644 --- a/examples/v2.0/json/petstore-with-external-docs.json +++ b/examples/v2.0/json/petstore-with-external-docs.json @@ -181,6 +181,7 @@ }, "definitions": { "Pet": { + "type": "object", "required": [ "id", "name" @@ -203,6 +204,7 @@ } }, "NewPet": { + "type": "object", "allOf": [ { "$ref": "#/definitions/Pet" @@ -221,6 +223,7 @@ ] }, "ErrorModel": { + "type": "object", "required": [ "code", "message" diff --git a/examples/v2.0/json/petstore.json b/examples/v2.0/json/petstore.json index e7e800ab2b..bb1fcb3b94 100644 --- a/examples/v2.0/json/petstore.json +++ b/examples/v2.0/json/petstore.json @@ -49,6 +49,7 @@ }, "definitions": { "Pet": { + "type": "object", "required": [ "id", "name" @@ -67,6 +68,7 @@ } }, "Error": { + "type": "object", "required": [ "code", "message"