Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cleaning up samples, parity between yaml and json - Close #559 #389

Merged
merged 2 commits into from
Feb 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions examples/v2.0/json/api-with-examples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This existed in YAML, but not JSON examples.

"swagger": "2.0",
"info": {
"title": "Simple API overview",
"version": "v2"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "200 300 response",
"examples": {
"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}"
}
},
"300": {
"description": "200 300 response",
"examples": {
"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}"
}
}
}
}
},
"/v2": {
"get": {
"operationId": "getVersionDetailsv2",
"summary": "Show API version details",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "200 203 response",
"examples": {
"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}"
}
},
"203": {
"description": "200 203 response",
"examples": {
"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}"
}
}
}
}
}
},
"consumes": [
"application/json"
]
}
2 changes: 1 addition & 1 deletion examples/v2.0/json/petstore-expanded.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@
}
}
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gulp yaml2json stripped linefeeds lots of places.

2 changes: 1 addition & 1 deletion examples/v2.0/json/petstore-separate/common/Error.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"type": "string"
}
}
}
}
2 changes: 1 addition & 1 deletion examples/v2.0/json/petstore-separate/spec/NewPet.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
}
}
]
}
}
2 changes: 1 addition & 1 deletion examples/v2.0/json/petstore-separate/spec/Pet.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"type": "string"
}
}
}
}
2 changes: 1 addition & 1 deletion examples/v2.0/json/petstore-separate/spec/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"type": "integer",
"format": "int32"
}
}
}
2 changes: 1 addition & 1 deletion examples/v2.0/json/petstore-separate/spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@
}
}
}
}
}
39 changes: 17 additions & 22 deletions examples/v2.0/json/petstore-simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"description": "Pet to add to the store",
"required": true,
"schema": {
"$ref": "#/definitions/PetInput"
"$ref": "#/definitions/NewPet"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was never a PetInput.

}
}
],
Expand Down Expand Up @@ -170,33 +170,14 @@
},
"definitions": {
"Pet": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"PetInput": {
"type": "object",
"allOf": [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing inheritance to a believable scenario.

{
"$ref": "#/definitions/Pet"
"$ref": "#/definitions/NewPet"
},
{
"required": [
"name"
"id"
],
"properties": {
"id": {
Expand All @@ -207,6 +188,20 @@
}
]
},
"NewPet": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"ErrorModel": {
"type": "object",
"required": [
Expand Down
43 changes: 17 additions & 26 deletions examples/v2.0/json/petstore-with-external-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,37 +181,14 @@
},
"definitions": {
"Pet": {
"type": "object",
"required": [
"id",
"name"
],
"externalDocs": {
"description": "find more info here",
"url": "https://swagger.io/about"
},
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"NewPet": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/Pet"
"$ref": "#/definitions/NewPet"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same inheritance story as petstore-simple

},
{
"required": [
"name"
"id"
],
"properties": {
"id": {
Expand All @@ -222,6 +199,20 @@
}
]
},
"NewPet": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
},
"tag": {
"type": "string"
}
}
},
"ErrorModel": {
"type": "object",
"required": [
Expand All @@ -239,4 +230,4 @@
}
}
}
}
}
107 changes: 86 additions & 21 deletions examples/v2.0/json/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,99 @@
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"contact": {
"name": "Swagger API Team",
"url": "http://swagger.io"
},
"license": {
"name": "Creative Commons 4.0 International",
"url": "http://creativecommons.org/licenses/by/4.0/"
"name": "MIT"
}
},
"host": "petstore.swagger.io",
"basePath": "/api",
"basePath": "/v1",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/pets": {
"get": {
"tags": [ "Pet Operations" ],
"summary": "finds pets in the system",
"summary": "List all pets",
"operationId": "listPets",
"tags": [
"pets"
],
"parameters": [
{
"name": "limit",
"in": "query",
"description": "How many items to return at one time (max 100)",
"required": false,
"type": "integer",
"format": "int32"
}
],
"responses": {
"200": {
"description": "pet response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
},
"description": "An paged array of pets",
"headers": {
"x-expires": {
"type": "string"
"x-next": {
"type": "string",
"description": "A link to the next page of responses"
}
},
"schema": {
"$ref": "#/definitions/Pets"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"post": {
"summary": "Create a pet",
"operationId": "createPets",
"tags": [
"pets"
],
"responses": {
"201": {
"description": "Null response"
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/pets/{petId}": {
"get": {
"summary": "Info for a specific pet",
"operationId": "showPetById",
"tags": [
"pets"
],
"parameters": [
{
"name": "petId",
"in": "path",
"description": "The id of the pet to retrieve",
"type": "string"
}
],
"responses": {
"200": {
"description": "Expected response to a valid request",
"schema": {
"$ref": "#/definitions/Pets"
}
},
"default": {
Expand All @@ -49,7 +110,6 @@
},
"definitions": {
"Pet": {
"type": "object",
"required": [
"id",
"name"
Expand All @@ -67,8 +127,13 @@
}
}
},
"Pets": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
},
"Error": {
"type": "object",
"required": [
"code",
"message"
Expand All @@ -84,4 +149,4 @@
}
}
}
}
}
Loading