Skip to content

Commit 47a268c

Browse files
committed
Merge pull request #389 from jasonh-n-austin/develop_2.0
Cleaning up samples, parity between yaml and json - Close #559
2 parents 0122c22 + ce4cd99 commit 47a268c

16 files changed

+945
-93
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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-expanded.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,4 @@
207207
}
208208
}
209209
}
210-
}
210+
}

examples/v2.0/json/petstore-separate/common/Error.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
"type": "string"
1414
}
1515
}
16-
}
16+
}

examples/v2.0/json/petstore-separate/spec/NewPet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
}
1717
}
1818
]
19-
}
19+
}

examples/v2.0/json/petstore-separate/spec/Pet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
"type": "string"
1717
}
1818
}
19-
}
19+
}

examples/v2.0/json/petstore-separate/spec/parameters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"type": "integer",
1919
"format": "int32"
2020
}
21-
}
21+
}

examples/v2.0/json/petstore-separate/spec/swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@
143143
}
144144
}
145145
}
146-
}
146+
}

examples/v2.0/json/petstore-simple.json

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"description": "Pet to add to the store",
8787
"required": true,
8888
"schema": {
89-
"$ref": "#/definitions/PetInput"
89+
"$ref": "#/definitions/NewPet"
9090
}
9191
}
9292
],
@@ -170,33 +170,14 @@
170170
},
171171
"definitions": {
172172
"Pet": {
173-
"type": "object",
174-
"required": [
175-
"id",
176-
"name"
177-
],
178-
"properties": {
179-
"id": {
180-
"type": "integer",
181-
"format": "int64"
182-
},
183-
"name": {
184-
"type": "string"
185-
},
186-
"tag": {
187-
"type": "string"
188-
}
189-
}
190-
},
191-
"PetInput": {
192173
"type": "object",
193174
"allOf": [
194175
{
195-
"$ref": "#/definitions/Pet"
176+
"$ref": "#/definitions/NewPet"
196177
},
197178
{
198179
"required": [
199-
"name"
180+
"id"
200181
],
201182
"properties": {
202183
"id": {
@@ -207,6 +188,20 @@
207188
}
208189
]
209190
},
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+
},
210205
"ErrorModel": {
211206
"type": "object",
212207
"required": [

examples/v2.0/json/petstore-with-external-docs.json

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -181,37 +181,14 @@
181181
},
182182
"definitions": {
183183
"Pet": {
184-
"type": "object",
185-
"required": [
186-
"id",
187-
"name"
188-
],
189-
"externalDocs": {
190-
"description": "find more info here",
191-
"url": "https://swagger.io/about"
192-
},
193-
"properties": {
194-
"id": {
195-
"type": "integer",
196-
"format": "int64"
197-
},
198-
"name": {
199-
"type": "string"
200-
},
201-
"tag": {
202-
"type": "string"
203-
}
204-
}
205-
},
206-
"NewPet": {
207184
"type": "object",
208185
"allOf": [
209186
{
210-
"$ref": "#/definitions/Pet"
187+
"$ref": "#/definitions/NewPet"
211188
},
212189
{
213190
"required": [
214-
"name"
191+
"id"
215192
],
216193
"properties": {
217194
"id": {
@@ -222,6 +199,20 @@
222199
}
223200
]
224201
},
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+
},
225216
"ErrorModel": {
226217
"type": "object",
227218
"required": [
@@ -239,4 +230,4 @@
239230
}
240231
}
241232
}
242-
}
233+
}

examples/v2.0/json/petstore.json

Lines changed: 86 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,99 @@
33
"info": {
44
"version": "1.0.0",
55
"title": "Swagger Petstore",
6-
"contact": {
7-
"name": "Swagger API Team",
8-
"url": "http://swagger.io"
9-
},
106
"license": {
11-
"name": "Creative Commons 4.0 International",
12-
"url": "http://creativecommons.org/licenses/by/4.0/"
7+
"name": "MIT"
138
}
149
},
1510
"host": "petstore.swagger.io",
16-
"basePath": "/api",
11+
"basePath": "/v1",
1712
"schemes": [
1813
"http"
1914
],
15+
"consumes": [
16+
"application/json"
17+
],
18+
"produces": [
19+
"application/json"
20+
],
2021
"paths": {
2122
"/pets": {
2223
"get": {
23-
"tags": [ "Pet Operations" ],
24-
"summary": "finds pets in the system",
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+
],
2539
"responses": {
2640
"200": {
27-
"description": "pet response",
28-
"schema": {
29-
"type": "array",
30-
"items": {
31-
"$ref": "#/definitions/Pet"
32-
}
33-
},
41+
"description": "An paged array of pets",
3442
"headers": {
35-
"x-expires": {
36-
"type": "string"
43+
"x-next": {
44+
"type": "string",
45+
"description": "A link to the next page of responses"
3746
}
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+
"description": "The id of the pet to retrieve",
91+
"type": "string"
92+
}
93+
],
94+
"responses": {
95+
"200": {
96+
"description": "Expected response to a valid request",
97+
"schema": {
98+
"$ref": "#/definitions/Pets"
3899
}
39100
},
40101
"default": {
@@ -49,7 +110,6 @@
49110
},
50111
"definitions": {
51112
"Pet": {
52-
"type": "object",
53113
"required": [
54114
"id",
55115
"name"
@@ -67,8 +127,13 @@
67127
}
68128
}
69129
},
130+
"Pets": {
131+
"type": "array",
132+
"items": {
133+
"$ref": "#/definitions/Pet"
134+
}
135+
},
70136
"Error": {
71-
"type": "object",
72137
"required": [
73138
"code",
74139
"message"
@@ -84,4 +149,4 @@
84149
}
85150
}
86151
}
87-
}
152+
}

0 commit comments

Comments
 (0)