├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build.sbt
├── examples
└── v2.0
│ ├── json
│ ├── api-with-examples.json
│ ├── petstore-expanded.json
│ ├── petstore-minimal.json
│ ├── petstore-separate
│ │ ├── common
│ │ │ └── Error.json
│ │ └── spec
│ │ │ ├── NewPet.json
│ │ │ ├── Pet.json
│ │ │ ├── parameters.json
│ │ │ └── swagger.json
│ ├── petstore-simple.json
│ ├── petstore-with-external-docs.json
│ ├── petstore.json
│ └── uber.json
│ └── yaml
│ ├── api-with-examples.yaml
│ ├── petstore-expanded.yaml
│ ├── petstore-minimal.yaml
│ ├── petstore-separate
│ ├── common
│ │ └── Error.yaml
│ └── spec
│ │ ├── NewPet.yaml
│ │ ├── Pet.yaml
│ │ ├── parameters.yaml
│ │ └── swagger.yaml
│ ├── petstore-simple.yaml
│ ├── petstore-with-external-docs.yaml
│ ├── petstore.yaml
│ └── uber.yaml
├── fixtures
├── v1.2
│ └── helloworld
│ │ ├── server
│ │ ├── README.md
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── webapp
│ │ │ ├── api-docs
│ │ │ ├── css
│ │ │ ├── highlight.default.css
│ │ │ └── screen.css
│ │ │ ├── images
│ │ │ ├── logo_small.png
│ │ │ ├── pet_store_api.png
│ │ │ ├── throbber.gif
│ │ │ └── wordnik_api.png
│ │ │ ├── index.html
│ │ │ ├── lib
│ │ │ ├── backbone-min.js
│ │ │ ├── handlebars-1.0.0.js
│ │ │ ├── highlight.7.3.pack.js
│ │ │ ├── jquery-1.8.0.min.js
│ │ │ ├── jquery.ba-bbq.min.js
│ │ │ ├── jquery.slideto.min.js
│ │ │ ├── jquery.wiggle.min.js
│ │ │ ├── shred.bundle.js
│ │ │ ├── shred
│ │ │ │ └── content.js
│ │ │ ├── swagger.js
│ │ │ └── underscore-min.js
│ │ │ ├── listings
│ │ │ └── greetings
│ │ │ ├── swagger-ui.js
│ │ │ └── swagger-ui.min.js
│ │ └── static
│ │ ├── README.md
│ │ ├── api-docs
│ │ └── listings
│ │ └── greetings
└── v2.0
│ ├── json
│ ├── general
│ │ ├── basicInfoObject.json
│ │ ├── externalDocs.json
│ │ ├── minimalInfoObject.json
│ │ └── negative
│ │ │ ├── negativeExternalDocs.json
│ │ │ └── negativeInfoObject.json
│ ├── models
│ │ ├── modelWithArrayRef.json
│ │ ├── modelWithComposition.json
│ │ ├── modelWithDateTimeMap.json
│ │ ├── modelWithExamples.json
│ │ ├── modelWithInt32Map.json
│ │ ├── modelWithInt64Map.json
│ │ ├── modelWithMultipleProperties.json
│ │ ├── modelWithPrimitiveArray.json
│ │ ├── modelWithStringProperty.json
│ │ ├── modelWithXmlAttributes.json
│ │ ├── models.json
│ │ ├── multipleModels.json
│ │ └── properties
│ │ │ ├── propertyWithBooleanArray.json
│ │ │ ├── propertyWithByteArray.json
│ │ │ ├── propertyWithComplexArray.json
│ │ │ ├── propertyWithDateTimeArray.json
│ │ │ ├── propertyWithInt32Array.json
│ │ │ ├── propertyWithInt64Array.json
│ │ │ ├── propertyWithStringArray.json
│ │ │ ├── simpleBooleanProperty.json
│ │ │ ├── simpleByteProperty.json
│ │ │ ├── simpleDateTimeProperty.json
│ │ │ ├── simpleInt32Property.json
│ │ │ ├── simpleInt64Property.json
│ │ │ └── simpleStringProperty.json
│ ├── resources
│ │ ├── cascadingSchemes.json
│ │ ├── commonParameters.json
│ │ ├── multipleMimeTypes.json
│ │ ├── operations
│ │ │ ├── operationWithTags.json
│ │ │ ├── stringPathAndBoolQueryParamResource.json
│ │ │ └── stringPathParamResource.json
│ │ ├── parameters
│ │ │ ├── bodyComplexArrayParameter.json
│ │ │ ├── bodyComplexInlineParameter.json
│ │ │ ├── bodyComplexParameter.json
│ │ │ ├── bodyInt64Parameter.json
│ │ │ ├── bodyStringArrayParameter.json
│ │ │ ├── bodyStringParameter.json
│ │ │ ├── formDataInt64Parameter.json
│ │ │ ├── formDataStringArrayParameter.json
│ │ │ ├── formDataStringParameter.json
│ │ │ ├── headerInt64ArrayParameter.json
│ │ │ ├── headerStringArrayParameter.json
│ │ │ ├── headerStringParameter.json
│ │ │ ├── negative
│ │ │ │ ├── bodyFileParameter.json
│ │ │ │ ├── bodyNonSchemaParameter.json
│ │ │ │ ├── formDataComplexParameter.json
│ │ │ │ ├── formDataSchemaParameter.json
│ │ │ │ ├── headerComplexParameter.json
│ │ │ │ ├── headerFileParameter.json
│ │ │ │ ├── headerSchemaParameter.json
│ │ │ │ ├── pathComplexParameter.json
│ │ │ │ ├── pathFileParameter.json
│ │ │ │ ├── pathNonRequiredStringParameter.json
│ │ │ │ ├── pathSchemaParameter.json
│ │ │ │ ├── queryComplexParameter.json
│ │ │ │ ├── queryFileParameter.json
│ │ │ │ └── querySchemaParameter.json
│ │ │ ├── pathInt64Parameter.json
│ │ │ ├── pathStringArrayParameter.json
│ │ │ ├── pathStringParameter.json
│ │ │ ├── queryInt64ArrayParameter.json
│ │ │ └── queryInt64Parameter.json
│ │ ├── resourceWithExamplePayload.json
│ │ ├── resourceWithLinkedDefinitions.json
│ │ ├── resourceWithLinkedDefinitions_part1.json
│ │ ├── resourceWithRelativeHost.json
│ │ ├── reusableParameters.json
│ │ ├── securityExample.json
│ │ ├── stringPathParamResource.json
│ │ ├── taggedResource.json
│ │ └── vendorExtensionExamples.json
│ └── responses
│ │ ├── complexArrayResponse.json
│ │ ├── dateTimeResponse.json
│ │ ├── int32Response.json
│ │ ├── int64Response.json
│ │ ├── multipleResponses.json
│ │ ├── negative
│ │ ├── noResponses.json
│ │ └── noResponsesWithVendorExtension.json
│ │ ├── stringArrayResponse.json
│ │ ├── stringResponse.json
│ │ ├── stringResponseWithHeader.json
│ │ └── voidResponse.json
│ └── yaml
│ └── .gitkeep
├── guidelines
├── EXTENSIONS.md
├── README.md
├── REUSE.md
└── sample-server
│ ├── README.md
│ ├── files
│ ├── models.json
│ ├── operations.json
│ ├── parameters.json
│ ├── responses.json
│ └── swagger.json
│ ├── package.json
│ └── server.js
├── gulpfile.js
├── package.json
├── schemas
├── v1.2
│ ├── README.md
│ ├── apiDeclaration.json
│ ├── authorizationObject.json
│ ├── dataType.json
│ ├── dataTypeBase.json
│ ├── infoObject.json
│ ├── modelsObject.json
│ ├── oauth2GrantType.json
│ ├── operationObject.json
│ ├── parameterObject.json
│ ├── resourceListing.json
│ └── resourceObject.json
└── v2.0
│ ├── README.md
│ ├── bower.json
│ ├── package.json
│ └── schema.json
├── src
├── main
│ └── javascript
│ │ └── server.js
└── test
│ └── scala
│ ├── GeneralTest.scala
│ ├── ModelTest.scala
│ ├── ModelsTest.scala
│ ├── OperationsTest.scala
│ ├── ParameterTest.scala
│ ├── PropertyTest.scala
│ ├── ResourcesTest.scala
│ ├── ResponseTest.scala
│ ├── ResponsesTest.scala
│ └── TestBase.scala
├── swagger-logo.jpg
├── test
├── validate.js
└── validate_spec.rb
└── versions
├── 1.2.md
└── 2.0.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | *.iml
3 | *.ipr
4 | *.iws
5 | target
6 | atlassian-ide-plugin.xml
7 | node_modules/
8 | Gemfile.lock
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: scala
3 | scala:
4 | - 2.10.4
5 | script:
6 | - npm install
7 | - npm test
8 | - sbt ++$TRAVIS_SCALA_VERSION test
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2016 The Linux Foundation
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
6 |
7 | Unless required by applicable law or agreed to in writing, software
8 | distributed under the License is distributed on an "AS IS" BASIS,
9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 | See the License for the specific language governing permissions and
11 | limitations under the License.
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The OpenAPI Specification (fka The Swagger Specification)
2 |
3 | [](https://travis-ci.org/OAI/OpenAPI-Specification)
4 |
5 | 
6 |
7 | **Looking for the next version of the OpenAPI Specification? [See here](https://github.com/OAI/OpenAPI-Specification/tree/OpenAPI.next).**
8 |
9 | The goal of The OpenAPI Specification is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, OpenAPI removes the guesswork in calling the service.
10 |
11 | Use cases for machine-readable API interfaces include interactive documentation, code generation for documentation, client, and server, as well as automated test cases. OpenAPI-enabled APIs expose JSON files that correctly adhere to the OpenAPI Specification, documented in this repository. These files can either be produced and served statically, or be generated dynamically from your application.
12 |
13 | Without going into a long history of interfaces to Web Services, this is not the first attempt to do so. We can learn from CORBA, WSDL and WADL. These specifications had good intentions but were limited by proprietary vendor-specific implementations, being bound to a specific programming language, and goals which were too open-ended. In the end, they failed to gain traction.
14 |
15 | OpenAPI does not require you to rewrite your existing API. It does not require binding any software to a service--the service being described may not even be yours. It does, however, require the capabilities of the service be described in the structure of the OpenAPI Specification. Not all services can be described by OpenAPI--this specification is not intended to cover every possible use-case of a REST-ful API. OpenAPI does not define a specific development process such as design-first or code-first. It does facilitate either technique by establishing clear interactions with a REST API.
16 |
17 | This GitHub project is the starting point for OpenAPI.
18 | Here you will find the information you need about the OpenAPI Specification, a simple static sample of what it looks like,
19 | and some general information regarding the project.
20 |
21 |
22 | ## Current Version - 2.0
23 |
24 | The current version of the OpenAPI specification is 2.0 - and you can find it [here](versions/2.0.md).
25 |
26 | ### [OpenAPI 2.0 Specification](versions/2.0.md)
27 |
28 | This repository contains the existing Swagger 1.2, 2.0 specifications as well as proposals for the next version of the specification, which will be called the OpenAPI Specification 3.0. The proposals live in the [OpenAPI.next](https://github.com/OAI/OpenAPI-Specification/tree/OpenAPI.next) branch.
29 |
30 | ## Structure
31 |
32 | Each section should contain v1.2 and v2.0 folders to avoid confusion between the versions.
33 |
34 | Please keep in mind that the other projects under OpenAPI use an independent version system.
35 | As such, don't confuse the version of the OpenAPI Specification they support and the version of that given library.
36 |
37 | ## The Wiki
38 |
39 | Check out the [wiki](https://github.com/OAI/OpenAPI-Specification/wiki) for additional and relevant information about the project.
40 |
41 | This includes:
42 | - Static sample tutorial.
43 | - List of known deployments.
44 | - Revision history.
45 |
46 | ## See it in Action
47 |
48 | If you just want to see it work, check out the [pet store sample](http://petstore.swagger.io/).
49 |
50 | ## Tools and Libraries
51 |
52 | Looking to see how you can create your own OpenAPI definition, present it or otherwise use it? Check out our [list of tools](http://swagger.io/open-source-integrations/) over at [http://swagger.io](http://swagger.io/open-source-integrations/).
53 |
54 | (Yes, there used to be a really long list here, we just moved it to the main website)
55 |
56 | ## License
57 |
58 | Copyright 2016 The Linux Foundation
59 |
60 | Licensed under the Apache License, Version 2.0 (the "License");
61 | you may not use this file except in compliance with the License.
62 | You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
63 |
64 | Unless required by applicable law or agreed to in writing, software
65 | distributed under the License is distributed on an "AS IS" BASIS,
66 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67 | See the License for the specific language governing permissions and
68 | limitations under the License.
69 |
--------------------------------------------------------------------------------
/build.sbt:
--------------------------------------------------------------------------------
1 | name := "schema-test"
2 |
3 | scalaVersion := "2.10.4"
4 |
5 | libraryDependencies ++= Seq(
6 | "com.github.fge" % "json-schema-validator" % "2.2.5",
7 | "junit" % "junit" % "4.8.1" % "test",
8 | "org.scalatest" %% "scalatest" % "1.9.2" % "test"
9 | )
10 |
--------------------------------------------------------------------------------
/examples/v2.0/json/api-with-examples.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "title": "Simple API overview",
5 | "version": "v2"
6 | },
7 | "paths": {
8 | "/": {
9 | "get": {
10 | "operationId": "listVersionsv2",
11 | "summary": "List API versions",
12 | "produces": [
13 | "application/json"
14 | ],
15 | "responses": {
16 | "200": {
17 | "description": "200 300 response",
18 | "examples": {
19 | "application/json": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}"
20 | }
21 | },
22 | "300": {
23 | "description": "200 300 response",
24 | "examples": {
25 | "application/json": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}"
26 | }
27 | }
28 | }
29 | }
30 | },
31 | "/v2": {
32 | "get": {
33 | "operationId": "getVersionDetailsv2",
34 | "summary": "Show API version details",
35 | "produces": [
36 | "application/json"
37 | ],
38 | "responses": {
39 | "200": {
40 | "description": "200 203 response",
41 | "examples": {
42 | "application/json": "{\n \"version\": {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"media-types\": [\n {\n \"base\": \"application/xml\",\n \"type\": \"application/vnd.openstack.compute+xml;version=2\"\n },\n {\n \"base\": \"application/json\",\n \"type\": \"application/vnd.openstack.compute+json;version=2\"\n }\n ],\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf\",\n \"type\": \"application/pdf\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n }\n ]\n }\n}"
43 | }
44 | },
45 | "203": {
46 | "description": "200 203 response",
47 | "examples": {
48 | "application/json": "{\n \"version\": {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"media-types\": [\n {\n \"base\": \"application/xml\",\n \"type\": \"application/vnd.openstack.compute+xml;version=2\"\n },\n {\n \"base\": \"application/json\",\n \"type\": \"application/vnd.openstack.compute+json;version=2\"\n }\n ],\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://23.253.228.211:8774/v2/\",\n \"rel\": \"self\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf\",\n \"type\": \"application/pdf\",\n \"rel\": \"describedby\"\n },\n {\n \"href\": \"http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl\",\n \"type\": \"application/vnd.sun.wadl+xml\",\n \"rel\": \"describedby\"\n }\n ]\n }\n}"
49 | }
50 | }
51 | }
52 | }
53 | }
54 | },
55 | "consumes": [
56 | "application/json"
57 | ]
58 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore-minimal.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.0",
5 | "title": "Swagger Petstore",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team"
10 | },
11 | "license": {
12 | "name": "MIT"
13 | }
14 | },
15 | "host": "petstore.swagger.io",
16 | "basePath": "/api",
17 | "schemes": [
18 | "http"
19 | ],
20 | "consumes": [
21 | "application/json"
22 | ],
23 | "produces": [
24 | "application/json"
25 | ],
26 | "paths": {
27 | "/pets": {
28 | "get": {
29 | "description": "Returns all pets from the system that the user has access to",
30 | "produces": [
31 | "application/json"
32 | ],
33 | "responses": {
34 | "200": {
35 | "description": "A list of pets.",
36 | "schema": {
37 | "type": "array",
38 | "items": {
39 | "$ref": "#/definitions/Pet"
40 | }
41 | }
42 | }
43 | }
44 | }
45 | }
46 | },
47 | "definitions": {
48 | "Pet": {
49 | "type": "object",
50 | "required": [
51 | "id",
52 | "name"
53 | ],
54 | "properties": {
55 | "id": {
56 | "type": "integer",
57 | "format": "int64"
58 | },
59 | "name": {
60 | "type": "string"
61 | },
62 | "tag": {
63 | "type": "string"
64 | }
65 | }
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore-separate/common/Error.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "object",
3 | "required": [
4 | "code",
5 | "message"
6 | ],
7 | "properties": {
8 | "code": {
9 | "type": "integer",
10 | "format": "int32"
11 | },
12 | "message": {
13 | "type": "string"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore-separate/spec/NewPet.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "object",
3 | "allOf": [
4 | {
5 | "$ref": "Pet.json"
6 | },
7 | {
8 | "required": [
9 | "name"
10 | ],
11 | "properties": {
12 | "description": {
13 | "type": "integer",
14 | "format": "int64"
15 | }
16 | }
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore-separate/spec/Pet.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "object",
3 | "required": [
4 | "id",
5 | "name"
6 | ],
7 | "properties": {
8 | "id": {
9 | "type": "integer",
10 | "format": "int64"
11 | },
12 | "name": {
13 | "type": "string"
14 | },
15 | "tag": {
16 | "type": "string"
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore-separate/spec/parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "tagsParam": {
3 | "name": "tags",
4 | "in": "query",
5 | "description": "tags to filter by",
6 | "required": false,
7 | "type": "array",
8 | "collectionFormat": "csv",
9 | "items": {
10 | "type": "string"
11 | }
12 | },
13 | "limitsParam": {
14 | "name": "limit",
15 | "in": "query",
16 | "description": "maximum number of results to return",
17 | "required": false,
18 | "type": "integer",
19 | "format": "int32"
20 | }
21 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore-separate/spec/swagger.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.0",
5 | "title": "Swagger Petstore",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://helloreverb.com/terms/",
8 | "contact": {
9 | "name": "Wordnik API Team",
10 | "email": "foo@example.com",
11 | "url": "http://madskristensen.net"
12 | },
13 | "license": {
14 | "name": "MIT",
15 | "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT"
16 | }
17 | },
18 | "host": "petstore.swagger.wordnik.com",
19 | "basePath": "/api",
20 | "schemes": [
21 | "http"
22 | ],
23 | "consumes": [
24 | "application/json"
25 | ],
26 | "produces": [
27 | "application/json"
28 | ],
29 | "paths": {
30 | "/pets": {
31 | "get": {
32 | "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",
33 | "operationId": "findPets",
34 | "parameters": [
35 | {
36 | "$ref": "parameters.json#/tagsParam"
37 | },
38 | {
39 | "$ref": "parameters.json#/limitsParam"
40 | }
41 | ],
42 | "responses": {
43 | "200": {
44 | "description": "pet response",
45 | "schema": {
46 | "type": "array",
47 | "items": {
48 | "$ref": "Pet.json"
49 | }
50 | }
51 | },
52 | "default": {
53 | "description": "unexpected error",
54 | "schema": {
55 | "$ref": "../common/Error.json"
56 | }
57 | }
58 | }
59 | },
60 | "post": {
61 | "description": "Creates a new pet in the store. Duplicates are allowed",
62 | "operationId": "addPet",
63 | "parameters": [
64 | {
65 | "name": "pet",
66 | "in": "body",
67 | "description": "Pet to add to the store",
68 | "required": true,
69 | "schema": {
70 | "$ref": "NewPet.json"
71 | }
72 | }
73 | ],
74 | "responses": {
75 | "200": {
76 | "description": "pet response",
77 | "schema": {
78 | "$ref": "Pet.json"
79 | }
80 | },
81 | "default": {
82 | "description": "unexpected error",
83 | "schema": {
84 | "$ref": "../common/Error.json"
85 | }
86 | }
87 | }
88 | }
89 | },
90 | "/pets/{id}": {
91 | "get": {
92 | "description": "Returns a user based on a single ID, if the user does not have access to the pet",
93 | "operationId": "find pet by id",
94 | "parameters": [
95 | {
96 | "name": "id",
97 | "in": "path",
98 | "description": "ID of pet to fetch",
99 | "required": true,
100 | "type": "integer",
101 | "format": "int64"
102 | }
103 | ],
104 | "responses": {
105 | "200": {
106 | "description": "pet response",
107 | "schema": {
108 | "$ref": "Pet.json"
109 | }
110 | },
111 | "default": {
112 | "description": "unexpected error",
113 | "schema": {
114 | "$ref": "../common/Error.json"
115 | }
116 | }
117 | }
118 | },
119 | "delete": {
120 | "description": "deletes a single pet based on the ID supplied",
121 | "operationId": "deletePet",
122 | "parameters": [
123 | {
124 | "name": "id",
125 | "in": "path",
126 | "description": "ID of pet to delete",
127 | "required": true,
128 | "type": "integer",
129 | "format": "int64"
130 | }
131 | ],
132 | "responses": {
133 | "204": {
134 | "description": "pet deleted"
135 | },
136 | "default": {
137 | "description": "unexpected error",
138 | "schema": {
139 | "$ref": "../common/Error.json"
140 | }
141 | }
142 | }
143 | }
144 | }
145 | }
146 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore-simple.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.0",
5 | "title": "Swagger Petstore",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team"
10 | },
11 | "license": {
12 | "name": "MIT"
13 | }
14 | },
15 | "host": "petstore.swagger.io",
16 | "basePath": "/api",
17 | "schemes": [
18 | "http"
19 | ],
20 | "consumes": [
21 | "application/json"
22 | ],
23 | "produces": [
24 | "application/json"
25 | ],
26 | "paths": {
27 | "/pets": {
28 | "get": {
29 | "description": "Returns all pets from the system that the user has access to",
30 | "operationId": "findPets",
31 | "produces": [
32 | "application/json",
33 | "application/xml",
34 | "text/xml",
35 | "text/html"
36 | ],
37 | "parameters": [
38 | {
39 | "name": "tags",
40 | "in": "query",
41 | "description": "tags to filter by",
42 | "required": false,
43 | "type": "array",
44 | "items": {
45 | "type": "string"
46 | },
47 | "collectionFormat": "csv"
48 | },
49 | {
50 | "name": "limit",
51 | "in": "query",
52 | "description": "maximum number of results to return",
53 | "required": false,
54 | "type": "integer",
55 | "format": "int32"
56 | }
57 | ],
58 | "responses": {
59 | "200": {
60 | "description": "pet response",
61 | "schema": {
62 | "type": "array",
63 | "items": {
64 | "$ref": "#/definitions/Pet"
65 | }
66 | }
67 | },
68 | "default": {
69 | "description": "unexpected error",
70 | "schema": {
71 | "$ref": "#/definitions/ErrorModel"
72 | }
73 | }
74 | }
75 | },
76 | "post": {
77 | "description": "Creates a new pet in the store. Duplicates are allowed",
78 | "operationId": "addPet",
79 | "produces": [
80 | "application/json"
81 | ],
82 | "parameters": [
83 | {
84 | "name": "pet",
85 | "in": "body",
86 | "description": "Pet to add to the store",
87 | "required": true,
88 | "schema": {
89 | "$ref": "#/definitions/NewPet"
90 | }
91 | }
92 | ],
93 | "responses": {
94 | "200": {
95 | "description": "pet response",
96 | "schema": {
97 | "$ref": "#/definitions/Pet"
98 | }
99 | },
100 | "default": {
101 | "description": "unexpected error",
102 | "schema": {
103 | "$ref": "#/definitions/ErrorModel"
104 | }
105 | }
106 | }
107 | }
108 | },
109 | "/pets/{id}": {
110 | "get": {
111 | "description": "Returns a user based on a single ID, if the user does not have access to the pet",
112 | "operationId": "findPetById",
113 | "produces": [
114 | "application/json",
115 | "application/xml",
116 | "text/xml",
117 | "text/html"
118 | ],
119 | "parameters": [
120 | {
121 | "name": "id",
122 | "in": "path",
123 | "description": "ID of pet to fetch",
124 | "required": true,
125 | "type": "integer",
126 | "format": "int64"
127 | }
128 | ],
129 | "responses": {
130 | "200": {
131 | "description": "pet response",
132 | "schema": {
133 | "$ref": "#/definitions/Pet"
134 | }
135 | },
136 | "default": {
137 | "description": "unexpected error",
138 | "schema": {
139 | "$ref": "#/definitions/ErrorModel"
140 | }
141 | }
142 | }
143 | },
144 | "delete": {
145 | "description": "deletes a single pet based on the ID supplied",
146 | "operationId": "deletePet",
147 | "parameters": [
148 | {
149 | "name": "id",
150 | "in": "path",
151 | "description": "ID of pet to delete",
152 | "required": true,
153 | "type": "integer",
154 | "format": "int64"
155 | }
156 | ],
157 | "responses": {
158 | "204": {
159 | "description": "pet deleted"
160 | },
161 | "default": {
162 | "description": "unexpected error",
163 | "schema": {
164 | "$ref": "#/definitions/ErrorModel"
165 | }
166 | }
167 | }
168 | }
169 | }
170 | },
171 | "definitions": {
172 | "Pet": {
173 | "type": "object",
174 | "allOf": [
175 | {
176 | "$ref": "#/definitions/NewPet"
177 | },
178 | {
179 | "required": [
180 | "id"
181 | ],
182 | "properties": {
183 | "id": {
184 | "type": "integer",
185 | "format": "int64"
186 | }
187 | }
188 | }
189 | ]
190 | },
191 | "NewPet": {
192 | "type": "object",
193 | "required": [
194 | "name"
195 | ],
196 | "properties": {
197 | "name": {
198 | "type": "string"
199 | },
200 | "tag": {
201 | "type": "string"
202 | }
203 | }
204 | },
205 | "ErrorModel": {
206 | "type": "object",
207 | "required": [
208 | "code",
209 | "message"
210 | ],
211 | "properties": {
212 | "code": {
213 | "type": "integer",
214 | "format": "int32"
215 | },
216 | "message": {
217 | "type": "string"
218 | }
219 | }
220 | }
221 | }
222 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore-with-external-docs.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.0",
5 | "title": "Swagger Petstore",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "email": "apiteam@swagger.io",
11 | "url": "http://swagger.io"
12 | },
13 | "license": {
14 | "name": "MIT",
15 | "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT"
16 | }
17 | },
18 | "externalDocs": {
19 | "description": "find more info here",
20 | "url": "https://swagger.io/about"
21 | },
22 | "host": "petstore.swagger.io",
23 | "basePath": "/api",
24 | "schemes": [
25 | "http"
26 | ],
27 | "consumes": [
28 | "application/json"
29 | ],
30 | "produces": [
31 | "application/json"
32 | ],
33 | "paths": {
34 | "/pets": {
35 | "get": {
36 | "description": "Returns all pets from the system that the user has access to",
37 | "operationId": "findPets",
38 | "externalDocs": {
39 | "description": "find more info here",
40 | "url": "https://swagger.io/about"
41 | },
42 | "produces": [
43 | "application/json",
44 | "application/xml",
45 | "text/xml",
46 | "text/html"
47 | ],
48 | "parameters": [
49 | {
50 | "name": "tags",
51 | "in": "query",
52 | "description": "tags to filter by",
53 | "required": false,
54 | "type": "array",
55 | "items": {
56 | "type": "string"
57 | },
58 | "collectionFormat": "csv"
59 | },
60 | {
61 | "name": "limit",
62 | "in": "query",
63 | "description": "maximum number of results to return",
64 | "required": false,
65 | "type": "integer",
66 | "format": "int32"
67 | }
68 | ],
69 | "responses": {
70 | "200": {
71 | "description": "pet response",
72 | "schema": {
73 | "type": "array",
74 | "items": {
75 | "$ref": "#/definitions/Pet"
76 | }
77 | }
78 | },
79 | "default": {
80 | "description": "unexpected error",
81 | "schema": {
82 | "$ref": "#/definitions/ErrorModel"
83 | }
84 | }
85 | }
86 | },
87 | "post": {
88 | "description": "Creates a new pet in the store. Duplicates are allowed",
89 | "operationId": "addPet",
90 | "produces": [
91 | "application/json"
92 | ],
93 | "parameters": [
94 | {
95 | "name": "pet",
96 | "in": "body",
97 | "description": "Pet to add to the store",
98 | "required": true,
99 | "schema": {
100 | "$ref": "#/definitions/NewPet"
101 | }
102 | }
103 | ],
104 | "responses": {
105 | "200": {
106 | "description": "pet response",
107 | "schema": {
108 | "$ref": "#/definitions/Pet"
109 | }
110 | },
111 | "default": {
112 | "description": "unexpected error",
113 | "schema": {
114 | "$ref": "#/definitions/ErrorModel"
115 | }
116 | }
117 | }
118 | }
119 | },
120 | "/pets/{id}": {
121 | "get": {
122 | "description": "Returns a user based on a single ID, if the user does not have access to the pet",
123 | "operationId": "findPetById",
124 | "produces": [
125 | "application/json",
126 | "application/xml",
127 | "text/xml",
128 | "text/html"
129 | ],
130 | "parameters": [
131 | {
132 | "name": "id",
133 | "in": "path",
134 | "description": "ID of pet to fetch",
135 | "required": true,
136 | "type": "integer",
137 | "format": "int64"
138 | }
139 | ],
140 | "responses": {
141 | "200": {
142 | "description": "pet response",
143 | "schema": {
144 | "$ref": "#/definitions/Pet"
145 | }
146 | },
147 | "default": {
148 | "description": "unexpected error",
149 | "schema": {
150 | "$ref": "#/definitions/ErrorModel"
151 | }
152 | }
153 | }
154 | },
155 | "delete": {
156 | "description": "deletes a single pet based on the ID supplied",
157 | "operationId": "deletePet",
158 | "parameters": [
159 | {
160 | "name": "id",
161 | "in": "path",
162 | "description": "ID of pet to delete",
163 | "required": true,
164 | "type": "integer",
165 | "format": "int64"
166 | }
167 | ],
168 | "responses": {
169 | "204": {
170 | "description": "pet deleted"
171 | },
172 | "default": {
173 | "description": "unexpected error",
174 | "schema": {
175 | "$ref": "#/definitions/ErrorModel"
176 | }
177 | }
178 | }
179 | }
180 | }
181 | },
182 | "definitions": {
183 | "Pet": {
184 | "type": "object",
185 | "allOf": [
186 | {
187 | "$ref": "#/definitions/NewPet"
188 | },
189 | {
190 | "required": [
191 | "id"
192 | ],
193 | "properties": {
194 | "id": {
195 | "type": "integer",
196 | "format": "int64"
197 | }
198 | }
199 | }
200 | ]
201 | },
202 | "NewPet": {
203 | "type": "object",
204 | "required": [
205 | "name"
206 | ],
207 | "properties": {
208 | "name": {
209 | "type": "string"
210 | },
211 | "tag": {
212 | "type": "string"
213 | }
214 | }
215 | },
216 | "ErrorModel": {
217 | "type": "object",
218 | "required": [
219 | "code",
220 | "message"
221 | ],
222 | "properties": {
223 | "code": {
224 | "type": "integer",
225 | "format": "int32"
226 | },
227 | "message": {
228 | "type": "string"
229 | }
230 | }
231 | }
232 | }
233 | }
--------------------------------------------------------------------------------
/examples/v2.0/json/petstore.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.0",
5 | "title": "Swagger Petstore",
6 | "license": {
7 | "name": "MIT"
8 | }
9 | },
10 | "host": "petstore.swagger.io",
11 | "basePath": "/v1",
12 | "schemes": [
13 | "http"
14 | ],
15 | "consumes": [
16 | "application/json"
17 | ],
18 | "produces": [
19 | "application/json"
20 | ],
21 | "paths": {
22 | "/pets": {
23 | "get": {
24 | "summary": "List all pets",
25 | "operationId": "listPets",
26 | "tags": [
27 | "pets"
28 | ],
29 | "parameters": [
30 | {
31 | "name": "limit",
32 | "in": "query",
33 | "description": "How many items to return at one time (max 100)",
34 | "required": false,
35 | "type": "integer",
36 | "format": "int32"
37 | }
38 | ],
39 | "responses": {
40 | "200": {
41 | "description": "An paged array of pets",
42 | "headers": {
43 | "x-next": {
44 | "type": "string",
45 | "description": "A link to the next page of responses"
46 | }
47 | },
48 | "schema": {
49 | "$ref": "#/definitions/Pets"
50 | }
51 | },
52 | "default": {
53 | "description": "unexpected error",
54 | "schema": {
55 | "$ref": "#/definitions/Error"
56 | }
57 | }
58 | }
59 | },
60 | "post": {
61 | "summary": "Create a pet",
62 | "operationId": "createPets",
63 | "tags": [
64 | "pets"
65 | ],
66 | "responses": {
67 | "201": {
68 | "description": "Null response"
69 | },
70 | "default": {
71 | "description": "unexpected error",
72 | "schema": {
73 | "$ref": "#/definitions/Error"
74 | }
75 | }
76 | }
77 | }
78 | },
79 | "/pets/{petId}": {
80 | "get": {
81 | "summary": "Info for a specific pet",
82 | "operationId": "showPetById",
83 | "tags": [
84 | "pets"
85 | ],
86 | "parameters": [
87 | {
88 | "name": "petId",
89 | "in": "path",
90 | "required": true,
91 | "description": "The id of the pet to retrieve",
92 | "type": "string"
93 | }
94 | ],
95 | "responses": {
96 | "200": {
97 | "description": "Expected response to a valid request",
98 | "schema": {
99 | "$ref": "#/definitions/Pets"
100 | }
101 | },
102 | "default": {
103 | "description": "unexpected error",
104 | "schema": {
105 | "$ref": "#/definitions/Error"
106 | }
107 | }
108 | }
109 | }
110 | }
111 | },
112 | "definitions": {
113 | "Pet": {
114 | "required": [
115 | "id",
116 | "name"
117 | ],
118 | "properties": {
119 | "id": {
120 | "type": "integer",
121 | "format": "int64"
122 | },
123 | "name": {
124 | "type": "string"
125 | },
126 | "tag": {
127 | "type": "string"
128 | }
129 | }
130 | },
131 | "Pets": {
132 | "type": "array",
133 | "items": {
134 | "$ref": "#/definitions/Pet"
135 | }
136 | },
137 | "Error": {
138 | "required": [
139 | "code",
140 | "message"
141 | ],
142 | "properties": {
143 | "code": {
144 | "type": "integer",
145 | "format": "int32"
146 | },
147 | "message": {
148 | "type": "string"
149 | }
150 | }
151 | }
152 | }
153 | }
--------------------------------------------------------------------------------
/examples/v2.0/yaml/api-with-examples.yaml:
--------------------------------------------------------------------------------
1 | swagger: "2.0"
2 | info:
3 | title: Simple API overview
4 | version: v2
5 | paths:
6 | /:
7 | get:
8 | operationId: listVersionsv2
9 | summary: List API versions
10 | produces:
11 | - application/json
12 | responses:
13 | "200":
14 | description: |-
15 | 200 300 response
16 | examples:
17 | application/json: |-
18 | {
19 | "versions": [
20 | {
21 | "status": "CURRENT",
22 | "updated": "2011-01-21T11:33:21Z",
23 | "id": "v2.0",
24 | "links": [
25 | {
26 | "href": "http://127.0.0.1:8774/v2/",
27 | "rel": "self"
28 | }
29 | ]
30 | },
31 | {
32 | "status": "EXPERIMENTAL",
33 | "updated": "2013-07-23T11:33:21Z",
34 | "id": "v3.0",
35 | "links": [
36 | {
37 | "href": "http://127.0.0.1:8774/v3/",
38 | "rel": "self"
39 | }
40 | ]
41 | }
42 | ]
43 | }
44 | "300":
45 | description: |-
46 | 200 300 response
47 | examples:
48 | application/json: |-
49 | {
50 | "versions": [
51 | {
52 | "status": "CURRENT",
53 | "updated": "2011-01-21T11:33:21Z",
54 | "id": "v2.0",
55 | "links": [
56 | {
57 | "href": "http://127.0.0.1:8774/v2/",
58 | "rel": "self"
59 | }
60 | ]
61 | },
62 | {
63 | "status": "EXPERIMENTAL",
64 | "updated": "2013-07-23T11:33:21Z",
65 | "id": "v3.0",
66 | "links": [
67 | {
68 | "href": "http://127.0.0.1:8774/v3/",
69 | "rel": "self"
70 | }
71 | ]
72 | }
73 | ]
74 | }
75 | /v2:
76 | get:
77 | operationId: getVersionDetailsv2
78 | summary: Show API version details
79 | produces:
80 | - application/json
81 | responses:
82 | "200":
83 | description: |-
84 | 200 203 response
85 | examples:
86 | application/json: |-
87 | {
88 | "version": {
89 | "status": "CURRENT",
90 | "updated": "2011-01-21T11:33:21Z",
91 | "media-types": [
92 | {
93 | "base": "application/xml",
94 | "type": "application/vnd.openstack.compute+xml;version=2"
95 | },
96 | {
97 | "base": "application/json",
98 | "type": "application/vnd.openstack.compute+json;version=2"
99 | }
100 | ],
101 | "id": "v2.0",
102 | "links": [
103 | {
104 | "href": "http://127.0.0.1:8774/v2/",
105 | "rel": "self"
106 | },
107 | {
108 | "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
109 | "type": "application/pdf",
110 | "rel": "describedby"
111 | },
112 | {
113 | "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
114 | "type": "application/vnd.sun.wadl+xml",
115 | "rel": "describedby"
116 | },
117 | {
118 | "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
119 | "type": "application/vnd.sun.wadl+xml",
120 | "rel": "describedby"
121 | }
122 | ]
123 | }
124 | }
125 | "203":
126 | description: |-
127 | 200 203 response
128 | examples:
129 | application/json: |-
130 | {
131 | "version": {
132 | "status": "CURRENT",
133 | "updated": "2011-01-21T11:33:21Z",
134 | "media-types": [
135 | {
136 | "base": "application/xml",
137 | "type": "application/vnd.openstack.compute+xml;version=2"
138 | },
139 | {
140 | "base": "application/json",
141 | "type": "application/vnd.openstack.compute+json;version=2"
142 | }
143 | ],
144 | "id": "v2.0",
145 | "links": [
146 | {
147 | "href": "http://23.253.228.211:8774/v2/",
148 | "rel": "self"
149 | },
150 | {
151 | "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
152 | "type": "application/pdf",
153 | "rel": "describedby"
154 | },
155 | {
156 | "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
157 | "type": "application/vnd.sun.wadl+xml",
158 | "rel": "describedby"
159 | }
160 | ]
161 | }
162 | }
163 | consumes:
164 | - application/json
165 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-expanded.yaml:
--------------------------------------------------------------------------------
1 | swagger: "2.0"
2 | info:
3 | version: 1.0.0
4 | title: Swagger Petstore
5 | description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
6 | termsOfService: http://swagger.io/terms/
7 | contact:
8 | name: Swagger API Team
9 | email: foo@example.com
10 | url: http://madskristensen.net
11 | license:
12 | name: MIT
13 | url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
14 | host: petstore.swagger.io
15 | basePath: /api
16 | schemes:
17 | - http
18 | consumes:
19 | - application/json
20 | produces:
21 | - application/json
22 | paths:
23 | /pets:
24 | get:
25 | description: |
26 | Returns all pets from the system that the user has access to
27 | operationId: findPets
28 | parameters:
29 | - name: tags
30 | in: query
31 | description: tags to filter by
32 | required: false
33 | type: array
34 | collectionFormat: csv
35 | items:
36 | type: string
37 | - name: limit
38 | in: query
39 | description: maximum number of results to return
40 | required: false
41 | type: integer
42 | format: int32
43 | responses:
44 | "200":
45 | description: pet response
46 | schema:
47 | type: array
48 | items:
49 | $ref: '#/definitions/Pet'
50 | default:
51 | description: unexpected error
52 | schema:
53 | $ref: '#/definitions/Error'
54 | post:
55 | description: Creates a new pet in the store. Duplicates are allowed
56 | operationId: addPet
57 | parameters:
58 | - name: pet
59 | in: body
60 | description: Pet to add to the store
61 | required: true
62 | schema:
63 | $ref: '#/definitions/NewPet'
64 | responses:
65 | "200":
66 | description: pet response
67 | schema:
68 | $ref: '#/definitions/Pet'
69 | default:
70 | description: unexpected error
71 | schema:
72 | $ref: '#/definitions/Error'
73 | /pets/{id}:
74 | get:
75 | description: Returns a user based on a single ID, if the user does not have access to the pet
76 | operationId: find pet by id
77 | parameters:
78 | - name: id
79 | in: path
80 | description: ID of pet to fetch
81 | required: true
82 | type: integer
83 | format: int64
84 | responses:
85 | "200":
86 | description: pet response
87 | schema:
88 | $ref: '#/definitions/Pet'
89 | default:
90 | description: unexpected error
91 | schema:
92 | $ref: '#/definitions/Error'
93 | delete:
94 | description: deletes a single pet based on the ID supplied
95 | operationId: deletePet
96 | parameters:
97 | - name: id
98 | in: path
99 | description: ID of pet to delete
100 | required: true
101 | type: integer
102 | format: int64
103 | responses:
104 | "204":
105 | description: pet deleted
106 | default:
107 | description: unexpected error
108 | schema:
109 | $ref: '#/definitions/Error'
110 | definitions:
111 | Pet:
112 | allOf:
113 | - $ref: '#/definitions/NewPet'
114 | - required:
115 | - id
116 | properties:
117 | id:
118 | type: integer
119 | format: int64
120 |
121 | NewPet:
122 | required:
123 | - name
124 | properties:
125 | name:
126 | type: string
127 | tag:
128 | type: string
129 |
130 | Error:
131 | required:
132 | - code
133 | - message
134 | properties:
135 | code:
136 | type: integer
137 | format: int32
138 | message:
139 | type: string
140 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-minimal.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | swagger: "2.0"
3 | info:
4 | version: "1.0.0"
5 | title: "Swagger Petstore"
6 | description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"
7 | termsOfService: "http://swagger.io/terms/"
8 | contact:
9 | name: "Swagger API Team"
10 | license:
11 | name: "MIT"
12 | host: "petstore.swagger.io"
13 | basePath: "/api"
14 | schemes:
15 | - "http"
16 | consumes:
17 | - "application/json"
18 | produces:
19 | - "application/json"
20 | paths:
21 | /pets:
22 | get:
23 | description: "Returns all pets from the system that the user has access to"
24 | produces:
25 | - "application/json"
26 | responses:
27 | "200":
28 | description: "A list of pets."
29 | schema:
30 | type: "array"
31 | items:
32 | $ref: "#/definitions/Pet"
33 | definitions:
34 | Pet:
35 | type: "object"
36 | required:
37 | - "id"
38 | - "name"
39 | properties:
40 | id:
41 | type: "integer"
42 | format: "int64"
43 | name:
44 | type: "string"
45 | tag:
46 | type: "string"
47 |
48 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-separate/common/Error.yaml:
--------------------------------------------------------------------------------
1 | type: object
2 | required:
3 | - code
4 | - message
5 | properties:
6 | code:
7 | type: integer
8 | format: int32
9 | message:
10 | type: string
11 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-separate/spec/NewPet.yaml:
--------------------------------------------------------------------------------
1 | type: object
2 | allOf:
3 | - $ref: 'Pet.yaml'
4 | - required:
5 | - name
6 | properties:
7 | description:
8 | type: integer
9 | format: int64
10 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-separate/spec/Pet.yaml:
--------------------------------------------------------------------------------
1 | type: object
2 | required:
3 | - id
4 | - name
5 | properties:
6 | id:
7 | type: integer
8 | format: int64
9 | name:
10 | type: string
11 | tag:
12 | type: string
13 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-separate/spec/parameters.yaml:
--------------------------------------------------------------------------------
1 | tagsParam:
2 | name: tags
3 | in: query
4 | description: tags to filter by
5 | required: false
6 | type: array
7 | collectionFormat: csv
8 | items:
9 | type: string
10 | limitsParam:
11 | name: limit
12 | in: query
13 | description: maximum number of results to return
14 | required: false
15 | type: integer
16 | format: int32
17 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-separate/spec/swagger.yaml:
--------------------------------------------------------------------------------
1 | swagger: "2.0"
2 | info:
3 | version: 1.0.0
4 | title: Swagger Petstore
5 | description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
6 | termsOfService: http://helloreverb.com/terms/
7 | contact:
8 | name: Wordnik API Team
9 | email: foo@example.com
10 | url: http://madskristensen.net
11 | license:
12 | name: MIT
13 | url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
14 | host: petstore.swagger.wordnik.com
15 | basePath: /api
16 | schemes:
17 | - http
18 | consumes:
19 | - application/json
20 | produces:
21 | - application/json
22 | paths:
23 | /pets:
24 | get:
25 | description: |
26 | Returns all pets from the system that the user has access to
27 | 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.
28 |
29 | 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.
30 | operationId: findPets
31 | parameters:
32 | - $ref: 'parameters.yaml#/tagsParam'
33 | - $ref: 'parameters.yaml#/limitsParam'
34 | responses:
35 | "200":
36 | description: pet response
37 | schema:
38 | type: array
39 | items:
40 | $ref: 'Pet.yaml'
41 | default:
42 | description: unexpected error
43 | schema:
44 | $ref: '../common/Error.yaml'
45 | post:
46 | description: Creates a new pet in the store. Duplicates are allowed
47 | operationId: addPet
48 | parameters:
49 | - name: pet
50 | in: body
51 | description: Pet to add to the store
52 | required: true
53 | schema:
54 | $ref: 'NewPet.yaml'
55 | responses:
56 | "200":
57 | description: pet response
58 | schema:
59 | $ref: 'Pet.yaml'
60 | default:
61 | description: unexpected error
62 | schema:
63 | $ref: '../common/Error.yaml'
64 | /pets/{id}:
65 | get:
66 | description: Returns a user based on a single ID, if the user does not have access to the pet
67 | operationId: find pet by id
68 | parameters:
69 | - name: id
70 | in: path
71 | description: ID of pet to fetch
72 | required: true
73 | type: integer
74 | format: int64
75 | responses:
76 | "200":
77 | description: pet response
78 | schema:
79 | $ref: 'Pet.yaml'
80 | default:
81 | description: unexpected error
82 | schema:
83 | $ref: '../common/Error.yaml'
84 | delete:
85 | description: deletes a single pet based on the ID supplied
86 | operationId: deletePet
87 | parameters:
88 | - name: id
89 | in: path
90 | description: ID of pet to delete
91 | required: true
92 | type: integer
93 | format: int64
94 | responses:
95 | "204":
96 | description: pet deleted
97 | default:
98 | description: unexpected error
99 | schema:
100 | $ref: '../common/Error.yaml'
101 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-simple.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | swagger: "2.0"
3 | info:
4 | version: "1.0.0"
5 | title: "Swagger Petstore"
6 | description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"
7 | termsOfService: "http://swagger.io/terms/"
8 | contact:
9 | name: "Swagger API Team"
10 | license:
11 | name: "MIT"
12 | host: "petstore.swagger.io"
13 | basePath: "/api"
14 | schemes:
15 | - "http"
16 | consumes:
17 | - "application/json"
18 | produces:
19 | - "application/json"
20 | paths:
21 | /pets:
22 | get:
23 | description: "Returns all pets from the system that the user has access to"
24 | operationId: "findPets"
25 | produces:
26 | - "application/json"
27 | - "application/xml"
28 | - "text/xml"
29 | - "text/html"
30 | parameters:
31 | -
32 | name: "tags"
33 | in: "query"
34 | description: "tags to filter by"
35 | required: false
36 | type: "array"
37 | items:
38 | type: "string"
39 | collectionFormat: "csv"
40 | -
41 | name: "limit"
42 | in: "query"
43 | description: "maximum number of results to return"
44 | required: false
45 | type: "integer"
46 | format: "int32"
47 | responses:
48 | "200":
49 | description: "pet response"
50 | schema:
51 | type: "array"
52 | items:
53 | $ref: "#/definitions/Pet"
54 | default:
55 | description: "unexpected error"
56 | schema:
57 | $ref: "#/definitions/ErrorModel"
58 | post:
59 | description: "Creates a new pet in the store. Duplicates are allowed"
60 | operationId: "addPet"
61 | produces:
62 | - "application/json"
63 | parameters:
64 | -
65 | name: "pet"
66 | in: "body"
67 | description: "Pet to add to the store"
68 | required: true
69 | schema:
70 | $ref: "#/definitions/NewPet"
71 | responses:
72 | "200":
73 | description: "pet response"
74 | schema:
75 | $ref: "#/definitions/Pet"
76 | default:
77 | description: "unexpected error"
78 | schema:
79 | $ref: "#/definitions/ErrorModel"
80 | /pets/{id}:
81 | get:
82 | description: "Returns a user based on a single ID, if the user does not have access to the pet"
83 | operationId: "findPetById"
84 | produces:
85 | - "application/json"
86 | - "application/xml"
87 | - "text/xml"
88 | - "text/html"
89 | parameters:
90 | -
91 | name: "id"
92 | in: "path"
93 | description: "ID of pet to fetch"
94 | required: true
95 | type: "integer"
96 | format: "int64"
97 | responses:
98 | "200":
99 | description: "pet response"
100 | schema:
101 | $ref: "#/definitions/Pet"
102 | default:
103 | description: "unexpected error"
104 | schema:
105 | $ref: "#/definitions/ErrorModel"
106 | delete:
107 | description: "deletes a single pet based on the ID supplied"
108 | operationId: "deletePet"
109 | parameters:
110 | -
111 | name: "id"
112 | in: "path"
113 | description: "ID of pet to delete"
114 | required: true
115 | type: "integer"
116 | format: "int64"
117 | responses:
118 | "204":
119 | description: "pet deleted"
120 | default:
121 | description: "unexpected error"
122 | schema:
123 | $ref: "#/definitions/ErrorModel"
124 | definitions:
125 | Pet:
126 | type: "object"
127 | allOf:
128 | -
129 | $ref: "#/definitions/NewPet"
130 | -
131 | required:
132 | - "id"
133 | properties:
134 | id:
135 | type: "integer"
136 | format: "int64"
137 | NewPet:
138 | type: "object"
139 | required:
140 | - "name"
141 | properties:
142 | name:
143 | type: "string"
144 | tag:
145 | type: "string"
146 | ErrorModel:
147 | type: "object"
148 | required:
149 | - "code"
150 | - "message"
151 | properties:
152 | code:
153 | type: "integer"
154 | format: "int32"
155 | message:
156 | type: "string"
157 |
158 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore-with-external-docs.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | swagger: "2.0"
3 | info:
4 | version: "1.0.0"
5 | title: "Swagger Petstore"
6 | description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"
7 | termsOfService: "http://swagger.io/terms/"
8 | contact:
9 | name: "Swagger API Team"
10 | email: "apiteam@swagger.io"
11 | url: "http://swagger.io"
12 | license:
13 | name: "MIT"
14 | url: "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT"
15 | externalDocs:
16 | description: "find more info here"
17 | url: "https://swagger.io/about"
18 | host: "petstore.swagger.io"
19 | basePath: "/api"
20 | schemes:
21 | - "http"
22 | consumes:
23 | - "application/json"
24 | produces:
25 | - "application/json"
26 | paths:
27 | /pets:
28 | get:
29 | description: "Returns all pets from the system that the user has access to"
30 | operationId: "findPets"
31 | externalDocs:
32 | description: "find more info here"
33 | url: "https://swagger.io/about"
34 | produces:
35 | - "application/json"
36 | - "application/xml"
37 | - "text/xml"
38 | - "text/html"
39 | parameters:
40 | -
41 | name: "tags"
42 | in: "query"
43 | description: "tags to filter by"
44 | required: false
45 | type: "array"
46 | items:
47 | type: "string"
48 | collectionFormat: "csv"
49 | -
50 | name: "limit"
51 | in: "query"
52 | description: "maximum number of results to return"
53 | required: false
54 | type: "integer"
55 | format: "int32"
56 | responses:
57 | "200":
58 | description: "pet response"
59 | schema:
60 | type: "array"
61 | items:
62 | $ref: "#/definitions/Pet"
63 | default:
64 | description: "unexpected error"
65 | schema:
66 | $ref: "#/definitions/ErrorModel"
67 | post:
68 | description: "Creates a new pet in the store. Duplicates are allowed"
69 | operationId: "addPet"
70 | produces:
71 | - "application/json"
72 | parameters:
73 | -
74 | name: "pet"
75 | in: "body"
76 | description: "Pet to add to the store"
77 | required: true
78 | schema:
79 | $ref: "#/definitions/NewPet"
80 | responses:
81 | "200":
82 | description: "pet response"
83 | schema:
84 | $ref: "#/definitions/Pet"
85 | default:
86 | description: "unexpected error"
87 | schema:
88 | $ref: "#/definitions/ErrorModel"
89 | /pets/{id}:
90 | get:
91 | description: "Returns a user based on a single ID, if the user does not have access to the pet"
92 | operationId: "findPetById"
93 | produces:
94 | - "application/json"
95 | - "application/xml"
96 | - "text/xml"
97 | - "text/html"
98 | parameters:
99 | -
100 | name: "id"
101 | in: "path"
102 | description: "ID of pet to fetch"
103 | required: true
104 | type: "integer"
105 | format: "int64"
106 | responses:
107 | "200":
108 | description: "pet response"
109 | schema:
110 | $ref: "#/definitions/Pet"
111 | default:
112 | description: "unexpected error"
113 | schema:
114 | $ref: "#/definitions/ErrorModel"
115 | delete:
116 | description: "deletes a single pet based on the ID supplied"
117 | operationId: "deletePet"
118 | parameters:
119 | -
120 | name: "id"
121 | in: "path"
122 | description: "ID of pet to delete"
123 | required: true
124 | type: "integer"
125 | format: "int64"
126 | responses:
127 | "204":
128 | description: "pet deleted"
129 | default:
130 | description: "unexpected error"
131 | schema:
132 | $ref: "#/definitions/ErrorModel"
133 | definitions:
134 | Pet:
135 | type: "object"
136 | allOf:
137 | -
138 | $ref: "#/definitions/NewPet"
139 | -
140 | required:
141 | - "id"
142 | properties:
143 | id:
144 | type: "integer"
145 | format: "int64"
146 | NewPet:
147 | type: "object"
148 | required:
149 | - "name"
150 | properties:
151 | name:
152 | type: "string"
153 | tag:
154 | type: "string"
155 | ErrorModel:
156 | type: "object"
157 | required:
158 | - "code"
159 | - "message"
160 | properties:
161 | code:
162 | type: "integer"
163 | format: "int32"
164 | message:
165 | type: "string"
166 |
167 |
--------------------------------------------------------------------------------
/examples/v2.0/yaml/petstore.yaml:
--------------------------------------------------------------------------------
1 | swagger: "2.0"
2 | info:
3 | version: 1.0.0
4 | title: Swagger Petstore
5 | license:
6 | name: MIT
7 | host: petstore.swagger.io
8 | basePath: /v1
9 | schemes:
10 | - http
11 | consumes:
12 | - application/json
13 | produces:
14 | - application/json
15 | paths:
16 | /pets:
17 | get:
18 | summary: List all pets
19 | operationId: listPets
20 | tags:
21 | - pets
22 | parameters:
23 | - name: limit
24 | in: query
25 | description: How many items to return at one time (max 100)
26 | required: false
27 | type: integer
28 | format: int32
29 | responses:
30 | "200":
31 | description: An paged array of pets
32 | headers:
33 | x-next:
34 | type: string
35 | description: A link to the next page of responses
36 | schema:
37 | $ref: '#/definitions/Pets'
38 | default:
39 | description: unexpected error
40 | schema:
41 | $ref: '#/definitions/Error'
42 | post:
43 | summary: Create a pet
44 | operationId: createPets
45 | tags:
46 | - pets
47 | responses:
48 | "201":
49 | description: Null response
50 | default:
51 | description: unexpected error
52 | schema:
53 | $ref: '#/definitions/Error'
54 | /pets/{petId}:
55 | get:
56 | summary: Info for a specific pet
57 | operationId: showPetById
58 | tags:
59 | - pets
60 | parameters:
61 | - name: petId
62 | in: path
63 | required: true
64 | description: The id of the pet to retrieve
65 | type: string
66 | responses:
67 | "200":
68 | description: Expected response to a valid request
69 | schema:
70 | $ref: '#/definitions/Pets'
71 | default:
72 | description: unexpected error
73 | schema:
74 | $ref: '#/definitions/Error'
75 | definitions:
76 | Pet:
77 | required:
78 | - id
79 | - name
80 | properties:
81 | id:
82 | type: integer
83 | format: int64
84 | name:
85 | type: string
86 | tag:
87 | type: string
88 | Pets:
89 | type: array
90 | items:
91 | $ref: '#/definitions/Pet'
92 | Error:
93 | required:
94 | - code
95 | - message
96 | properties:
97 | code:
98 | type: integer
99 | format: int32
100 | message:
101 | type: string
102 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/README.md:
--------------------------------------------------------------------------------
1 | # All-in-one Static Hello World Sample
2 |
3 | This sample project provides an all-one-one package demo for the Hello World sample described in the [wiki](https://github.com/swagger-api/swagger-spec/wiki/Hello-World-Sample).
4 |
5 | ## Requirements
6 |
7 | This samples requires Java 5 or above and [Maven](http://maven.apache.org) installed.
8 |
9 | ## Run the sample
10 |
11 | In your favorite command-line, run:
12 |
13 | ```
14 | mvn jetty:run
15 | ```
16 |
17 | Then in your favorite web browser, open:
18 | ```
19 | http://localhost:8000
20 | ```
21 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | io.swagger
5 | swagger-demo
6 | jar
7 | swagger-demo
8 | 1.0.1-SNAPSHOT
9 |
10 | 2.2.0
11 |
12 |
13 |
14 | src/main/scala
15 | src/test/scala
16 |
17 |
18 | net.alchim31.maven
19 | scala-maven-plugin
20 | ${maven-plugin.version}
21 |
22 |
23 |
24 | compile
25 | testCompile
26 |
27 |
28 |
29 |
30 |
31 | -Xms64m
32 | -Xmx1024m
33 |
34 |
35 |
36 |
37 | maven-surefire-plugin
38 |
39 | once
40 | false
41 |
42 |
43 |
44 | maven-dependency-plugin
45 |
46 |
47 | package
48 |
49 | copy-dependencies
50 |
51 |
52 | ${project.build.directory}/lib
53 |
54 |
55 |
56 |
57 |
58 | org.mortbay.jetty
59 | jetty-maven-plugin
60 | ${jetty-version}
61 |
62 |
63 | /
64 |
65 |
66 |
67 | 8000
68 | 60000
69 | 8443
70 |
71 |
72 |
73 |
74 |
75 | start-jetty
76 | pre-integration-test
77 |
78 | run
79 |
80 |
81 | 0
82 | true
83 |
84 |
85 |
86 | stop-jetty
87 | post-integration-test
88 |
89 | stop
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | sonatype-snapshots
99 | https://oss.sonatype.org/content/repositories/snapshots
100 |
101 |
102 | sonatype-releases
103 | https://oss.sonatype.org/content/repositories/releases
104 |
105 |
106 |
107 | 3.1.0
108 | 7.6.0.v20120127
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/api-docs:
--------------------------------------------------------------------------------
1 | {
2 | "swaggerVersion": "1.2",
3 | "apis": [
4 | {
5 | "path": "http://localhost:8000/listings/greetings",
6 | "description": "Generating greetings in our application."
7 | }
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/css/highlight.default.css:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Original style from softwaremaniacs.org (c) Ivan Sagalaev
4 |
5 | */
6 |
7 | pre code {
8 | display: block; padding: 0.5em;
9 | background: #F0F0F0;
10 | }
11 |
12 | pre code,
13 | pre .subst,
14 | pre .tag .title,
15 | pre .lisp .title,
16 | pre .clojure .built_in,
17 | pre .nginx .title {
18 | color: black;
19 | }
20 |
21 | pre .string,
22 | pre .title,
23 | pre .constant,
24 | pre .parent,
25 | pre .tag .value,
26 | pre .rules .value,
27 | pre .rules .value .number,
28 | pre .preprocessor,
29 | pre .ruby .symbol,
30 | pre .ruby .symbol .string,
31 | pre .aggregate,
32 | pre .template_tag,
33 | pre .django .variable,
34 | pre .smalltalk .class,
35 | pre .addition,
36 | pre .flow,
37 | pre .stream,
38 | pre .bash .variable,
39 | pre .apache .tag,
40 | pre .apache .cbracket,
41 | pre .tex .command,
42 | pre .tex .special,
43 | pre .erlang_repl .function_or_atom,
44 | pre .markdown .header {
45 | color: #800;
46 | }
47 |
48 | pre .comment,
49 | pre .annotation,
50 | pre .template_comment,
51 | pre .diff .header,
52 | pre .chunk,
53 | pre .markdown .blockquote {
54 | color: #888;
55 | }
56 |
57 | pre .number,
58 | pre .date,
59 | pre .regexp,
60 | pre .literal,
61 | pre .smalltalk .symbol,
62 | pre .smalltalk .char,
63 | pre .go .constant,
64 | pre .change,
65 | pre .markdown .bullet,
66 | pre .markdown .link_url {
67 | color: #080;
68 | }
69 |
70 | pre .label,
71 | pre .javadoc,
72 | pre .ruby .string,
73 | pre .decorator,
74 | pre .filter .argument,
75 | pre .localvars,
76 | pre .array,
77 | pre .attr_selector,
78 | pre .important,
79 | pre .pseudo,
80 | pre .pi,
81 | pre .doctype,
82 | pre .deletion,
83 | pre .envvar,
84 | pre .shebang,
85 | pre .apache .sqbracket,
86 | pre .nginx .built_in,
87 | pre .tex .formula,
88 | pre .erlang_repl .reserved,
89 | pre .prompt,
90 | pre .markdown .link_label,
91 | pre .vhdl .attribute,
92 | pre .clojure .attribute,
93 | pre .coffeescript .property {
94 | color: #88F
95 | }
96 |
97 | pre .keyword,
98 | pre .id,
99 | pre .phpdoc,
100 | pre .title,
101 | pre .built_in,
102 | pre .aggregate,
103 | pre .css .tag,
104 | pre .javadoctag,
105 | pre .phpdoc,
106 | pre .yardoctag,
107 | pre .smalltalk .class,
108 | pre .winutils,
109 | pre .bash .variable,
110 | pre .apache .tag,
111 | pre .go .typename,
112 | pre .tex .command,
113 | pre .markdown .strong,
114 | pre .request,
115 | pre .status {
116 | font-weight: bold;
117 | }
118 |
119 | pre .markdown .emphasis {
120 | font-style: italic;
121 | }
122 |
123 | pre .nginx .built_in {
124 | font-weight: normal;
125 | }
126 |
127 | pre .coffeescript .javascript,
128 | pre .javascript .xml,
129 | pre .tex .formula,
130 | pre .xml .javascript,
131 | pre .xml .vbscript,
132 | pre .xml .css,
133 | pre .xml .cdata {
134 | opacity: 0.5;
135 | }
136 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/images/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/od2016/OpenAPI-Specification/d3b582593a1f6092c8666ad7c893ae5e12779ec7/fixtures/v1.2/helloworld/server/src/main/webapp/images/logo_small.png
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/images/pet_store_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/od2016/OpenAPI-Specification/d3b582593a1f6092c8666ad7c893ae5e12779ec7/fixtures/v1.2/helloworld/server/src/main/webapp/images/pet_store_api.png
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/images/throbber.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/od2016/OpenAPI-Specification/d3b582593a1f6092c8666ad7c893ae5e12779ec7/fixtures/v1.2/helloworld/server/src/main/webapp/images/throbber.gif
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/images/wordnik_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/od2016/OpenAPI-Specification/d3b582593a1f6092c8666ad7c893ae5e12779ec7/fixtures/v1.2/helloworld/server/src/main/webapp/images/wordnik_api.png
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Swagger UI
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
47 |
48 |
49 |
50 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/lib/jquery.ba-bbq.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
3 | * http://benalman.com/projects/jquery-bbq-plugin/
4 | *
5 | * Copyright (c) 2010 "Cowboy" Ben Alman
6 | * Dual licensed under the MIT and GPL licenses.
7 | * http://benalman.com/about/license/
8 | */
9 | (function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/lib/jquery.slideto.min.js:
--------------------------------------------------------------------------------
1 | (function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
2 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/lib/jquery.wiggle.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | jQuery Wiggle
3 | Author: WonderGroup, Jordan Thomas
4 | URL: http://labs.wondergroup.com/demos/mini-ui/index.html
5 | License: MIT (http://en.wikipedia.org/wiki/MIT_License)
6 | */
7 | jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
8 | if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/server/src/main/webapp/listings/greetings:
--------------------------------------------------------------------------------
1 | {
2 | "swaggerVersion": "1.2",
3 | "basePath": "http://localhost:8000/greetings",
4 | "apis": [
5 | {
6 | "path": "/hello/{subject}",
7 | "operations": [
8 | {
9 | "method": "GET",
10 | "summary": "Greet our subject with hello!",
11 | "type": "string",
12 | "nickname": "helloSubject",
13 | "parameters": [
14 | {
15 | "name": "subject",
16 | "description": "The subject to be greeted.",
17 | "required": true,
18 | "type": "string",
19 | "paramType": "path"
20 | }
21 | ]
22 | }
23 | ]
24 | }
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/static/README.md:
--------------------------------------------------------------------------------
1 | # Static Hello World Sample Files
2 |
3 | This sample project provides the static files to be hosted in your web server, following the Hello World sample described in the [wiki](https://github.com/swagger-api/swagger-spec/wiki/Hello-World-Sample).
4 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/static/api-docs:
--------------------------------------------------------------------------------
1 | {
2 | "swaggerVersion": "1.2",
3 | "apis": [
4 | {
5 | "path": "http://localhost:8000/listings/greetings",
6 | "description": "Generating greetings in our application."
7 | }
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/fixtures/v1.2/helloworld/static/listings/greetings:
--------------------------------------------------------------------------------
1 | {
2 | "swaggerVersion": "1.2",
3 | "basePath": "http://localhost:8000/greetings",
4 | "apis": [
5 | {
6 | "path": "/hello/{subject}",
7 | "operations": [
8 | {
9 | "method": "GET",
10 | "summary": "Greet our subject with hello!",
11 | "type": "string",
12 | "nickname": "helloSubject",
13 | "parameters": [
14 | {
15 | "name": "subject",
16 | "description": "The subject to be greeted.",
17 | "required": true,
18 | "type": "string",
19 | "paramType": "path"
20 | }
21 | ]
22 | }
23 | ]
24 | }
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/general/basicInfoObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Swagger Sample App",
3 | "description": "This is a sample server Petstore server.",
4 | "termsOfService": "http://swagger.io/terms/",
5 | "contact": {
6 | "name": "API Support",
7 | "url": "http://www.swagger.io/support",
8 | "email": "support@swagger.io"
9 | },
10 | "license": {
11 | "name": "Apache 2.0",
12 | "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
13 | },
14 | "version": "1.0.1"
15 | }
16 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/general/externalDocs.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Find more info here",
3 | "url": "https://swagger.io"
4 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/general/minimalInfoObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Swagger Sample App",
3 | "version": "1.0.1"
4 | }
5 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/general/negative/negativeExternalDocs.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Find more info here"
3 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/general/negative/negativeInfoObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "This is a sample server Petstore server.",
3 | "termsOfService": "http://swagger.io/terms/",
4 | "contact": {
5 | "name": "API Support",
6 | "url": "http://www.swagger.io/support",
7 | "email": "support@swagger.io"
8 | },
9 | "license": {
10 | "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithArrayRef.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": [
3 | "id"
4 | ],
5 | "properties": {
6 | "id": {
7 | "type": "integer",
8 | "format": "int64"
9 | },
10 | "children": {
11 | "type": "array",
12 | "items": {
13 | "$ref": "#/definitions/Person"
14 | }
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithComposition.json:
--------------------------------------------------------------------------------
1 | {
2 | "Pet": {
3 | "discriminator": "petType",
4 | "properties": {
5 | "name": {
6 | "type": "string"
7 | },
8 | "petType": {
9 | "type": "string"
10 | }
11 | },
12 | "required": [
13 | "name",
14 | "petType"
15 | ]
16 | },
17 | "Cat": {
18 | "description": "A representation of a cat",
19 | "allOf": [
20 | {
21 | "$ref": "#/definitions/Pet"
22 | },
23 | {
24 | "properties": {
25 | "huntingSkill": {
26 | "type": "string",
27 | "description": "The measured skill for hunting",
28 | "default": "lazy",
29 | "enum": [
30 | "clueless",
31 | "lazy",
32 | "adventurous",
33 | "aggressive"
34 | ]
35 | }
36 | },
37 | "required": [
38 | "huntingSkill"
39 | ]
40 | }
41 | ]
42 | },
43 | "Dog": {
44 | "description": "A representation of a dog",
45 | "allOf": [
46 | {
47 | "$ref": "#/definitions/Pet"
48 | },
49 | {
50 | "properties": {
51 | "packSize": {
52 | "type": "integer",
53 | "format": "int32",
54 | "description": "the size of the pack the dog is from",
55 | "default": 0,
56 | "minimum": 0
57 | }
58 | },
59 | "required": [
60 | "packSize"
61 | ]
62 | }
63 | ]
64 | },
65 | "Fish": {
66 | "description": "A representation of a fish",
67 | "allOf": [
68 | {
69 | "$ref": "#/definitions/Pet"
70 | },
71 | {
72 | "properties": {
73 | "fins": {
74 | "type": "integer",
75 | "format": "int32",
76 | "description": "count of fins",
77 | "minimum": 0
78 | }
79 | },
80 | "required": [
81 | "fins"
82 | ]
83 | }
84 | ]
85 | }
86 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithDateTimeMap.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "true",
3 | "additionalProperties": {
4 | "type": "string",
5 | "format": "date-time"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithExamples.json:
--------------------------------------------------------------------------------
1 | {
2 | "Pet": {
3 | "properties": {
4 | "name": {
5 | "type": "string"
6 | }
7 | },
8 | "required": [
9 | "name"
10 | ]
11 | },
12 | "Dog": {
13 | "properties": {
14 | "id": {
15 | "type": "integer",
16 | "format": "int64"
17 | },
18 | "name": {
19 | "type": "string"
20 | }
21 | },
22 | "required": [
23 | "name"
24 | ],
25 | "example": {
26 | "name": "Puma",
27 | "id": 1
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithInt32Map.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "This is a Map[String, Integer]",
3 | "additionalProperties": {
4 | "type": "integer",
5 | "format": "int32"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithInt64Map.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "true",
3 | "additionalProperties": {
4 | "type": "integer",
5 | "format": "int64"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithMultipleProperties.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "true",
3 | "properties": {
4 | "booleanValue": {
5 | "type": "boolean"
6 | },
7 | "byteValue": {
8 | "type": "string",
9 | "format": "byte"
10 | },
11 | "dateTimeValue": {
12 | "type": "string",
13 | "format": "date-time"
14 | },
15 | "int32Value": {
16 | "type": "integer",
17 | "format": "int32"
18 | },
19 | "int64Value": {
20 | "type": "integer",
21 | "format": "int64"
22 | },
23 | "stringValue": {
24 | "type": "string"
25 | },
26 | "booleanArrayValue": {
27 | "type": "array",
28 | "items": {
29 | "type": "boolean"
30 | }
31 | },
32 | "byteArrayValue": {
33 | "type": "array",
34 | "items": {
35 | "type": "string",
36 | "format": "byte"
37 | }
38 | },
39 | "dateTimeArrayValue": {
40 | "type": "array",
41 | "items": {
42 | "type": "string",
43 | "format": "date-time"
44 | }
45 | },
46 | "int32ArrayValue": {
47 | "type": "array",
48 | "items": {
49 | "type": "integer",
50 | "format": "int32"
51 | }
52 | },
53 | "int64ArrayValue": {
54 | "type": "array",
55 | "items": {
56 | "type": "integer",
57 | "format": "int64"
58 | }
59 | },
60 | "stringArrayValue": {
61 | "type": "array",
62 | "items": {
63 | "type": "string"
64 | }
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithPrimitiveArray.json:
--------------------------------------------------------------------------------
1 | {
2 | "required": [
3 | "id"
4 | ],
5 | "properties": {
6 | "id": {
7 | "type": "integer",
8 | "format": "int64"
9 | },
10 | "childrensAges": {
11 | "type": "array",
12 | "items": {
13 | "type": "integer",
14 | "format": "int32"
15 | }
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithStringProperty.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "true",
3 | "properties": {
4 | "name": {
5 | "type": "string"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/modelWithXmlAttributes.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "this model serves xml and json structures",
3 | "xml": {
4 | "name": "XMLModel"
5 | },
6 | "properties": {
7 | "id": {
8 | "type": "integer",
9 | "format": "int64",
10 | "xml": {
11 | "attribute": true,
12 | "namespace": "ns1",
13 | "prefix": "urn1"
14 | }
15 | },
16 | "items": {
17 | "type": "array",
18 | "items": {
19 | "type": "string"
20 | },
21 | "xml": {
22 | "wrapped": true
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/models.json:
--------------------------------------------------------------------------------
1 | {
2 | "Pet": {
3 | "properties": {
4 | "name": {
5 | "type": "string"
6 | }
7 | },
8 | "required": [
9 | "name"
10 | ]
11 | }
12 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/multipleModels.json:
--------------------------------------------------------------------------------
1 | {
2 | "Pet": {
3 | "properties": {
4 | "name": {
5 | "type": "string"
6 | }
7 | },
8 | "required": [
9 | "name"
10 | ]
11 | },
12 | "Dog": {
13 | "properties": {
14 | "id": {
15 | "type": "integer",
16 | "format": "int64"
17 | },
18 | "name": {
19 | "type": "string"
20 | }
21 | },
22 | "required": [
23 | "name"
24 | ]
25 | }
26 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/propertyWithBooleanArray.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "array",
3 | "items": {
4 | "type": "boolean"
5 | }
6 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/propertyWithByteArray.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "array",
3 | "items": {
4 | "type": "string",
5 | "format": "byte"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/propertyWithComplexArray.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "array",
3 | "items": {
4 | "$ref": "#/definitions/ComplexType"
5 | }
6 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/propertyWithDateTimeArray.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "array",
3 | "items": {
4 | "type": "string",
5 | "format": "date-time"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/propertyWithInt32Array.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "array",
3 | "items": {
4 | "type": "integer",
5 | "format": "int32"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/propertyWithInt64Array.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "array",
3 | "items": {
4 | "type": "integer",
5 | "format": "int64"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/propertyWithStringArray.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "array",
3 | "items": {
4 | "type": "string"
5 | }
6 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/simpleBooleanProperty.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "boolean",
3 | "description": "a boolean",
4 | "readOnly": true
5 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/simpleByteProperty.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "string",
3 | "format": "byte"
4 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/simpleDateTimeProperty.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "string",
3 | "format": "date-time"
4 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/simpleInt32Property.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "integer",
3 | "format": "int32"
4 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/simpleInt64Property.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "integer",
3 | "format": "int64"
4 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/models/properties/simpleStringProperty.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "string"
3 | }
4 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/cascadingSchemes.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.9-abcd",
5 | "title": "Swagger Sample API",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "url": "http://swagger.io"
11 | },
12 | "license": {
13 | "name": "Creative Commons 4.0 International",
14 | "url": "http://creativecommons.org/licenses/by/4.0/"
15 | }
16 | },
17 | "host": "my.api.com",
18 | "basePath": "/v1",
19 | "schemes": [
20 | "http",
21 | "https"
22 | ],
23 | "consumes": [
24 | "application/json"
25 | ],
26 | "produces": [
27 | "application/json",
28 | "application/xml"
29 | ],
30 | "paths": {
31 | "/pets/{petId}": {
32 | "get": {
33 | "description": "Returns a pet based on ID",
34 | "summary": "Find pet by ID",
35 | "operationId": "getPetsById",
36 | "produces": [
37 | "application/json",
38 | "text/html"
39 | ],
40 | "parameters": [
41 | {
42 | "name": "petId",
43 | "in": "path",
44 | "description": "ID of pet that needs to be fetched",
45 | "required": true,
46 | "type": "array",
47 | "items": {
48 | "type": "string"
49 | },
50 | "collectionFormat": "csv"
51 | }
52 | ],
53 | "responses": {
54 | "200": {
55 | "description": "pet response",
56 | "schema": {
57 | "$ref": "#/definitions/Pet"
58 | }
59 | },
60 | "default": {
61 | "description": "error payload",
62 | "schema": {
63 | "$ref": "#/definitions/ErrorModel"
64 | }
65 | }
66 | },
67 | "schemes": [ "https" ]
68 | }
69 | }
70 | },
71 | "definitions": {
72 | "Pet": {
73 | "required": [
74 | "name"
75 | ],
76 | "properties": {
77 | "name": {
78 | "type": "string"
79 | },
80 | "tag": {
81 | "type": "string"
82 | }
83 | }
84 | },
85 | "ErrorModel": {
86 | "required": [ "code", "message" ],
87 | "properties": {
88 | "code": {
89 | "type": "integer",
90 | "format": "int32"
91 | },
92 | "message": {
93 | "type": "string"
94 | }
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/commonParameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.9-abcd",
5 | "title": "Swagger Sample API",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "url": "http://swagger.io"
11 | },
12 | "license": {
13 | "name": "Creative Commons 4.0 International",
14 | "url": "http://creativecommons.org/licenses/by/4.0/"
15 | }
16 | },
17 | "host": "my.api.com",
18 | "basePath": "/v1",
19 | "schemes": [
20 | "http",
21 | "https"
22 | ],
23 | "consumes": [
24 | "application/json"
25 | ],
26 | "produces": [
27 | "application/json",
28 | "application/xml"
29 | ],
30 | "paths": {
31 | "/pets/{id}": {
32 | "parameters": [
33 | {
34 | "name": "id",
35 | "in": "path",
36 | "description": "ID of pet to use",
37 | "required": true,
38 | "type": "array",
39 | "items": {
40 | "type": "string"
41 | },
42 | "collectionFormat": "csv"
43 | }
44 | ],
45 | "get": {
46 | "description": "Returns pets based on ID",
47 | "summary": "Find pets by ID",
48 | "operationId": "getPetsById",
49 | "produces": [
50 | "application/json",
51 | "text/html"
52 | ],
53 | "responses": {
54 | "200": {
55 | "description": "pet response",
56 | "schema": {
57 | "type": "array",
58 | "items": {
59 | "$ref": "#/definitions/Pet"
60 | }
61 | }
62 | },
63 | "default": {
64 | "description": "error payload",
65 | "schema": {
66 | "$ref": "#/definitions/ErrorModel"
67 | }
68 | }
69 | }
70 | }
71 | }
72 | },
73 | "definitions": {
74 | "Pet": {
75 | "required": [
76 | "name"
77 | ],
78 | "properties": {
79 | "name": {
80 | "type": "string"
81 | },
82 | "tag": {
83 | "type": "string"
84 | }
85 | }
86 | },
87 | "ErrorModel": {
88 | "required": [ "code", "message" ],
89 | "properties": {
90 | "code": {
91 | "type": "integer",
92 | "format": "int32"
93 | },
94 | "message": {
95 | "type": "string"
96 | }
97 | }
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/multipleMimeTypes.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.9-abcd",
5 | "title": "Swagger Sample API",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "url": "http://swagger.io"
11 | },
12 | "license": {
13 | "name": "Creative Commons 4.0 International",
14 | "url": "http://creativecommons.org/licenses/by/4.0/"
15 | }
16 | },
17 | "host": "my.api.com",
18 | "basePath": "/v1",
19 | "schemes": [
20 | "http",
21 | "https"
22 | ],
23 | "consumes": [
24 | "text/plain; charset=utf-8",
25 | "application/json",
26 | "application/vnd.github+json",
27 | "application/vnd.github.v3+json",
28 | "application/vnd.github.v3.raw+json",
29 | "application/vnd.github.v3.text+json",
30 | "application/vnd.github.v3.html+json",
31 | "application/vnd.github.v3.full+json",
32 | "application/vnd.github.v3.diff",
33 | "application/vnd.github.v3.patch"
34 | ],
35 | "produces": [
36 | "application/json",
37 | "application/xml"
38 | ],
39 | "paths": {
40 | "/pets/{id}": {
41 | "parameters": [
42 | {
43 | "name": "id",
44 | "in": "path",
45 | "description": "ID of pet to use",
46 | "required": true,
47 | "type": "array",
48 | "items": {
49 | "type": "string"
50 | },
51 | "collectionFormat": "csv"
52 | }
53 | ],
54 | "get": {
55 | "description": "Returns pets based on ID",
56 | "summary": "Find pets by ID",
57 | "operationId": "getPetsById",
58 | "produces": [
59 | "application/json",
60 | "text/html"
61 | ],
62 | "responses": {
63 | "200": {
64 | "description": "pet response",
65 | "schema": {
66 | "type": "array",
67 | "items": {
68 | "$ref": "#/definitions/Pet"
69 | }
70 | }
71 | },
72 | "default": {
73 | "description": "error payload",
74 | "schema": {
75 | "$ref": "#/definitions/ErrorModel"
76 | }
77 | }
78 | }
79 | }
80 | }
81 | },
82 | "definitions": {
83 | "Pet": {
84 | "required": [
85 | "name"
86 | ],
87 | "properties": {
88 | "name": {
89 | "type": "string"
90 | },
91 | "tag": {
92 | "type": "string"
93 | }
94 | }
95 | },
96 | "ErrorModel": {
97 | "required": [ "code", "message" ],
98 | "properties": {
99 | "code": {
100 | "type": "integer",
101 | "format": "int32"
102 | },
103 | "message": {
104 | "type": "string"
105 | }
106 | }
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/operations/operationWithTags.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Returns a pet based on ID",
3 | "summary": "Find pet by ID",
4 | "operationId": "getPetsById",
5 | "tags": [ "foo", "bar"],
6 | "produces": [
7 | "application/json",
8 | "text/html"
9 | ],
10 | "parameters": [
11 | {
12 | "name": "petId",
13 | "in": "path",
14 | "description": "ID of pet that needs to be fetched",
15 | "required": true,
16 | "type": "integer",
17 | "format": "int64"
18 | }
19 | ],
20 | "responses": {
21 | "200": {
22 | "description": "a pet to be returned",
23 | "schema": {"$ref": "#/definitions/Pet"}
24 | },
25 | "default": {
26 | "description": "Unexpected error",
27 | "schema": {"$ref": "#/definitions/ErrorModel"}
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/operations/stringPathAndBoolQueryParamResource.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Returns a pet based on ID",
3 | "summary": "Find pet by ID",
4 | "operationId": "getPetsById",
5 | "produces": [
6 | "application/json",
7 | "text/html"
8 | ],
9 | "parameters": [
10 | {
11 | "name": "petId",
12 | "in": "path",
13 | "description": "ID of pet that needs to be fetched",
14 | "required": true,
15 | "type": "integer",
16 | "format": "int64"
17 | },
18 | {
19 | "name": "includeDetails",
20 | "in": "query",
21 | "description": "include details in response",
22 | "required": true,
23 | "type": "boolean"
24 | }
25 | ],
26 | "responses": {
27 | "200": {
28 | "description": "a pet to be returned",
29 | "schema": {"$ref": "#/definitions/Pet"}
30 | },
31 | "default": {
32 | "description": "Unexpected error",
33 | "schema": {"$ref": "#/definitions/ErrorModel"}
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/operations/stringPathParamResource.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Returns a pet based on ID",
3 | "summary": "Find pet by ID",
4 | "operationId": "getPetsById",
5 | "produces": [
6 | "application/json",
7 | "text/html"
8 | ],
9 | "parameters": [
10 | {
11 | "name": "petId",
12 | "in": "path",
13 | "description": "ID of pet that needs to be fetched",
14 | "required": true,
15 | "type": "integer",
16 | "format": "int64"
17 | }
18 | ],
19 | "responses": {
20 | "200": {
21 | "description": "fun",
22 | "schema": {"$ref": "#/definitions/Pet"}
23 | },
24 | "400": {
25 | "description": "Invalid ID supplied <= this is purely for documentation",
26 | "schema": {"$ref": "#/definitions/ErrorModel"}
27 | },
28 | "default": {
29 | "description": "Unexpected error",
30 | "schema": {"$ref": "#/definitions/ErrorModel"}
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/bodyComplexArrayParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "user",
3 | "in": "body",
4 | "description": "user to add to the system",
5 | "required": true,
6 | "schema": {
7 | "type": "array",
8 | "items": {
9 | "type": "string"
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/bodyComplexInlineParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "user",
3 | "in": "body",
4 | "description": "user to add to the system",
5 | "required": true,
6 | "schema": {
7 | "type": "object",
8 | "required": [ "name", "id" ],
9 | "properties": {
10 | "id": {
11 | "type": "integer",
12 | "format": "int64"
13 | },
14 | "name": {
15 | "type": "string"
16 | },
17 | "keys": {
18 | "type": "array",
19 | "items": {
20 | "type": "integer"
21 | }
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/bodyComplexParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "user",
3 | "in": "body",
4 | "description": "user to add to the system",
5 | "required": true,
6 | "schema": {
7 | "$ref": "#/definitions/User"
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/bodyInt64Parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "id",
3 | "in": "body",
4 | "description": "id to add",
5 | "required": true,
6 | "schema": {
7 | "type": "integer",
8 | "format": "int64"
9 | }
10 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/bodyStringArrayParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "user",
3 | "in": "body",
4 | "description": "user to add to the system",
5 | "required": true,
6 | "schema": {
7 | "type": "array",
8 | "items": {
9 | "type": "string"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/bodyStringParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "user",
3 | "in": "body",
4 | "description": "user to add to the system",
5 | "required": true,
6 | "schema": {
7 | "type": "string"
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/formDataInt64Parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "id",
3 | "in": "formData",
4 | "description": "username to fetch",
5 | "required": true,
6 | "type": "integer",
7 | "format": "int64"
8 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/formDataStringArrayParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "user",
3 | "in": "formData",
4 | "description": "user to add to the system",
5 | "required": true,
6 | "type": "array",
7 | "items": {
8 | "type": "string"
9 | }
10 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/formDataStringParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "formData",
4 | "description": "users first name",
5 | "required": true,
6 | "type": "string"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/headerInt64ArrayParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "token",
3 | "in": "header",
4 | "description": "token to be passed as a header",
5 | "required": true,
6 | "type": "array",
7 | "items": {
8 | "type": "integer",
9 | "format": "int64"
10 | },
11 | "collectionFormat": "csv"
12 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/headerStringArrayParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "token",
3 | "in": "header",
4 | "description": "token to be passed as a header",
5 | "required": true,
6 | "type": "array",
7 | "items": {
8 | "type": "string"
9 | },
10 | "collectionFormat": "csv"
11 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/headerStringParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "token",
3 | "in": "header",
4 | "description": "token to be passed as a header",
5 | "required": true,
6 | "type": "string"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/bodyFileParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "username",
3 | "in": "body",
4 | "description": "username to fetch",
5 | "required": true,
6 | "schema": {
7 | "type": "file"
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/bodyNonSchemaParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "username",
3 | "in": "body",
4 | "description": "username to fetch",
5 | "required": true,
6 | "type": "string"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/formDataComplexParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "formData",
4 | "description": "users first name",
5 | "required": true,
6 | "$ref": "#/definitions/Nothing"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/formDataSchemaParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "formData",
4 | "description": "users first name",
5 | "required": true,
6 | "schema": {
7 | "$ref": "#/definitions/Nothing"
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/headerComplexParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "header",
4 | "description": "users first name",
5 | "required": true,
6 | "$ref": "#/definitions/Nothing"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/headerFileParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "username",
3 | "in": "header",
4 | "description": "username to fetch",
5 | "required": true,
6 | "type": "file"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/headerSchemaParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "header",
4 | "description": "users first name",
5 | "required": true,
6 | "schema": {
7 | "$ref": "#/definitions/Nothing"
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/pathComplexParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "path",
4 | "description": "users first name",
5 | "required": true,
6 | "$ref": "#/definitions/Nothing"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/pathFileParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "username",
3 | "in": "path",
4 | "description": "username to fetch",
5 | "required": true,
6 | "type": "file"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/pathNonRequiredStringParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "username",
3 | "in": "path",
4 | "description": "username to fetch",
5 | "required": false,
6 | "type": "string"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/pathSchemaParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "path",
4 | "description": "users first name",
5 | "required": true,
6 | "schema": {
7 | "$ref": "#/definitions/Nothing"
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/queryComplexParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "query",
4 | "description": "users first name",
5 | "required": true,
6 | "$ref": "#/definitions/Nothing"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/queryFileParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "username",
3 | "in": "query",
4 | "description": "username to fetch",
5 | "required": true,
6 | "type": "file"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/negative/querySchemaParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firstName",
3 | "in": "query",
4 | "description": "users first name",
5 | "required": true,
6 | "schema": {
7 | "$ref": "#/definitions/Nothing"
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/pathInt64Parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "id",
3 | "in": "path",
4 | "description": "username to fetch",
5 | "required": true,
6 | "type": "integer",
7 | "format": "int64"
8 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/pathStringArrayParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "usernames",
3 | "in": "path",
4 | "description": "usernames to pass",
5 | "required": true,
6 | "type": "array",
7 | "items": {
8 | "type": "string"
9 | },
10 | "collectionFormat": "csv"
11 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/pathStringParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "username",
3 | "in": "path",
4 | "description": "username to fetch",
5 | "required": true,
6 | "type": "string"
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/queryInt64ArrayParameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "id",
3 | "in": "query",
4 | "description": "ID of the object to fetch",
5 | "required": true,
6 | "type": "array",
7 | "items": {
8 | "type": "integer",
9 | "format": "int64"
10 | },
11 | "collectionFormat": "csv"
12 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/parameters/queryInt64Parameter.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "id",
3 | "in": "query",
4 | "description": "ID of the object to fetch",
5 | "required": true,
6 | "type": "integer",
7 | "format": "int64"
8 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/resourceWithExamplePayload.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.9-abcd",
5 | "title": "Swagger Sample API",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "url": "http://swagger.io"
11 | },
12 | "license": {
13 | "name": "Creative Commons 4.0 International",
14 | "url": "http://creativecommons.org/licenses/by/4.0/"
15 | }
16 | },
17 | "host": "my.api.com",
18 | "basePath": "/v1",
19 | "schemes": [
20 | "http",
21 | "https"
22 | ],
23 | "consumes": [
24 | "application/json"
25 | ],
26 | "produces": [
27 | "application/json",
28 | "application/xml"
29 | ],
30 | "paths": {
31 | "/pets/{petId}": {
32 | "get": {
33 | "description": "Returns a pet based on ID",
34 | "summary": "Find pet by ID",
35 | "operationId": "getPetsById",
36 | "produces": [
37 | "application/json",
38 | "text/html"
39 | ],
40 | "parameters": [
41 | {
42 | "name": "petId",
43 | "in": "path",
44 | "description": "ID of pet that needs to be fetched",
45 | "required": true,
46 | "type": "array",
47 | "items": {
48 | "type": "string"
49 | },
50 | "collectionFormat": "csv"
51 | }
52 | ],
53 | "responses": {
54 | "200": {
55 | "description": "pet response",
56 | "schema": {
57 | "$ref": "#/definitions/Pet"
58 | },
59 | "examples": {
60 | "application/json": {
61 | "id": 9,
62 | "category": {
63 | "name": "domestic"
64 | },
65 | "name": "monster",
66 | "tags": [
67 | {
68 | "name": "for sale"
69 | }
70 | ],
71 | "status": "alive"
72 | }
73 | }
74 | },
75 | "default": {
76 | "description": "error payload",
77 | "schema": {
78 | "$ref": "#/definitions/ErrorModel"
79 | }
80 | }
81 | }
82 | }
83 | }
84 | },
85 | "definitions": {
86 | "Pet": {
87 | "required": [
88 | "name"
89 | ],
90 | "properties": {
91 | "name": {
92 | "type": "string",
93 | "example": "cat"
94 | },
95 | "tag": {
96 | "type": "string",
97 | "example": "for sale"
98 | }
99 | }
100 | },
101 | "ErrorModel": {
102 | "required": [ "code", "message" ],
103 | "properties": {
104 | "code": {
105 | "type": "integer",
106 | "format": "int32"
107 | },
108 | "message": {
109 | "type": "string"
110 | }
111 | }
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/resourceWithLinkedDefinitions.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.9-abcd",
5 | "title": "Swagger Sample API",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "url": "http://swagger.io"
11 | },
12 | "license": {
13 | "name": "Creative Commons 4.0 International",
14 | "url": "http://creativecommons.org/licenses/by/4.0/"
15 | }
16 | },
17 | "host": "my.api.com",
18 | "basePath": "/v1",
19 | "schemes": [
20 | "http",
21 | "https"
22 | ],
23 | "consumes": [
24 | "application/json"
25 | ],
26 | "produces": [
27 | "application/json",
28 | "application/xml"
29 | ],
30 | "paths": {
31 | "/pets/{petId}": {
32 | "$ref": "https://raw.githubusercontent.com/swagger-api/swagger-spec/master/fixtures/v2.0/json/resources/resourceWithLinkedDefinitions_part1.json"
33 | }
34 | },
35 | "definitions": {
36 | "Pet": {
37 | "required": [
38 | "name"
39 | ],
40 | "properties": {
41 | "name": {
42 | "type": "string"
43 | },
44 | "tag": {
45 | "type": "string"
46 | }
47 | }
48 | },
49 | "ErrorModel": {
50 | "required": [ "code", "message" ],
51 | "properties": {
52 | "code": {
53 | "type": "integer",
54 | "format": "int32"
55 | },
56 | "message": {
57 | "type": "string"
58 | }
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/resourceWithLinkedDefinitions_part1.json:
--------------------------------------------------------------------------------
1 | {
2 | "get": {
3 | "description": "Returns a pet based on ID",
4 | "summary": "Find pet by ID",
5 | "operationId": "getPetsById",
6 | "produces": [
7 | "application/json",
8 | "text/html"
9 | ],
10 | "parameters": [
11 | {
12 | "name": "petId",
13 | "in": "path",
14 | "description": "ID of pet that needs to be fetched",
15 | "required": true,
16 | "type": "array",
17 | "items": {
18 | "type": "string"
19 | },
20 | "collectionFormat": "csv"
21 | }
22 | ],
23 | "responses": {
24 | "200": {
25 | "description": "pet response",
26 | "schema": {
27 | "$ref": "#/definitions/Pet"
28 | }
29 | },
30 | "default": {
31 | "description": "error payload",
32 | "schema": {
33 | "$ref": "#/definitions/ErrorModel"
34 | }
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/resourceWithRelativeHost.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.9-abcd",
5 | "title": "Swagger Sample API",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "url": "http://swagger.io"
11 | },
12 | "license": {
13 | "name": "Creative Commons 4.0 International",
14 | "url": "http://creativecommons.org/licenses/by/4.0/"
15 | }
16 | },
17 | "basePath": "/v1",
18 | "schemes": [
19 | "http",
20 | "https"
21 | ],
22 | "consumes": [
23 | "application/json"
24 | ],
25 | "produces": [
26 | "application/json",
27 | "application/xml"
28 | ],
29 | "paths": {
30 | "/pets/{id}": {
31 | "parameters": [
32 | {
33 | "name": "id",
34 | "in": "path",
35 | "description": "ID of pet to use",
36 | "required": true,
37 | "type": "array",
38 | "items": {
39 | "type": "string"
40 | },
41 | "collectionFormat": "csv"
42 | }
43 | ],
44 | "get": {
45 | "description": "Returns pets based on ID",
46 | "summary": "Find pets by ID",
47 | "operationId": "getPetsById",
48 | "produces": [
49 | "application/json",
50 | "text/html"
51 | ],
52 | "responses": {
53 | "200": {
54 | "description": "pet response",
55 | "schema": {
56 | "type": "array",
57 | "items": {
58 | "$ref": "#/definitions/Pet"
59 | }
60 | }
61 | },
62 | "default": {
63 | "description": "error payload",
64 | "schema": {
65 | "$ref": "#/definitions/ErrorModel"
66 | }
67 | }
68 | }
69 | }
70 | }
71 | },
72 | "definitions": {
73 | "Pet": {
74 | "required": [
75 | "name"
76 | ],
77 | "properties": {
78 | "name": {
79 | "type": "string"
80 | },
81 | "tag": {
82 | "type": "string"
83 | }
84 | }
85 | },
86 | "ErrorModel": {
87 | "required": [ "code", "message" ],
88 | "properties": {
89 | "code": {
90 | "type": "integer",
91 | "format": "int32"
92 | },
93 | "message": {
94 | "type": "string"
95 | }
96 | }
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/reusableParameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.9-abcd",
5 | "title": "Swagger Sample API",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "url": "http://swagger.io"
11 | },
12 | "license": {
13 | "name": "Creative Commons 4.0 International",
14 | "url": "http://creativecommons.org/licenses/by/4.0/"
15 | }
16 | },
17 | "host": "my.api.com",
18 | "basePath": "/v1",
19 | "schemes": [
20 | "http",
21 | "https"
22 | ],
23 | "consumes": [
24 | "application/json"
25 | ],
26 | "produces": [
27 | "application/json",
28 | "application/xml"
29 | ],
30 | "paths": {
31 | "/pets/{id}": {
32 | "get": {
33 | "description": "Returns pets based on ID",
34 | "summary": "Find pets by ID",
35 | "operationId": "getPetsById",
36 | "parameters": [
37 | { "$ref": "#/parameters/skipParam" },
38 | { "$ref": "#/parameters/limitParam" }
39 | ],
40 | "responses": {
41 | "200": {
42 | "description": "pet response",
43 | "schema": {
44 | "type": "array",
45 | "items": {
46 | "$ref": "#/definitions/Pet"
47 | }
48 | }
49 | },
50 | "default": {
51 | "description": "error payload",
52 | "schema": {
53 | "$ref": "#/definitions/ErrorModel"
54 | }
55 | }
56 | }
57 | }
58 | }
59 | },
60 | "parameters": {
61 | "skipParam": {
62 | "name": "skip",
63 | "in": "query",
64 | "description": "number of items to skip",
65 | "required": true,
66 | "type": "integer",
67 | "format": "int32"
68 | },
69 | "limitParam": {
70 | "name": "limit",
71 | "in": "query",
72 | "description": "max records to return",
73 | "required": true,
74 | "type": "integer",
75 | "format": "int32"
76 | }
77 | },
78 | "definitions": {
79 | "Pet": {
80 | "required": [
81 | "name"
82 | ],
83 | "properties": {
84 | "name": {
85 | "type": "string"
86 | },
87 | "tag": {
88 | "type": "string"
89 | }
90 | }
91 | },
92 | "ErrorModel": {
93 | "required": [ "code", "message" ],
94 | "properties": {
95 | "code": {
96 | "type": "integer",
97 | "format": "int32"
98 | },
99 | "message": {
100 | "type": "string"
101 | }
102 | }
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/stringPathParamResource.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.9-abcd",
5 | "title": "Swagger Sample API",
6 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
7 | "termsOfService": "http://swagger.io/terms/",
8 | "contact": {
9 | "name": "Swagger API Team",
10 | "url": "http://swagger.io"
11 | },
12 | "license": {
13 | "name": "Creative Commons 4.0 International",
14 | "url": "http://creativecommons.org/licenses/by/4.0/"
15 | }
16 | },
17 | "host": "my.api.com",
18 | "basePath": "/v1",
19 | "schemes": [
20 | "http",
21 | "https"
22 | ],
23 | "consumes": [
24 | "application/json"
25 | ],
26 | "produces": [
27 | "application/json",
28 | "application/xml"
29 | ],
30 | "paths": {
31 | "/pets/{petId}": {
32 | "get": {
33 | "description": "Returns a pet based on ID",
34 | "summary": "Find pet by ID",
35 | "operationId": "getPetsById",
36 | "produces": [
37 | "application/json",
38 | "text/html"
39 | ],
40 | "parameters": [
41 | {
42 | "name": "petId",
43 | "in": "path",
44 | "description": "ID of pet that needs to be fetched",
45 | "required": true,
46 | "type": "array",
47 | "items": {
48 | "type": "string"
49 | },
50 | "collectionFormat": "csv"
51 | }
52 | ],
53 | "responses": {
54 | "200": {
55 | "description": "pet response",
56 | "schema": {
57 | "$ref": "#/definitions/Pet"
58 | }
59 | },
60 | "default": {
61 | "description": "error payload",
62 | "schema": {
63 | "$ref": "#/definitions/ErrorModel"
64 | }
65 | }
66 | }
67 | }
68 | }
69 | },
70 | "definitions": {
71 | "Pet": {
72 | "required": [
73 | "name"
74 | ],
75 | "properties": {
76 | "name": {
77 | "type": "string"
78 | },
79 | "tag": {
80 | "type": "string"
81 | }
82 | }
83 | },
84 | "ErrorModel": {
85 | "required": [ "code", "message" ],
86 | "properties": {
87 | "code": {
88 | "type": "integer",
89 | "format": "int32"
90 | },
91 | "message": {
92 | "type": "string"
93 | }
94 | }
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/taggedResource.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "x-swagger": {
4 | "addAnythingYouWant": true
5 | },
6 | "info": {
7 | "x-swagger-info": "this is an example",
8 | "version": "1.0.9-abcd",
9 | "title": "Swagger Sample API",
10 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
11 | "termsOfService": "http://swagger.io/terms/",
12 | "contact": {
13 | "name": "Swagger API Team",
14 | "url": "http://swagger.io"
15 | },
16 | "license": {
17 | "name": "Creative Commons 4.0 International",
18 | "url": "http://creativecommons.org/licenses/by/4.0/"
19 | }
20 | },
21 | "host": "my.api.com",
22 | "basePath": "/v1",
23 | "schemes": [
24 | "http",
25 | "https"
26 | ],
27 | "consumes": [
28 | "application/json"
29 | ],
30 | "produces": [
31 | "application/json",
32 | "application/xml"
33 | ],
34 | "tags": [
35 | {
36 | "name": "pets"
37 | }
38 | ],
39 | "paths": {
40 | "x-swagger-path-info": "vendor info",
41 | "/pets": {
42 | "x-vendor-method": {},
43 | "get": {
44 | "x-vendor-operation-property": {},
45 | "description": "Returns a pet based on ID",
46 | "summary": "Find pet by ID",
47 | "operationId": "getPetsById",
48 | "produces": [
49 | "application/json",
50 | "text/html"
51 | ],
52 | "parameters": [
53 | {
54 | "x-vendor-parameter-property": {},
55 | "name": "petId",
56 | "in": "path",
57 | "description": "ID of pet that needs to be fetched",
58 | "required": true,
59 | "type": "array",
60 | "items": {
61 | "type": "string"
62 | },
63 | "collectionFormat": "csv"
64 | }
65 | ],
66 | "responses": {
67 | "x-vendor-operation-response-property": {},
68 | "200": {
69 | "description": "pet response",
70 | "schema": {
71 | "$ref": "#/definitions/Pet"
72 | }
73 | },
74 | "default": {
75 | "description": "error payload",
76 | "schema": {
77 | "$ref": "#/definitions/ErrorModel"
78 | }
79 | }
80 | }
81 | }
82 | }
83 | },
84 | "definitions": {
85 | "Pet": {
86 | "x-vendor-model-property": {},
87 | "required": [
88 | "name"
89 | ],
90 | "properties": {
91 | "name": {
92 | "type": "string"
93 | },
94 | "tag": {
95 | "type": "string"
96 | }
97 | }
98 | },
99 | "ErrorModel": {
100 | "required": [ "code", "message" ],
101 | "properties": {
102 | "code": {
103 | "type": "integer",
104 | "format": "int32"
105 | },
106 | "message": {
107 | "type": "string"
108 | }
109 | }
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/resources/vendorExtensionExamples.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "x-swagger": {
4 | "addAnythingYouWant": true
5 | },
6 | "info": {
7 | "x-swagger-info": "this is an example",
8 | "version": "1.0.9-abcd",
9 | "title": "Swagger Sample API",
10 | "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification",
11 | "termsOfService": "http://swagger.io/terms/",
12 | "contact": {
13 | "name": "Swagger API Team",
14 | "url": "http://swagger.io"
15 | },
16 | "license": {
17 | "name": "Creative Commons 4.0 International",
18 | "url": "http://creativecommons.org/licenses/by/4.0/"
19 | }
20 | },
21 | "host": "my.api.com",
22 | "basePath": "/v1",
23 | "schemes": [
24 | "http",
25 | "https"
26 | ],
27 | "consumes": [
28 | "application/json"
29 | ],
30 | "produces": [
31 | "application/json",
32 | "application/xml"
33 | ],
34 | "paths": {
35 | "x-swagger-path-info": "vendor info",
36 | "/pets": {
37 | "x-vendor-method": {},
38 | "get": {
39 | "x-vendor-operation-property": {},
40 | "description": "Returns a pet based on ID",
41 | "summary": "Find pet by ID",
42 | "operationId": "getPetsById",
43 | "produces": [
44 | "application/json",
45 | "text/html"
46 | ],
47 | "parameters": [
48 | {
49 | "x-vendor-parameter-property": {},
50 | "name": "petId",
51 | "in": "path",
52 | "description": "ID of pet that needs to be fetched",
53 | "required": true,
54 | "type": "array",
55 | "items": {
56 | "type": "string"
57 | },
58 | "collectionFormat": "csv"
59 | }
60 | ],
61 | "responses": {
62 | "x-vendor-operation-response-property": {},
63 | "200": {
64 | "description": "pet response",
65 | "schema": {
66 | "$ref": "#/definitions/Pet"
67 | }
68 | },
69 | "default": {
70 | "description": "error payload",
71 | "schema": {
72 | "$ref": "#/definitions/ErrorModel"
73 | }
74 | }
75 | }
76 | }
77 | }
78 | },
79 | "definitions": {
80 | "Pet": {
81 | "x-vendor-model-property": {},
82 | "required": [
83 | "name"
84 | ],
85 | "properties": {
86 | "name": {
87 | "type": "string"
88 | },
89 | "tag": {
90 | "type": "string"
91 | }
92 | }
93 | },
94 | "ErrorModel": {
95 | "required": [ "code", "message" ],
96 | "properties": {
97 | "code": {
98 | "type": "integer",
99 | "format": "int32"
100 | },
101 | "message": {
102 | "type": "string"
103 | }
104 | }
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/complexArrayResponse.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "A complex object array response",
3 | "schema": {
4 | "type": "array",
5 | "items": {
6 | "$ref": "#/definitions/VeryComplexType"
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/dateTimeResponse.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "A date-time response",
3 | "schema": {
4 | "type": "string",
5 | "format": "date-time"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/int32Response.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "A simple string response",
3 | "schema": {
4 | "type": "integer",
5 | "format": "int32"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/int64Response.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "A simple string response",
3 | "schema": {
4 | "type": "integer",
5 | "format": "int64"
6 | }
7 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/multipleResponses.json:
--------------------------------------------------------------------------------
1 | {
2 | "200": {
3 | "description": "simple string response",
4 | "schema": {
5 | "type": "string"
6 | }
7 | },
8 | "201": {
9 | "description": "object created"
10 | },
11 | "default": {
12 | "description": "oops",
13 | "schema": {
14 | "type": "integer",
15 | "format": "int32"
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/negative/noResponses.json:
--------------------------------------------------------------------------------
1 | {
2 | "x-test": {}
3 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/negative/noResponsesWithVendorExtension.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/stringArrayResponse.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "A string array response",
3 | "schema": {
4 | "type": "array",
5 | "items": {
6 | "type": "string"
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/stringResponse.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "A simple string response",
3 | "schema": {
4 | "type": "string"
5 | }
6 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/stringResponseWithHeader.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "A simple string response",
3 | "schema": {
4 | "type": "string"
5 | },
6 | "headers": {
7 | "is-dog": {"type": "boolean"},
8 | "is-cat": {"type": "boolean"}
9 | }
10 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/json/responses/voidResponse.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "object created"
3 | }
--------------------------------------------------------------------------------
/fixtures/v2.0/yaml/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/od2016/OpenAPI-Specification/d3b582593a1f6092c8666ad7c893ae5e12779ec7/fixtures/v2.0/yaml/.gitkeep
--------------------------------------------------------------------------------
/guidelines/EXTENSIONS.md:
--------------------------------------------------------------------------------
1 | # Swagger Extensions
2 |
3 | The Swagger 2.0 specification allows for custom properties to be added at several places within a Swagger definition, allowing
4 | API providers to extend the meta-data provided for their REST APIs as needed. Extension properties are always
5 | prefixed by "x-" and can have any valid JSON format value.
6 |
7 | Currently extension properties are supported in the following definition objects:
8 |
9 | * within the [info object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#info-object)
10 | * within the [paths object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#paths-object)
11 | * within the [path-item object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#path-item-object)
12 | * within the [operation object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#operationObject)
13 | * within the [parameter object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameterObject)
14 | * within the [responses object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#responses-object)
15 | * within the [tag object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#tag-object)
16 | * within the [security-scheme object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#security-scheme-object)
17 |
18 | For example, a vendor extension that adds apis.json specific metadata a Swagger definition might look as follows:
19 |
20 | ```json
21 | {
22 | "swagger": "2.0",
23 | "info": {
24 | "version": "1.0",
25 | "title": "Analysis",
26 | "description" : "Provides access to blog posts and analysis across the API Evangelist network.",
27 | "x-apis-json" : {
28 | "image": "https://s3.amazonaws.com/kinlane-productions/api-evangelist/t-shirts/KL_InApiWeTrust-1000.png",
29 | "humanURL": "http://developer.apievangelist.com",
30 | "baseURL": "http://api.apievangelist.com/definitions/Analysis",
31 | "tags": [
32 | "blog",
33 | "industry",
34 | "analysis",
35 | "new",
36 | "API",
37 | "Application Programming Interface"
38 | ],
39 | "properties": [
40 | {
41 | "type": "X-signup",
42 | "url": "https://apievangelist.3scale.net/"
43 | },
44 | {
45 | "type": "X-blog",
46 | "url": "http://developer.apievangelist.com/blog/"
47 | },
48 | {
49 | "type": "X-apicommonsmanifest",
50 | "url": "https://raw.githubusercontent.com/kinlane/analysis-api/master/api-commons-manifest.json"
51 | }
52 | ],
53 | }
54 | },
55 | "basePath": "/",
56 | "paths": {
57 | ...
58 | }
59 | }
60 | ```
61 |
62 | This could be used by corresponding tooling that builds apis.json files for swagger definitions, the advantage being that all metadata
63 | for a Swagger API is within one definition instead of spread out amongst multiple files.
64 |
65 | Another (simplified) example could be how to specify a [JWE encryption](http://hdknr.github.io/docs/identity/jwe.html) policy to parameters,
66 | for example as follows:
67 |
68 | ```json
69 | {
70 | ...
71 | "socialSecurityNumber": {
72 | "name": "socialSecurityNumber",
73 | "in": "query",
74 | "description": "a social security number",
75 | "required": false,
76 | "type": "string",
77 | "x-jwe-encryption" : {
78 | "algorithm" : "RSA-OAEP",
79 | "encryption" : "A256GCM"
80 | }
81 | }
82 | }
83 | ...
84 | }
85 |
86 | ```
87 | An API consumer reading these parameter definitions could interpret this as having to encrypt the skip parameter in line
88 | with the JWE standard.
89 |
90 | ## Annotations
91 |
92 | The Swagger specific annotations currently available for jax-rs APIs do not support the addition of extension data.
93 |
--------------------------------------------------------------------------------
/guidelines/README.md:
--------------------------------------------------------------------------------
1 | ## Guidelines for Swagger definitions
2 |
3 | * [Reuse](REUSE.md) of Swagger definitions
4 | * [Extending](EXTENSIONS.md) Swagger definitions with custom metadata
5 |
--------------------------------------------------------------------------------
/guidelines/sample-server/README.md:
--------------------------------------------------------------------------------
1 | ### Running the sample server
2 |
3 | ```bash
4 | npm install
5 | node server.js
6 | ```
7 |
--------------------------------------------------------------------------------
/guidelines/sample-server/files/models.json:
--------------------------------------------------------------------------------
1 | {
2 | "Model": {
3 | "type": "object",
4 | "description": "A simple model",
5 | "properties": {
6 | "id": {
7 | "type": "integer",
8 | "format": "int64"
9 | },
10 | "tag": {
11 | "description": "a complex, shared property. Note the absolute reference",
12 | "$ref": "https://my.company.com/definitions/models.json#/models/Tag"
13 | }
14 | }
15 | },
16 | "Tag": {
17 | "type": "object",
18 | "description": "A tag entity in the system",
19 | "properties": {
20 | "name": {
21 | "type": "string"
22 | }
23 | }
24 | },
25 | "Health": {
26 | "type": "object",
27 | "description": "An object representing the health of a server",
28 | "required": [
29 | "liveThreadCount",
30 | "peakThreadCount",
31 | "startedThreadCount",
32 | "daemonThreadCount",
33 | "jvmMemory"
34 | ],
35 | "properties": {
36 | "liveThreadCount": {
37 | "type": "integer",
38 | "format": "int32"
39 | },
40 | "peakThreadCount": {
41 | "type": "integer",
42 | "format": "int32"
43 | },
44 | "startedThreadCount": {
45 | "type": "integer",
46 | "format": "int32"
47 | },
48 | "daemonThreadCount": {
49 | "type": "integer",
50 | "format": "int32"
51 | },
52 | "jvmMemory": {
53 | "$ref": "http://localhost:8000/models.json#/JVMMemory"
54 | }
55 | }
56 | },
57 | "JVMMemory": {
58 | "type": "object",
59 | "required": [
60 | "allocated",
61 | "max",
62 | "free",
63 | "used",
64 | "percentUsed"
65 | ],
66 | "properties": {
67 | "allocated": {
68 | "type": "integer",
69 | "format": "int64"
70 | },
71 | "max": {
72 | "type": "integer",
73 | "format": "int64"
74 | },
75 | "free": {
76 | "type": "integer",
77 | "format": "int64"
78 | },
79 | "used": {
80 | "type": "integer",
81 | "format": "int64"
82 | },
83 | "percentUsed": {
84 | "type": "number",
85 | "format": "double"
86 | }
87 | }
88 | },
89 | "ErrorMessage": {
90 | "type": "object",
91 | "description": "A shared model for error message",
92 | "required" : ["errorCode","reason"],
93 | "properties": {
94 | "errorCode": {
95 | "type": "integer",
96 | "format": "int64"
97 | },
98 | "reason": {
99 | "description": "the reason for this error",
100 | "type": "string"
101 | },
102 | "description": {
103 | "description": "an optional longer description of this error message",
104 | "type": "string"
105 | }
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/guidelines/sample-server/files/operations.json:
--------------------------------------------------------------------------------
1 | {
2 | "health": {
3 | "get": {
4 | "tags": [
5 | "admin"
6 | ],
7 | "summary": "Returns server health information",
8 | "operationId": "getHealth",
9 | "produces": [
10 | "application/json"
11 | ],
12 | "parameters": [],
13 | "responses": {
14 | "200": {
15 | "description": "Health information from the server",
16 | "schema": {
17 | "$ref": "http://localhost:8000/models.json#/Health"
18 | }
19 | },
20 | "404": {
21 | "$ref": "http://localhost:8000/responses.json#/NotFoundError"
22 | }
23 | }
24 | }
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/guidelines/sample-server/files/parameters.json:
--------------------------------------------------------------------------------
1 | {
2 | "query" : {
3 | "skip": {
4 | "name": "skip",
5 | "in": "query",
6 | "description": "Results to skip when paginating through a result set",
7 | "required": false,
8 | "minimum": 0,
9 | "type": "integer",
10 | "format": "int32"
11 | },
12 | "limit": {
13 | "name": "limit",
14 | "in": "query",
15 | "description": "Maximum number of results to return",
16 | "required": false,
17 | "minimum": 0,
18 | "type": "integer",
19 | "format": "int32"
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/guidelines/sample-server/files/responses.json:
--------------------------------------------------------------------------------
1 | {
2 | "NotFoundError": {
3 | "description": "Entity not found",
4 | "schema": {
5 | "$ref": "http://localhost:8000/models.json#/ErrorMessage"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/guidelines/sample-server/files/swagger.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "description": "Sample server to demonstrate object reuse",
5 | "version": "1.0.0",
6 | "title": "Swagger sample"
7 | },
8 | "paths": {
9 | "/health": {
10 | "$ref": "http://localhost:8000/operations.json#/health"
11 | },
12 | "/users": {
13 | "get": {
14 | "tags": [
15 | "users"
16 | ],
17 | "summary": "Returns users in the system",
18 | "operationId": "getUsers",
19 | "produces": [
20 | "application/json"
21 | ],
22 | "parameters": [
23 | {
24 | "$ref": "http://localhost:8000/parameters.json#/query/skip"
25 | },
26 | {
27 | "$ref": "http://localhost:8000/parameters.json#/query/limit"
28 | }
29 | ],
30 | "responses": {
31 | "200": {
32 | "description": "Users in the system",
33 | "schema": {
34 | "type": "array",
35 | "items": {
36 | "$ref": "http://localhost:8000/models.json#/Health"
37 | }
38 | }
39 | },
40 | "404": {
41 | "$ref": "http://localhost:8000/responses.json#/NotFoundError"
42 | }
43 | }
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/guidelines/sample-server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.0.1",
3 | "author": {
4 | "name": "Tony Tam",
5 | "email": "fehguy@gmail.com",
6 | "url": "https://github.com/fehguy"
7 | },
8 | "dependencies": {
9 | "cors": "^2.5.3",
10 | "http-server": "0.8.0"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/guidelines/sample-server/server.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 | var createServer = require('http-server').createServer;
3 |
4 | var server = createServer({ root: 'files', cors: true });
5 |
6 | server.listen(8000);
7 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp');
2 |
3 | var jsonlint = require("gulp-jsonlint");
4 | var gulpyaml = require('gulp-yaml');
5 | var ext_replace = require('gulp-ext-replace');
6 | var map = require('map-stream');
7 | var YAML = require('json2yaml');
8 | var gutil = require('gulp-util');
9 |
10 | var exitCode = 0;
11 |
12 | var json_paths = {
13 | examples: 'examples/**/*.json',
14 | models: 'fixtures/v2.0/json/models/**/*.json',
15 | resources: 'fixtures/v2.0/json/resources/**/*.json',
16 | responses: 'fixtures/v2.0/json/responses/**/*.json'
17 | // What are the other files in fixtures/v2.0/json/*.json
18 | };
19 |
20 | gulp.task('lint', function() {
21 | return gulp.src(['./**/*.json', '!./node_modules/**/*.json'])
22 | .pipe(jsonlint())
23 | .pipe(jsonlint.reporter());
24 |
25 | // YAML linting/formatting?
26 | });
27 |
28 | gulp.task('yaml2json', function(){
29 | gulp.src('./fixtures/v2.0/yaml/**.yaml')
30 | .pipe(gulpyaml({ pretty: true }))
31 | .pipe(gulp.dest('./fixtures/v2.0/json'));
32 |
33 | gulp.src(json_paths.examples)
34 | .pipe(gulpyaml({ pretty: true }))
35 | .pipe(gulp.dest('examples/'));
36 | });
37 |
38 | gulp.task('json2yaml', function(){
39 | return gulp.src('./fixtures/v2.0/json/**/*.json')
40 | .pipe(map(function(file, cb) {
41 | data = JSON.parse(file.contents);
42 | file.contents = new Buffer(String(YAML.stringify(data)));
43 | cb(null, file);
44 | }))
45 | .pipe(ext_replace('.yaml'))
46 | .pipe(gulp.dest('fixtures/v2.0/yaml'));
47 | });
48 |
49 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "test": "gulp lint && mocha"
5 | },
6 | "dependencies": {},
7 | "devDependencies": {
8 | "chai": "^3.5.0",
9 | "glob": "^7.0.0",
10 | "gulp": "~3.8.x",
11 | "gulp-ext-replace": "^0.1.0",
12 | "gulp-jsonlint": "0.0.3",
13 | "gulp-util": "^3.0.0",
14 | "gulp-yaml": "0.0.3",
15 | "js-yaml": "^3.1.0",
16 | "json-schema-ref-parser": "^2.2.0",
17 | "json2yaml": "^1.0.3",
18 | "jsonschema": "^1.0.0",
19 | "lodash": "^4.5.1",
20 | "map-stream": "^0.1.0",
21 | "mocha": "^2.4.5",
22 | "z-schema": "^3.16.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/schemas/v1.2/README.md:
--------------------------------------------------------------------------------
1 | # Swagger Specification JSON Schemas
2 |
3 | The work on the JSON Schema for the Swagger Specification was donated to the community by [Francis Galiegue](https://github.com/fge)!
4 |
5 | Keep in mind that due to some JSON Schema limitations, not all constraints can be described. The missing constraints will be listed here in the future.
6 |
--------------------------------------------------------------------------------
/schemas/v1.2/apiDeclaration.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/apiDeclaration.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "required": [ "swaggerVersion", "basePath", "apis" ],
6 | "properties": {
7 | "swaggerVersion": { "enum": [ "1.2" ] },
8 | "apiVersion": { "type": "string" },
9 | "basePath": {
10 | "type": "string",
11 | "format": "uri",
12 | "pattern": "^https?://"
13 | },
14 | "resourcePath": {
15 | "type": "string",
16 | "format": "uri",
17 | "pattern": "^/"
18 | },
19 | "apis": {
20 | "type": "array",
21 | "items": { "$ref": "#/definitions/apiObject" }
22 | },
23 | "models": {
24 | "type": "object",
25 | "additionalProperties": {
26 | "$ref": "modelsObject.json#"
27 | }
28 | },
29 | "produces": { "$ref": "#/definitions/mimeTypeArray" },
30 | "consumes": { "$ref": "#/definitions/mimeTypeArray" },
31 | "authorizations": { "$ref": "authorizationObject.json#" }
32 | },
33 | "additionalProperties": false,
34 | "definitions": {
35 | "apiObject": {
36 | "type": "object",
37 | "required": [ "path", "operations" ],
38 | "properties": {
39 | "path": {
40 | "type": "string",
41 | "format": "uri-template",
42 | "pattern": "^/"
43 | },
44 | "description": { "type": "string" },
45 | "operations": {
46 | "type": "array",
47 | "items": { "$ref": "operationObject.json#" }
48 | }
49 | },
50 | "additionalProperties": false
51 | },
52 | "mimeTypeArray": {
53 | "type": "array",
54 | "items": {
55 | "type": "string",
56 | "format": "mime-type"
57 | },
58 | "uniqueItems": true
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/schemas/v1.2/authorizationObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/authorizationObject.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "additionalProperties": {
6 | "oneOf": [
7 | {
8 | "$ref": "#/definitions/basicAuth"
9 | },
10 | {
11 | "$ref": "#/definitions/apiKey"
12 | },
13 | {
14 | "$ref": "#/definitions/oauth2"
15 | }
16 | ]
17 | },
18 | "definitions": {
19 | "basicAuth": {
20 | "required": [ "type" ],
21 | "properties": {
22 | "type": { "enum": [ "basicAuth" ] }
23 | },
24 | "additionalProperties": false
25 | },
26 | "apiKey": {
27 | "required": [ "type", "passAs", "keyname" ],
28 | "properties": {
29 | "type": { "enum": [ "apiKey" ] },
30 | "passAs": { "enum": [ "header", "query" ] },
31 | "keyname": { "type": "string" }
32 | },
33 | "additionalProperties": false
34 | },
35 | "oauth2": {
36 | "type": "object",
37 | "required": [ "type", "grantTypes" ],
38 | "properties": {
39 | "type": { "enum": [ "oauth2" ] },
40 | "scopes": {
41 | "type": "array",
42 | "items": { "$ref": "#/definitions/oauth2Scope" }
43 | },
44 | "grantTypes": { "$ref": "oauth2GrantType.json#" }
45 | },
46 | "additionalProperties": false
47 | },
48 | "oauth2Scope": {
49 | "type": "object",
50 | "required": [ "scope" ],
51 | "properties": {
52 | "scope": { "type": "string" },
53 | "description": { "type": "string" }
54 | },
55 | "additionalProperties": false
56 | }
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/schemas/v1.2/dataType.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/dataType.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Data type as described by the specification (version 1.2)",
5 | "type": "object",
6 | "oneOf": [
7 | { "$ref": "#/definitions/refType" },
8 | { "$ref": "#/definitions/voidType" },
9 | { "$ref": "#/definitions/primitiveType" },
10 | { "$ref": "#/definitions/modelType" },
11 | { "$ref": "#/definitions/arrayType" }
12 | ],
13 | "definitions": {
14 | "refType": {
15 | "required": [ "$ref" ],
16 | "properties": {
17 | "$ref": { "type": "string" }
18 | },
19 | "additionalProperties": false
20 | },
21 | "voidType": {
22 | "enum": [ { "type": "void" } ]
23 | },
24 | "modelType": {
25 | "required": [ "type" ],
26 | "properties": {
27 | "type": {
28 | "type": "string",
29 | "not": {
30 | "enum": [ "boolean", "integer", "number", "string", "array" ]
31 | }
32 | }
33 | },
34 | "additionalProperties": false
35 | },
36 | "primitiveType": {
37 | "required": [ "type" ],
38 | "properties": {
39 | "type": {
40 | "enum": [ "boolean", "integer", "number", "string" ]
41 | },
42 | "format": { "type": "string" },
43 | "defaultValue": {
44 | "not": { "type": [ "array", "object", "null" ] }
45 | },
46 | "enum": {
47 | "type": "array",
48 | "items": { "type": "string" },
49 | "minItems": 1,
50 | "uniqueItems": true
51 | },
52 | "minimum": { "type": "string" },
53 | "maximum": { "type": "string" }
54 | },
55 | "additionalProperties": false,
56 | "dependencies": {
57 | "format": {
58 | "oneOf": [
59 | {
60 | "properties": {
61 | "type": { "enum": [ "integer" ] },
62 | "format": { "enum": [ "int32", "int64" ] }
63 | }
64 | },
65 | {
66 | "properties": {
67 | "type": { "enum": [ "number" ] },
68 | "format": { "enum": [ "float", "double" ] }
69 | }
70 | },
71 | {
72 | "properties": {
73 | "type": { "enum": [ "string" ] },
74 | "format": {
75 | "enum": [ "byte", "date", "date-time" ]
76 | }
77 | }
78 | }
79 | ]
80 | },
81 | "enum": {
82 | "properties": {
83 | "type": { "enum": [ "string" ] }
84 | }
85 | },
86 | "minimum": {
87 | "properties": {
88 | "type": { "enum": [ "integer", "number" ] }
89 | }
90 | },
91 | "maximum": {
92 | "properties": {
93 | "type": { "enum": [ "integer", "number" ] }
94 | }
95 | }
96 | }
97 | },
98 | "arrayType": {
99 | "required": [ "type", "items" ],
100 | "properties": {
101 | "type": { "enum": [ "array" ] },
102 | "items": {
103 | "type": "array",
104 | "items": { "$ref": "#/definitions/itemsObject" }
105 | },
106 | "uniqueItems": { "type": "boolean" }
107 | },
108 | "additionalProperties": false
109 | },
110 | "itemsObject": {
111 | "oneOf": [
112 | {
113 | "$ref": "#/definitions/refType"
114 | },
115 | {
116 | "allOf": [
117 | {
118 | "$ref": "#/definitions/primitiveType"
119 | },
120 | {
121 | "properties": {
122 | "type": {},
123 | "format": {}
124 | },
125 | "additionalProperties": false
126 | }
127 | ]
128 | }
129 | ]
130 | }
131 | }
132 | }
--------------------------------------------------------------------------------
/schemas/v1.2/dataTypeBase.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/dataTypeBase.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "Data type fields (section 4.3.3)",
5 | "type": "object",
6 | "oneOf": [
7 | { "required": [ "type" ] },
8 | { "required": [ "$ref" ] }
9 | ],
10 | "properties": {
11 | "type": { "type": "string" },
12 | "$ref": { "type": "string" },
13 | "format": { "type": "string" },
14 | "defaultValue": {
15 | "not": { "type": [ "array", "object", "null" ] }
16 | },
17 | "enum": {
18 | "type": "array",
19 | "items": { "type": "string" },
20 | "uniqueItems": true,
21 | "minItems": 1
22 | },
23 | "minimum": { "type": "string" },
24 | "maximum": { "type": "string" },
25 | "items": { "$ref": "#/definitions/itemsObject" },
26 | "uniqueItems": { "type": "boolean" }
27 | },
28 | "dependencies": {
29 | "format": {
30 | "oneOf": [
31 | {
32 | "properties": {
33 | "type": { "enum": [ "integer" ] },
34 | "format": { "enum": [ "int32", "int64" ] }
35 | }
36 | },
37 | {
38 | "properties": {
39 | "type": { "enum": [ "number" ] },
40 | "format": { "enum": [ "float", "double" ] }
41 | }
42 | },
43 | {
44 | "properties": {
45 | "type": { "enum": [ "string" ] },
46 | "format": {
47 | "enum": [ "byte", "date", "date-time" ]
48 | }
49 | }
50 | }
51 | ]
52 | }
53 | },
54 | "definitions": {
55 | "itemsObject": {
56 | "oneOf": [
57 | {
58 | "type": "object",
59 | "required": [ "$ref" ],
60 | "properties": {
61 | "$ref": { "type": "string" }
62 | },
63 | "additionalProperties": false
64 | },
65 | {
66 | "allOf": [
67 | { "$ref": "#" },
68 | {
69 | "required": [ "type" ],
70 | "properties": {
71 | "type": {},
72 | "format": {}
73 | },
74 | "additionalProperties": false
75 | }
76 | ]
77 | }
78 | ]
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/schemas/v1.2/infoObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/infoObject.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "description": "info object (section 5.1.3)",
5 | "type": "object",
6 | "required": [ "title", "description" ],
7 | "properties": {
8 | "title": { "type": "string" },
9 | "description": { "type": "string" },
10 | "termsOfServiceUrl": { "type": "string", "format": "uri" },
11 | "contact": { "type": "string", "format": "email" },
12 | "license": { "type": "string" },
13 | "licenseUrl": { "type": "string", "format": "uri" }
14 | },
15 | "additionalProperties": false
16 | }
--------------------------------------------------------------------------------
/schemas/v1.2/modelsObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/modelsObject.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "required": [ "id", "properties" ],
6 | "properties": {
7 | "id": { "type": "string" },
8 | "description": { "type": "string" },
9 | "properties": {
10 | "type": "object",
11 | "additionalProperties": { "$ref": "#/definitions/propertyObject" }
12 | },
13 | "subTypes": {
14 | "type": "array",
15 | "items": { "type": "string" },
16 | "uniqueItems": true
17 | },
18 | "discriminator": { "type": "string" }
19 | },
20 | "dependencies": {
21 | "subTypes": [ "discriminator" ]
22 | },
23 | "definitions": {
24 | "propertyObject": {
25 | "allOf": [
26 | {
27 | "not": { "$ref": "#" }
28 | },
29 | {
30 | "$ref": "dataTypeBase.json#"
31 | }
32 | ]
33 | }
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/schemas/v1.2/oauth2GrantType.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/oauth2GrantType.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "minProperties": 1,
6 | "properties": {
7 | "implicit": { "$ref": "#/definitions/implicit" },
8 | "authorization_code": { "$ref": "#/definitions/authorizationCode" }
9 | },
10 | "definitions": {
11 | "implicit": {
12 | "type": "object",
13 | "required": [ "loginEndpoint" ],
14 | "properties": {
15 | "loginEndpoint": { "$ref": "#/definitions/loginEndpoint" },
16 | "tokenName": { "type": "string" }
17 | },
18 | "additionalProperties": false
19 | },
20 | "authorizationCode": {
21 | "type": "object",
22 | "required": [ "tokenEndpoint", "tokenRequestEndpoint" ],
23 | "properties": {
24 | "tokenEndpoint": { "$ref": "#/definitions/tokenEndpoint" },
25 | "tokenRequestEndpoint": { "$ref": "#/definitions/tokenRequestEndpoint" }
26 | },
27 | "additionalProperties": false
28 | },
29 | "loginEndpoint": {
30 | "type": "object",
31 | "required": [ "url" ],
32 | "properties": {
33 | "url": { "type": "string", "format": "uri" }
34 | },
35 | "additionalProperties": false
36 | },
37 | "tokenEndpoint": {
38 | "type": "object",
39 | "required": [ "url" ],
40 | "properties": {
41 | "url": { "type": "string", "format": "uri" },
42 | "tokenName": { "type": "string" }
43 | },
44 | "additionalProperties": false
45 | },
46 | "tokenRequestEndpoint": {
47 | "type": "object",
48 | "required": [ "url" ],
49 | "properties": {
50 | "url": { "type": "string", "format": "uri" },
51 | "clientIdName": { "type": "string" },
52 | "clientSecretName": { "type": "string" }
53 | },
54 | "additionalProperties": false
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/schemas/v1.2/operationObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/operationObject.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "allOf": [
6 | { "$ref": "dataTypeBase.json#" },
7 | {
8 | "required": [ "method", "nickname", "parameters" ],
9 | "properties": {
10 | "method": { "enum": [ "GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS" ] },
11 | "summary": { "type": "string", "maxLength": 120 },
12 | "notes": { "type": "string" },
13 | "nickname": {
14 | "type": "string",
15 | "pattern": "^[a-zA-Z0-9_]+$"
16 | },
17 | "authorizations": {
18 | "type": "object",
19 | "additionalProperties": {
20 | "type": "array",
21 | "items": {
22 | "$ref": "authorizationObject.json#/definitions/oauth2Scope"
23 | }
24 | }
25 | },
26 | "parameters": {
27 | "type": "array",
28 | "items": { "$ref": "parameterObject.json#" }
29 | },
30 | "responseMessages": {
31 | "type": "array",
32 | "items": { "$ref": "#/definitions/responseMessageObject"}
33 | },
34 | "produces": { "$ref": "#/definitions/mimeTypeArray" },
35 | "consumes": { "$ref": "#/definitions/mimeTypeArray" },
36 | "deprecated": { "enum": [ "true", "false" ] }
37 | }
38 | }
39 | ],
40 | "definitions": {
41 | "responseMessageObject": {
42 | "type": "object",
43 | "required": [ "code", "message" ],
44 | "properties": {
45 | "code": { "$ref": "#/definitions/rfc2616section10" },
46 | "message": { "type": "string" },
47 | "responseModel": { "type": "string" }
48 | }
49 | },
50 | "rfc2616section10": {
51 | "type": "integer",
52 | "minimum": 100,
53 | "maximum": 600,
54 | "exclusiveMaximum": true
55 | },
56 | "mimeTypeArray": {
57 | "type": "array",
58 | "items": {
59 | "type": "string",
60 | "format": "mime-type"
61 | },
62 | "uniqueItems": true
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/schemas/v1.2/parameterObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/parameterObject.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "allOf": [
6 | { "$ref": "dataTypeBase.json#" },
7 | {
8 | "required": [ "paramType", "name" ],
9 | "properties": {
10 | "paramType": {
11 | "enum": [ "path", "query", "body", "header", "form" ]
12 | },
13 | "name": { "type": "string" },
14 | "description": { "type": "string" },
15 | "required": { "type": "boolean" },
16 | "allowMultiple": { "type": "boolean" }
17 | }
18 | },
19 | {
20 | "description": "type File requires special paramType and consumes",
21 | "oneOf": [
22 | {
23 | "properties": {
24 | "type": { "not": { "enum": [ "File" ] } }
25 | }
26 | },
27 | {
28 | "properties": {
29 | "type": { "enum": [ "File" ] },
30 | "paramType": { "enum": [ "form" ] },
31 | "consumes": { "enum": [ "multipart/form-data" ] }
32 | }
33 | }
34 | ]
35 | }
36 | ]
37 | }
38 |
--------------------------------------------------------------------------------
/schemas/v1.2/resourceListing.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceListing.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "required": [ "swaggerVersion", "apis" ],
6 | "properties": {
7 | "swaggerVersion": { "enum": [ "1.2" ] },
8 | "apis": {
9 | "type": "array",
10 | "items": { "$ref": "resourceObject.json#" }
11 | },
12 | "apiVersion": { "type": "string" },
13 | "info": { "$ref": "infoObject.json#" },
14 | "authorizations": { "$ref": "authorizationObject.json#" }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/schemas/v1.2/resourceObject.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v1.2/resourceObject.json#",
3 | "$schema": "http://json-schema.org/draft-04/schema#",
4 | "type": "object",
5 | "required": [ "path" ],
6 | "properties": {
7 | "path": { "type": "string", "format": "uri" },
8 | "description": { "type": "string" }
9 | },
10 | "additionalProperties": false
11 | }
--------------------------------------------------------------------------------
/schemas/v2.0/README.md:
--------------------------------------------------------------------------------
1 | # Swagger Specification JSON Schemas
2 |
3 | This is only JSON Schema file for Swagger version 2.0. Download and Install it via NPM or Bower.
4 |
5 | ## Install via NPM
6 |
7 | ```shell
8 | npm install --save swagger-schema-official
9 | ```
10 |
11 | #### Install 1.2 version via NPM
12 |
13 | ```shell
14 | npm install --save swagger-schema-official@1.2.0
15 | ```
16 | ## Install via Bower
17 |
18 | ```shell
19 | bower install --save swagger-schema
20 | ```
21 |
22 | ## License
23 |
24 | Apache-2.0
25 |
--------------------------------------------------------------------------------
/schemas/v2.0/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "swagger-schema",
3 | "version": "2.0.0-96305d9",
4 | "homepage": "https://github.com/swagger-api/swagger-schema",
5 | "authors": [
6 | "''"
7 | ],
8 | "main": "./schema.json",
9 | "description": "Swagger JSON Schema",
10 | "keywords": [
11 | "swagger",
12 | "schema",
13 | "api"
14 | ],
15 | "license": "Apache-2.0"
16 | }
17 |
--------------------------------------------------------------------------------
/schemas/v2.0/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "swagger-schema-official",
3 | "version": "2.0.0-bab6bed",
4 | "description": "Swagger JSON Schema ",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "keywords": [
9 | "swagger",
10 | "schema",
11 | "api"
12 | ],
13 | "author": "",
14 | "main": "./schema.json",
15 | "license": "Apache-2.0"
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/javascript/server.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs'),
2 | http = require('http');
3 |
4 | http.createServer(function (req, res) {
5 | fs.readFile("./schemas/v2.0" + req.url, function (err,data) {
6 | if (err) {
7 | res.writeHead(404);
8 | res.end(JSON.stringify(err));
9 | return;
10 | }
11 | res.writeHead(200);
12 | res.end(data);
13 | });
14 | }).listen(8000);
--------------------------------------------------------------------------------
/src/test/scala/GeneralTest.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.JsonNode
2 | import com.github.fge.jsonschema.core.exceptions.ProcessingException
3 | import com.github.fge.jsonschema.main.{ JsonSchema, JsonSchemaFactory}
4 | import com.github.fge.jsonschema.core.report.ProcessingReport
5 | import com.github.fge.jackson.JsonLoader
6 |
7 | import scala.io.Source
8 |
9 | import org.junit.runner.RunWith
10 | import org.scalatest.junit.JUnitRunner
11 | import org.scalatest.FlatSpec
12 | import org.scalatest.matchers.ShouldMatchers
13 |
14 | @RunWith(classOf[JUnitRunner])
15 | class InfoTest extends FlatSpec with ShouldMatchers with TestBase {
16 | val schema = readSchema(true)
17 | val factory = JsonSchemaFactory.byDefault()
18 | val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("info"))
19 |
20 | // Info Object Tests - Positive
21 |
22 | it should "validate a basic info object" in {
23 | val json = Source.fromFile("fixtures/v2.0/json/general/basicInfoObject.json").mkString
24 | val data = JsonLoader.fromString(json)
25 | val report = jsonSchema.validate(data)
26 | if(report.isSuccess == false)
27 | println(report)
28 | report.isSuccess should be (true)
29 | }
30 |
31 | it should "validate a minimal info object" in {
32 | val json = Source.fromFile("fixtures/v2.0/json/general/minimalInfoObject.json").mkString
33 | val data = JsonLoader.fromString(json)
34 | val report = jsonSchema.validate(data)
35 | if(report.isSuccess == false)
36 | println(report)
37 | report.isSuccess should be (true)
38 | }
39 |
40 | // Info Object (+ License Object) Tests - Negative
41 |
42 | it should "not validate an info object with missing required fields" in {
43 | val json = Source.fromFile("fixtures/v2.0/json/general/negative/negativeInfoObject.json").mkString
44 | val data = JsonLoader.fromString(json)
45 | val report = jsonSchema.validate(data)
46 | if(report.isSuccess == true)
47 | println(report)
48 | report.isSuccess should be (false)
49 | }
50 | }
51 |
52 | @RunWith(classOf[JUnitRunner])
53 | class ExternalDocsTest extends FlatSpec with ShouldMatchers with TestBase {
54 | val schema = readSchema(true)
55 | val factory = JsonSchemaFactory.byDefault()
56 | val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("externalDocs"))
57 |
58 | // externalDocs - Positive
59 |
60 | it should "validate an externalDocs object" in {
61 | val json = Source.fromFile("fixtures/v2.0/json/general/externalDocs.json").mkString
62 | val data = JsonLoader.fromString(json)
63 | val report = jsonSchema.validate(data)
64 | if(report.isSuccess == false)
65 | println(report)
66 | report.isSuccess should be (true)
67 | }
68 |
69 | // externalDocs - Negative
70 |
71 | it should "not validate an externalDocs with missing required fields" in {
72 | val json = Source.fromFile("fixtures/v2.0/json/general/negative/negativeExternalDocs.json").mkString
73 | val data = JsonLoader.fromString(json)
74 | val report = jsonSchema.validate(data)
75 | if(report.isSuccess == true)
76 | println(report)
77 | report.isSuccess should be (false)
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/test/scala/ModelTest.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.JsonNode
2 | import com.github.fge.jsonschema.core.exceptions.ProcessingException
3 | import com.github.fge.jsonschema.main.{ JsonSchema, JsonSchemaFactory}
4 | import com.github.fge.jsonschema.core.report.ProcessingReport
5 | import com.github.fge.jackson.JsonLoader
6 |
7 | import scala.io.Source
8 |
9 | import org.junit.runner.RunWith
10 | import org.scalatest.junit.JUnitRunner
11 | import org.scalatest.FlatSpec
12 | import org.scalatest.matchers.ShouldMatchers
13 |
14 | @RunWith(classOf[JUnitRunner])
15 | class ModelTest extends FlatSpec with ShouldMatchers with TestBase {
16 | val schema = readSchema(true)
17 | val factory = JsonSchemaFactory.byDefault()
18 | val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("schema"))
19 |
20 | it should "validate a model with string property" in {
21 | val json = Source.fromFile("fixtures/v2.0/json/models/modelWithStringProperty.json").mkString
22 | val data = JsonLoader.fromString(json)
23 | val report = jsonSchema.validate(data)
24 | if(report.isSuccess == false)
25 | println(report)
26 | report.isSuccess should be (true)
27 | }
28 |
29 | it should "validate a model with multiple properties" in {
30 | val json = Source.fromFile("fixtures/v2.0/json/models/modelWithMultipleProperties.json").mkString
31 | val data = JsonLoader.fromString(json)
32 | val report = jsonSchema.validate(data)
33 | if(report.isSuccess == false)
34 | println(report)
35 | report.isSuccess should be (true)
36 | }
37 |
38 | it should "validate a model with an int32 map" in {
39 | val json = Source.fromFile("fixtures/v2.0/json/models/modelWithInt32Map.json").mkString
40 | val data = JsonLoader.fromString(json)
41 | val report = jsonSchema.validate(data)
42 | if(report.isSuccess == false)
43 | println(report)
44 | report.isSuccess should be (true)
45 | }
46 |
47 | it should "validate a model with an int64 map" in {
48 | val json = Source.fromFile("fixtures/v2.0/json/models/modelWithInt64Map.json").mkString
49 | val data = JsonLoader.fromString(json)
50 | val report = jsonSchema.validate(data)
51 | if(report.isSuccess == false)
52 | println(report)
53 | report.isSuccess should be (true)
54 | }
55 |
56 | it should "validate a model with an date-time map" in {
57 | val json = Source.fromFile("fixtures/v2.0/json/models/modelWithDateTimeMap.json").mkString
58 | val data = JsonLoader.fromString(json)
59 | val report = jsonSchema.validate(data)
60 | if(report.isSuccess == false)
61 | println(report)
62 | report.isSuccess should be (true)
63 | }
64 |
65 | it should "validate a model with xml properties" in {
66 | val json = Source.fromFile("fixtures/v2.0/json/models/modelWithXmlAttributes.json").mkString
67 | val data = JsonLoader.fromString(json)
68 | val report = jsonSchema.validate(data)
69 | if(report.isSuccess == false)
70 | println(report)
71 | report.isSuccess should be (true)
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/test/scala/ModelsTest.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.JsonNode
2 | import com.github.fge.jsonschema.core.exceptions.ProcessingException
3 | import com.github.fge.jsonschema.main.{ JsonSchema, JsonSchemaFactory}
4 | import com.github.fge.jsonschema.core.report.ProcessingReport
5 | import com.github.fge.jackson.JsonLoader
6 |
7 | import scala.io.Source
8 |
9 | import org.junit.runner.RunWith
10 | import org.scalatest.junit.JUnitRunner
11 | import org.scalatest.FlatSpec
12 | import org.scalatest.matchers.ShouldMatchers
13 |
14 | @RunWith(classOf[JUnitRunner])
15 | class ModelsTest extends FlatSpec with ShouldMatchers with TestBase {
16 | val schema = readSchema(true)
17 | val factory = JsonSchemaFactory.byDefault()
18 | val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("definitions"))
19 |
20 | it should "validate a models hash" in {
21 | val json = Source.fromFile("fixtures/v2.0/json/models/models.json").mkString
22 | val data = JsonLoader.fromString(json)
23 | val report = jsonSchema.validate(data)
24 | if(report.isSuccess == false)
25 | println(report)
26 | report.isSuccess should be (true)
27 | }
28 |
29 | it should "validate multiple models" in {
30 | val json = Source.fromFile("fixtures/v2.0/json/models/multipleModels.json").mkString
31 | val data = JsonLoader.fromString(json)
32 | val report = jsonSchema.validate(data)
33 | if(report.isSuccess == false)
34 | println(report)
35 | report.isSuccess should be (true)
36 | }
37 |
38 | it should "validate models with examples" in {
39 | val json = Source.fromFile("fixtures/v2.0/json/models/modelWithExamples.json").mkString
40 | val data = JsonLoader.fromString(json)
41 | val report = jsonSchema.validate(data)
42 | if(report.isSuccess == false)
43 | println(report)
44 | report.isSuccess should be (true)
45 | }
46 |
47 | it should "validate models with composition" in {
48 | val json = Source.fromFile("fixtures/v2.0/json/models/modelWithComposition.json").mkString
49 | val data = JsonLoader.fromString(json)
50 | val report = jsonSchema.validate(data)
51 | if(report.isSuccess == false)
52 | println(report)
53 | report.isSuccess should be (true)
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/scala/OperationsTest.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.JsonNode
2 | import com.github.fge.jsonschema.core.exceptions.ProcessingException
3 | import com.github.fge.jsonschema.main.{ JsonSchema, JsonSchemaFactory}
4 | import com.github.fge.jsonschema.core.report.ProcessingReport
5 | import com.github.fge.jackson.JsonLoader
6 |
7 | import scala.io.Source
8 |
9 | import org.junit.runner.RunWith
10 | import org.scalatest.junit.JUnitRunner
11 | import org.scalatest.FlatSpec
12 | import org.scalatest.matchers.ShouldMatchers
13 |
14 | @RunWith(classOf[JUnitRunner])
15 | class OperationsTest extends FlatSpec with ShouldMatchers with TestBase {
16 | val schema = readSchema(true)
17 | val factory = JsonSchemaFactory.byDefault()
18 | val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("operation"))
19 |
20 | it should "validate a resource with string path param" in {
21 | val json = Source.fromFile("fixtures/v2.0/json/resources/operations/stringPathParamResource.json").mkString
22 | val data = JsonLoader.fromString(json)
23 | val report = jsonSchema.validate(data)
24 | if(report.isSuccess == false)
25 | println(report)
26 | report.isSuccess should be (true)
27 | }
28 |
29 | it should "validate a resource with string path param and boolean query param" in {
30 | val json = Source.fromFile("fixtures/v2.0/json/resources/operations/stringPathAndBoolQueryParamResource.json").mkString
31 | val data = JsonLoader.fromString(json)
32 | val report = jsonSchema.validate(data)
33 | if(report.isSuccess == false)
34 | println(report)
35 | report.isSuccess should be (true)
36 | }
37 |
38 | it should "validate a resource with tags in the operation" in {
39 | val json = Source.fromFile("fixtures/v2.0/json/resources/operations/operationWithTags.json").mkString
40 | val data = JsonLoader.fromString(json)
41 | val report = jsonSchema.validate(data)
42 | if(report.isSuccess == false)
43 | println(report)
44 | report.isSuccess should be (true)
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/scala/PropertyTest.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.JsonNode
2 | import com.github.fge.jsonschema.core.exceptions.ProcessingException
3 | import com.github.fge.jsonschema.main.{ JsonSchema, JsonSchemaFactory}
4 | import com.github.fge.jsonschema.core.report.ProcessingReport
5 | import com.github.fge.jackson.JsonLoader
6 |
7 | import scala.io.Source
8 |
9 | import org.junit.runner.RunWith
10 | import org.scalatest.junit.JUnitRunner
11 | import org.scalatest.FlatSpec
12 | import org.scalatest.matchers.ShouldMatchers
13 |
14 | @RunWith(classOf[JUnitRunner])
15 | class PropertyTest extends FlatSpec with ShouldMatchers with TestBase {
16 | val schema = readSchema(true)
17 | val factory = JsonSchemaFactory.byDefault()
18 | val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("schema"))
19 |
20 | it should "validate a simple string property" in {
21 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/simpleStringProperty.json").mkString
22 | val data = JsonLoader.fromString(json)
23 | val report = jsonSchema.validate(data)
24 | if(report.isSuccess == false)
25 | println(report)
26 | report.isSuccess should be (true)
27 | }
28 |
29 | it should "validate a simple int32 property" in {
30 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/simpleInt32Property.json").mkString
31 | val data = JsonLoader.fromString(json)
32 | val report = jsonSchema.validate(data)
33 | if(report.isSuccess == false)
34 | println(report)
35 | report.isSuccess should be (true)
36 | }
37 |
38 | it should "validate a simple int64 property" in {
39 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/simpleInt64Property.json").mkString
40 | val data = JsonLoader.fromString(json)
41 | val report = jsonSchema.validate(data)
42 | if(report.isSuccess == false)
43 | println(report)
44 | report.isSuccess should be (true)
45 | }
46 |
47 | it should "validate a simple date-time property" in {
48 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/simpleDateTimeProperty.json").mkString
49 | val data = JsonLoader.fromString(json)
50 | val report = jsonSchema.validate(data)
51 | if(report.isSuccess == false)
52 | println(report)
53 | report.isSuccess should be (true)
54 | }
55 |
56 | it should "validate a simple boolean property" in {
57 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/simpleBooleanProperty.json").mkString
58 | val data = JsonLoader.fromString(json)
59 | val report = jsonSchema.validate(data)
60 | if(report.isSuccess == false)
61 | println(report)
62 | report.isSuccess should be (true)
63 | }
64 |
65 | it should "validate a simple byte property" in {
66 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/simpleByteProperty.json").mkString
67 | val data = JsonLoader.fromString(json)
68 | val report = jsonSchema.validate(data)
69 | if(report.isSuccess == false)
70 | println(report)
71 | report.isSuccess should be (true)
72 | }
73 |
74 | it should "validate an array property with string" in {
75 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/propertyWithStringArray.json").mkString
76 | val data = JsonLoader.fromString(json)
77 | val report = jsonSchema.validate(data)
78 | if(report.isSuccess == false)
79 | println(report)
80 | report.isSuccess should be (true)
81 | }
82 |
83 | it should "validate an array property with int32" in {
84 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/propertyWithInt32Array.json").mkString
85 | val data = JsonLoader.fromString(json)
86 | val report = jsonSchema.validate(data)
87 | if(report.isSuccess == false)
88 | println(report)
89 | report.isSuccess should be (true)
90 | }
91 |
92 | it should "validate an array property with int64" in {
93 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/propertyWithInt64Array.json").mkString
94 | val data = JsonLoader.fromString(json)
95 | val report = jsonSchema.validate(data)
96 | if(report.isSuccess == false)
97 | println(report)
98 | report.isSuccess should be (true)
99 | }
100 |
101 | it should "validate an array property with boolean" in {
102 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/propertyWithBooleanArray.json").mkString
103 | val data = JsonLoader.fromString(json)
104 | val report = jsonSchema.validate(data)
105 | if(report.isSuccess == false)
106 | println(report)
107 | report.isSuccess should be (true)
108 | }
109 |
110 | it should "validate an array property with byte" in {
111 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/propertyWithByteArray.json").mkString
112 | val data = JsonLoader.fromString(json)
113 | val report = jsonSchema.validate(data)
114 | if(report.isSuccess == false)
115 | println(report)
116 | report.isSuccess should be (true)
117 | }
118 |
119 | it should "validate an array property with date-time" in {
120 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/propertyWithDateTimeArray.json").mkString
121 | val data = JsonLoader.fromString(json)
122 | val report = jsonSchema.validate(data)
123 | if(report.isSuccess == false)
124 | println(report)
125 | report.isSuccess should be (true)
126 | }
127 |
128 | it should "validate an array property with complex type" in {
129 | val json = Source.fromFile("fixtures/v2.0/json/models/properties/propertyWithComplexArray.json").mkString
130 | val data = JsonLoader.fromString(json)
131 | val report = jsonSchema.validate(data)
132 | if(report.isSuccess == false)
133 | println(report)
134 | report.isSuccess should be (true)
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/test/scala/ResourcesTest.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.JsonNode
2 | import com.github.fge.jsonschema.core.exceptions.ProcessingException
3 | import com.github.fge.jsonschema.main.{ JsonSchema, JsonSchemaFactory}
4 | import com.github.fge.jsonschema.core.report.ProcessingReport
5 | import com.github.fge.jackson.JsonLoader
6 |
7 | import scala.io.Source
8 |
9 | import org.junit.runner.RunWith
10 | import org.scalatest.junit.JUnitRunner
11 | import org.scalatest.FlatSpec
12 | import org.scalatest.matchers.ShouldMatchers
13 |
14 | @RunWith(classOf[JUnitRunner])
15 | class ResourcesTest extends FlatSpec with ShouldMatchers with TestBase {
16 | val schema = readSchema(true)
17 | val factory = JsonSchemaFactory.byDefault()
18 | val jsonSchema = factory.getJsonSchema(schema)
19 |
20 | it should "validate a resource with string path param" in {
21 | val json = Source.fromFile("fixtures/v2.0/json/resources/stringPathParamResource.json").mkString
22 | val data = JsonLoader.fromString(json)
23 | val report = jsonSchema.validate(data)
24 | if(report.isSuccess == false)
25 | println(report)
26 | report.isSuccess should be (true)
27 | }
28 |
29 | it should "validate a spec with common params" in {
30 | val json = Source.fromFile("fixtures/v2.0/json/resources/commonParameters.json").mkString
31 | val data = JsonLoader.fromString(json)
32 | val report = jsonSchema.validate(data)
33 | if(report.isSuccess == false)
34 | println(report)
35 | report.isSuccess should be (true)
36 | }
37 |
38 | it should "validate a spec with vendor extensions" in {
39 | val json = Source.fromFile("fixtures/v2.0/json/resources/vendorExtensionExamples.json").mkString
40 | val data = JsonLoader.fromString(json)
41 | val report = jsonSchema.validate(data)
42 | if(report.isSuccess == false)
43 | println(report)
44 | report.isSuccess should be (true)
45 | }
46 |
47 | it should "validate a resource with example payload" in {
48 | val json = Source.fromFile("fixtures/v2.0/json/resources/resourceWithExamplePayload.json").getLines.filter(!_.startsWith("//")).mkString
49 | val data = JsonLoader.fromString(json)
50 | val report = jsonSchema.validate(data)
51 | if(report.isSuccess == false)
52 | println(report)
53 | report.isSuccess should be (true)
54 | }
55 |
56 | it should "validate a resource with cascading schemes" in {
57 | val json = Source.fromFile("fixtures/v2.0/json/resources/cascadingSchemes.json").getLines.filter(!_.startsWith("//")).mkString
58 | val data = JsonLoader.fromString(json)
59 | val report = jsonSchema.validate(data)
60 | if(report.isSuccess == false)
61 | println(report)
62 | report.isSuccess should be (true)
63 | }
64 |
65 | it should "validate a spec with relative host" in {
66 | val json = Source.fromFile("fixtures/v2.0/json/resources/resourceWithRelativeHost.json").mkString
67 | val data = JsonLoader.fromString(json)
68 | val report = jsonSchema.validate(data)
69 | if(report.isSuccess == false)
70 | println(report)
71 | report.isSuccess should be (true)
72 | }
73 |
74 | it should "validate a spec with linked resources" in {
75 | val json = Source.fromFile("fixtures/v2.0/json/resources/resourceWithLinkedDefinitions.json").mkString
76 | val data = JsonLoader.fromString(json)
77 | val report = jsonSchema.validate(data)
78 | if(report.isSuccess == false)
79 | println(report)
80 | report.isSuccess should be (true)
81 | }
82 |
83 | it should "validate a spec with multiple mime types" in {
84 | val json = Source.fromFile("fixtures/v2.0/json/resources/multipleMimeTypes.json").mkString
85 | val data = JsonLoader.fromString(json)
86 | val report = jsonSchema.validate(data)
87 | if(report.isSuccess == false)
88 | println(report)
89 | report.isSuccess should be (true)
90 | }
91 |
92 | it should "validate a spec with security info" in {
93 | val json = Source.fromFile("fixtures/v2.0/json/resources/securityExample.json").mkString
94 | val data = JsonLoader.fromString(json)
95 | val report = jsonSchema.validate(data)
96 | if(report.isSuccess == false)
97 | println(report)
98 | report.isSuccess should be (true)
99 | }
100 |
101 | it should "validate a spec with tag info" in {
102 | val json = Source.fromFile("fixtures/v2.0/json/resources/taggedResource.json").mkString
103 | val data = JsonLoader.fromString(json)
104 | val report = jsonSchema.validate(data)
105 | if(report.isSuccess == false)
106 | println(report)
107 | report.isSuccess should be (true)
108 | }
109 |
110 | it should "validate a spec with reusable parameters" in {
111 | val json = Source.fromFile("fixtures/v2.0/json/resources/reusableParameters.json").mkString
112 | val data = JsonLoader.fromString(json)
113 | val report = jsonSchema.validate(data)
114 | if(report.isSuccess == false)
115 | println(report)
116 | report.isSuccess should be (true)
117 | }
118 |
119 | it should "validate the swagger petstore" in {
120 | val json = Source.fromFile("examples/v2.0/json/petstore.json").mkString
121 | val data = JsonLoader.fromString(json)
122 | val report = jsonSchema.validate(data)
123 | if(report.isSuccess == false)
124 | println(report)
125 | report.isSuccess should be (true)
126 | }
127 |
128 | it should "validate the swagger petstore with external docs" in {
129 | val json = Source.fromFile("examples/v2.0/json/petstore-with-external-docs.json").mkString
130 | val data = JsonLoader.fromString(json)
131 | val report = jsonSchema.validate(data)
132 | if(report.isSuccess == false)
133 | println(report)
134 | report.isSuccess should be (true)
135 | }
136 |
137 | it should "validate mads sample 1" in {
138 | val json = Source.fromFile("examples/v2.0/json/petstore-simple.json").getLines.filter(!_.startsWith("//")).mkString
139 | val data = JsonLoader.fromString(json)
140 | val report = jsonSchema.validate(data)
141 | if(report.isSuccess == false)
142 | println(report)
143 | report.isSuccess should be (true)
144 | }
145 |
146 | it should "validate mads sample 2" in {
147 | val json = Source.fromFile("examples/v2.0/json/petstore-expanded.json").getLines.filter(!_.startsWith("//")).mkString
148 | val data = JsonLoader.fromString(json)
149 | val report = jsonSchema.validate(data)
150 | if(report.isSuccess == false)
151 | println(report)
152 | report.isSuccess should be (true)
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/src/test/scala/ResponseTest.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.JsonNode
2 | import com.github.fge.jsonschema.core.exceptions.ProcessingException
3 | import com.github.fge.jsonschema.main.{ JsonSchema, JsonSchemaFactory}
4 | import com.github.fge.jsonschema.core.report.ProcessingReport
5 | import com.github.fge.jackson.JsonLoader
6 |
7 | import scala.io.Source
8 |
9 | import org.junit.runner.RunWith
10 | import org.scalatest.junit.JUnitRunner
11 | import org.scalatest.FlatSpec
12 | import org.scalatest.matchers.ShouldMatchers
13 |
14 | @RunWith(classOf[JUnitRunner])
15 | class ResponseTest extends FlatSpec with ShouldMatchers with TestBase {
16 | val schema = readSchema(true)
17 | val factory = JsonSchemaFactory.byDefault()
18 | val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("response"))
19 |
20 | it should "validate a string response" in {
21 | val json = Source.fromFile("fixtures/v2.0/json/responses/stringResponse.json").mkString
22 | val data = JsonLoader.fromString(json)
23 | val report = jsonSchema.validate(data)
24 | if(report.isSuccess == false)
25 | println(report)
26 | report.isSuccess should be (true)
27 | }
28 |
29 | it should "validate an int32 response" in {
30 | val json = Source.fromFile("fixtures/v2.0/json/responses/int32Response.json").mkString
31 | val data = JsonLoader.fromString(json)
32 | val report = jsonSchema.validate(data)
33 | if(report.isSuccess == false)
34 | println(report)
35 | report.isSuccess should be (true)
36 | }
37 |
38 | it should "validate an int64 response" in {
39 | val json = Source.fromFile("fixtures/v2.0/json/responses/int64Response.json").mkString
40 | val data = JsonLoader.fromString(json)
41 | val report = jsonSchema.validate(data)
42 | if(report.isSuccess == false)
43 | println(report)
44 | report.isSuccess should be (true)
45 | }
46 |
47 | it should "validate an date-time response" in {
48 | val json = Source.fromFile("fixtures/v2.0/json/responses/dateTimeResponse.json").mkString
49 | val data = JsonLoader.fromString(json)
50 | val report = jsonSchema.validate(data)
51 | if(report.isSuccess == false)
52 | println(report)
53 | report.isSuccess should be (true)
54 | }
55 |
56 | it should "validate a void response" in {
57 | val json = Source.fromFile("fixtures/v2.0/json/responses/voidResponse.json").mkString
58 | val data = JsonLoader.fromString(json)
59 | val report = jsonSchema.validate(data)
60 | if(report.isSuccess == false)
61 | println(report)
62 | report.isSuccess should be (true)
63 | }
64 |
65 | it should "validate a string array response" in {
66 | val json = Source.fromFile("fixtures/v2.0/json/responses/stringArrayResponse.json").mkString
67 | val data = JsonLoader.fromString(json)
68 | val report = jsonSchema.validate(data)
69 | if(report.isSuccess == false)
70 | println(report)
71 | report.isSuccess should be (true)
72 | }
73 |
74 | it should "validate a complex array response" in {
75 | val json = Source.fromFile("fixtures/v2.0/json/responses/complexArrayResponse.json").mkString
76 | val data = JsonLoader.fromString(json)
77 | val report = jsonSchema.validate(data)
78 | if(report.isSuccess == false)
79 | println(report)
80 | report.isSuccess should be (true)
81 | }
82 |
83 | it should "validate a string response with header" in {
84 | val json = Source.fromFile("fixtures/v2.0/json/responses/stringResponseWithHeader.json").mkString
85 | val data = JsonLoader.fromString(json)
86 | val report = jsonSchema.validate(data)
87 | if(report.isSuccess == false)
88 | println(report)
89 | report.isSuccess should be (true)
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/test/scala/ResponsesTest.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.JsonNode
2 | import com.github.fge.jsonschema.core.exceptions.ProcessingException
3 | import com.github.fge.jsonschema.main.{ JsonSchema, JsonSchemaFactory}
4 | import com.github.fge.jsonschema.core.report.ProcessingReport
5 | import com.github.fge.jackson.JsonLoader
6 |
7 | import scala.io.Source
8 |
9 | import org.junit.runner.RunWith
10 | import org.scalatest.junit.JUnitRunner
11 | import org.scalatest.FlatSpec
12 | import org.scalatest.matchers.ShouldMatchers
13 |
14 | @RunWith(classOf[JUnitRunner])
15 | class ResponsesTest extends FlatSpec with ShouldMatchers with TestBase {
16 | val schema = readSchema(true)
17 | val factory = JsonSchemaFactory.byDefault()
18 | val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("responses"))
19 |
20 | it should "validate multiple responses" in {
21 | val json = Source.fromFile("fixtures/v2.0/json/responses/multipleResponses.json").mkString
22 | val data = JsonLoader.fromString(json)
23 | val report = jsonSchema.validate(data)
24 | if(report.isSuccess == false)
25 | println(report)
26 | report.isSuccess should be (true)
27 | }
28 |
29 | // Negative tests
30 |
31 | it should "fail validation on no responses" in {
32 | val json = Source.fromFile("fixtures/v2.0/json/responses/negative/noResponses.json").mkString
33 | val data = JsonLoader.fromString(json)
34 | val report = jsonSchema.validate(data)
35 | report.isSuccess should be (false)
36 | }
37 |
38 | it should "fail validation on no responses with vendor extension" in {
39 | val json = Source.fromFile("fixtures/v2.0/json/responses/negative/noResponsesWithVendorExtension.json").mkString
40 | val data = JsonLoader.fromString(json)
41 | val report = jsonSchema.validate(data)
42 | report.isSuccess should be (false)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/scala/TestBase.scala:
--------------------------------------------------------------------------------
1 | import com.fasterxml.jackson.databind.ObjectMapper
2 |
3 | import scala.io.Source
4 |
5 | /**
6 | * makes the schemas absolute so the java json-schema validator can locate
7 | * references correctly
8 | **/
9 | trait TestBase {
10 | val mapper = new ObjectMapper
11 | val host = "http://swagger.io/v2/schema.json"
12 | // val host = "http://localhost:8000/schema.json"
13 |
14 | def readSchema(makeQualified: Boolean = true) = {
15 | val json = Source.fromFile("schemas/v2.0/schema.json").getLines
16 | val lines = {
17 | if(makeQualified) {
18 | for(line <- json) yield {
19 | line.replace("\"#/definitions", "\"" + host + "#/definitions")
20 | }
21 | }
22 | else json
23 | }.mkString
24 | mapper.readTree(lines)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/swagger-logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/od2016/OpenAPI-Specification/d3b582593a1f6092c8666ad7c893ae5e12779ec7/swagger-logo.jpg
--------------------------------------------------------------------------------
/test/validate.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 | var path = require('path');
3 |
4 | var _ = require('lodash');
5 | var glob = require('glob');
6 | var yaml = require('js-yaml');
7 | var ZSchema = require('z-schema');
8 | var expect = require('chai').expect;
9 | var RefParser = require('json-schema-ref-parser');
10 |
11 | var schema = require('../schemas/v2.0/schema.json');
12 |
13 | function validate(data) {
14 | var validator = new ZSchema();
15 | validator.validate(data, schema);
16 | var error = validator.getLastError();
17 | error = JSON.stringify(error, null, 2);
18 | expect(error).to.deep.equal('null');
19 | }
20 |
21 | function readFile(file, isYaml) {
22 | var ext = path.extname(file);
23 | var data = fs.readFileSync(file, 'utf8');
24 |
25 | expect(ext).to.be.oneOf(['.json', '.yaml']);
26 | if (ext === '.yaml')
27 | return yaml.safeLoad(data);
28 | else if (ext === '.json')
29 | return JSON.parse(data);
30 | }
31 |
32 | function validateFiles(pattern) {
33 | files = glob.sync(pattern)
34 | files.forEach(function(file) {
35 | it("should validate " + file, function() {
36 | var swagger = readFile(file);
37 |
38 | expect(swagger).to.be.an('object');
39 | if (_.isUndefined(swagger.swagger))
40 | return;
41 |
42 | validate(swagger);
43 |
44 | return RefParser.dereference(file, {
45 | $refs: {
46 | internal: false // Don't dereference internal $refs, only external
47 | }
48 | })
49 | .then(function(resolveSwagger) {
50 | validate(resolveSwagger);
51 | });
52 | })
53 | })
54 | }
55 |
56 | describe('JSON Samples', function() {
57 | validateFiles('./examples/**/*.json')
58 | })
59 |
60 | describe('YAML Samples', function() {
61 | validateFiles('./examples/**/*.yaml')
62 | })
63 |
--------------------------------------------------------------------------------
/test/validate_spec.rb:
--------------------------------------------------------------------------------
1 | require 'json-schema'
2 | require 'json'
3 | require 'yaml'
4 |
5 | schema = JSON.parse(File.read('schemas/v2.0/schema.json'))
6 | Dir['examples/**/*.json'].each do |file|
7 | puts "Validating: #{file}"
8 | data = File.read file
9 | # require 'pry'; binding.pry
10 | puts JSON::Validator.fully_validate(schema, data, :validate_schema => true)
11 | end
12 |
13 | Dir['examples/**/*.yaml'].each do |file|
14 | puts "Validating: #{file}"
15 | data = YAML.load(File.read file)
16 | # require 'pry'; binding.pry
17 | puts JSON::Validator.fully_validate(schema, data, :validate_schema => true)
18 | end
19 |
--------------------------------------------------------------------------------