Skip to content

Commit c2cab84

Browse files
committed
fix typo, update sinatra to use origianl petstore spec (yaml)
1 parent aa805a4 commit c2cab84

File tree

7 files changed

+180
-315
lines changed

7 files changed

+180
-315
lines changed

bin/sinatra-petstore-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ fi
2626

2727
# if you've executed sbt assembly previously it will use that instead.
2828
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="$@ generate -t modules/swagger-codegen/src/main/resources/sinatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l sinatra -o samples/server/petstore/sinatra"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/sinatra -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l sinatra -o samples/server/petstore/sinatra"
3030

3131
java $JAVA_OPTS -jar $executable $ags

modules/swagger-codegen/src/test/resources/2_0/petstore.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@
13011301
}
13021302
},
13031303
"Return": {
1304-
"descripton": "Model for testing reserved words",
1304+
"description": "Model for testing reserved words",
13051305
"properties": {
13061306
"return": {
13071307
"type": "integer",
@@ -1313,7 +1313,7 @@
13131313
}
13141314
},
13151315
"Name": {
1316-
"descripton": "Model for testing model name same as property name",
1316+
"description": "Model for testing model name same as property name",
13171317
"properties": {
13181318
"name": {
13191319
"type": "integer",
@@ -1329,7 +1329,7 @@
13291329
}
13301330
},
13311331
"200_response": {
1332-
"descripton": "Model for testing model name starting with number",
1332+
"description": "Model for testing model name starting with number",
13331333
"properties": {
13341334
"name": {
13351335
"type": "integer",

samples/server/petstore/sinatra/api/pet_api.rb

Lines changed: 42 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
require 'json'
22

33

4-
MyApp.add_route('PUT', '/v2/pet', {
4+
MyApp.add_route('POST', '/v2/pets', {
55
"resourcePath" => "/Pet",
6-
"summary" => "Update an existing pet",
7-
"nickname" => "update_pet",
6+
"summary" => "Add a new pet to the store",
7+
"nickname" => "add_pet",
88
"responseClass" => "void",
9-
"endpoint" => "/pet",
9+
"endpoint" => "/pets",
1010
"notes" => "",
1111
"parameters" => [
1212

@@ -28,24 +28,31 @@
2828
end
2929

3030

31-
MyApp.add_route('POST', '/v2/pet', {
31+
MyApp.add_route('DELETE', '/v2/pets/{petId}', {
3232
"resourcePath" => "/Pet",
33-
"summary" => "Add a new pet to the store",
34-
"nickname" => "add_pet",
33+
"summary" => "Deletes a pet",
34+
"nickname" => "delete_pet",
3535
"responseClass" => "void",
36-
"endpoint" => "/pet",
36+
"endpoint" => "/pets/{petId}",
3737
"notes" => "",
3838
"parameters" => [
3939

4040

41+
{
42+
"name" => "pet_id",
43+
"description" => "Pet id to delete",
44+
"dataType" => "int",
45+
"paramType" => "path",
46+
},
4147

4248

4349
{
44-
"name" => "body",
45-
"description" => "Pet object that needs to be added to the store",
46-
"dataType" => "Pet",
47-
"paramType" => "body",
48-
}
50+
"name" => "api_key",
51+
"description" => "",
52+
"dataType" => "string",
53+
"paramType" => "header",
54+
},
55+
4956

5057
]}) do
5158
cross_origin
@@ -55,12 +62,12 @@
5562
end
5663

5764

58-
MyApp.add_route('GET', '/v2/pet/findByStatus', {
65+
MyApp.add_route('GET', '/v2/pets/findByStatus', {
5966
"resourcePath" => "/Pet",
6067
"summary" => "Finds Pets by status",
6168
"nickname" => "find_pets_by_status",
6269
"responseClass" => "array[Pet]",
63-
"endpoint" => "/pet/findByStatus",
70+
"endpoint" => "/pets/findByStatus",
6471
"notes" => "Multiple status values can be provided with comma seperated strings",
6572
"parameters" => [
6673

@@ -71,7 +78,7 @@
7178
"paramType" => "query",
7279
"collectionFormat" => "multi",
7380
"allowableValues" => "",
74-
"defaultValue" => "available"
81+
7582
},
7683

7784

@@ -85,12 +92,12 @@
8592
end
8693

8794

88-
MyApp.add_route('GET', '/v2/pet/findByTags', {
95+
MyApp.add_route('GET', '/v2/pets/findByTags', {
8996
"resourcePath" => "/Pet",
9097
"summary" => "Finds Pets by tags",
9198
"nickname" => "find_pets_by_tags",
9299
"responseClass" => "array[Pet]",
93-
"endpoint" => "/pet/findByTags",
100+
"endpoint" => "/pets/findByTags",
94101
"notes" => "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
95102
"parameters" => [
96103

@@ -115,12 +122,12 @@
115122
end
116123

117124

118-
MyApp.add_route('GET', '/v2/pet/{petId}', {
125+
MyApp.add_route('GET', '/v2/pets/{petId}', {
119126
"resourcePath" => "/Pet",
120127
"summary" => "Find pet by ID",
121128
"nickname" => "get_pet_by_id",
122129
"responseClass" => "Pet",
123-
"endpoint" => "/pet/{petId}",
130+
"endpoint" => "/pets/{petId}",
124131
"notes" => "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
125132
"parameters" => [
126133

@@ -142,58 +149,24 @@
142149
end
143150

144151

145-
MyApp.add_route('POST', '/v2/pet/{petId}', {
152+
MyApp.add_route('PUT', '/v2/pets', {
146153
"resourcePath" => "/Pet",
147-
"summary" => "Updates a pet in the store with form data",
148-
"nickname" => "update_pet_with_form",
149-
"responseClass" => "void",
150-
"endpoint" => "/pet/{petId}",
151-
"notes" => "",
152-
"parameters" => [
153-
154-
155-
{
156-
"name" => "pet_id",
157-
"description" => "ID of pet that needs to be updated",
158-
"dataType" => "string",
159-
"paramType" => "path",
160-
},
161-
162-
163-
164-
]}) do
165-
cross_origin
166-
# the guts live here
167-
168-
{"message" => "yes, it worked"}.to_json
169-
end
170-
171-
172-
MyApp.add_route('DELETE', '/v2/pet/{petId}', {
173-
"resourcePath" => "/Pet",
174-
"summary" => "Deletes a pet",
175-
"nickname" => "delete_pet",
154+
"summary" => "Update an existing pet",
155+
"nickname" => "update_pet",
176156
"responseClass" => "void",
177-
"endpoint" => "/pet/{petId}",
157+
"endpoint" => "/pets",
178158
"notes" => "",
179159
"parameters" => [
180160

181161

182-
{
183-
"name" => "pet_id",
184-
"description" => "Pet id to delete",
185-
"dataType" => "int",
186-
"paramType" => "path",
187-
},
188162

189163

190164
{
191-
"name" => "api_key",
192-
"description" => "",
193-
"dataType" => "string",
194-
"paramType" => "header",
195-
},
196-
165+
"name" => "body",
166+
"description" => "Pet object that needs to be added to the store",
167+
"dataType" => "Pet",
168+
"paramType" => "body",
169+
}
197170

198171
]}) do
199172
cross_origin
@@ -203,20 +176,20 @@
203176
end
204177

205178

206-
MyApp.add_route('POST', '/v2/pet/{petId}/uploadImage', {
179+
MyApp.add_route('POST', '/v2/pets/{petId}', {
207180
"resourcePath" => "/Pet",
208-
"summary" => "uploads an image",
209-
"nickname" => "upload_file",
181+
"summary" => "Updates a pet in the store with form data",
182+
"nickname" => "update_pet_with_form",
210183
"responseClass" => "void",
211-
"endpoint" => "/pet/{petId}/uploadImage",
184+
"endpoint" => "/pets/{petId}",
212185
"notes" => "",
213186
"parameters" => [
214187

215188

216189
{
217190
"name" => "pet_id",
218-
"description" => "ID of pet to update",
219-
"dataType" => "int",
191+
"description" => "ID of pet that needs to be updated",
192+
"dataType" => "string",
220193
"paramType" => "path",
221194
},
222195

samples/server/petstore/sinatra/api/store_api.rb

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,24 @@
11
require 'json'
22

33

4-
MyApp.add_route('GET', '/v2/store/inventory', {
4+
MyApp.add_route('DELETE', '/v2/stores/order/{orderId}', {
55
"resourcePath" => "/Store",
6-
"summary" => "Returns pet inventories by status",
7-
"nickname" => "get_inventory",
8-
"responseClass" => "map[string,int]",
9-
"endpoint" => "/store/inventory",
10-
"notes" => "Returns a map of status codes to quantities",
11-
"parameters" => [
12-
13-
14-
15-
16-
]}) do
17-
cross_origin
18-
# the guts live here
19-
20-
{"message" => "yes, it worked"}.to_json
21-
end
22-
23-
24-
MyApp.add_route('POST', '/v2/store/order', {
25-
"resourcePath" => "/Store",
26-
"summary" => "Place an order for a pet",
27-
"nickname" => "place_order",
28-
"responseClass" => "Order",
29-
"endpoint" => "/store/order",
30-
"notes" => "",
6+
"summary" => "Delete purchase order by ID",
7+
"nickname" => "delete_order",
8+
"responseClass" => "void",
9+
"endpoint" => "/stores/order/{orderId}",
10+
"notes" => "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
3111
"parameters" => [
3212

3313

14+
{
15+
"name" => "order_id",
16+
"description" => "ID of the order that needs to be deleted",
17+
"dataType" => "string",
18+
"paramType" => "path",
19+
},
3420

3521

36-
{
37-
"name" => "body",
38-
"description" => "order placed for purchasing the pet",
39-
"dataType" => "Order",
40-
"paramType" => "body",
41-
}
4222

4323
]}) do
4424
cross_origin
@@ -48,12 +28,12 @@
4828
end
4929

5030

51-
MyApp.add_route('GET', '/v2/store/order/{orderId}', {
31+
MyApp.add_route('GET', '/v2/stores/order/{orderId}', {
5232
"resourcePath" => "/Store",
5333
"summary" => "Find purchase order by ID",
5434
"nickname" => "get_order_by_id",
5535
"responseClass" => "Order",
56-
"endpoint" => "/store/order/{orderId}",
36+
"endpoint" => "/stores/order/{orderId}",
5737
"notes" => "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
5838
"parameters" => [
5939

@@ -75,24 +55,24 @@
7555
end
7656

7757

78-
MyApp.add_route('DELETE', '/v2/store/order/{orderId}', {
58+
MyApp.add_route('POST', '/v2/stores/order', {
7959
"resourcePath" => "/Store",
80-
"summary" => "Delete purchase order by ID",
81-
"nickname" => "delete_order",
82-
"responseClass" => "void",
83-
"endpoint" => "/store/order/{orderId}",
84-
"notes" => "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
60+
"summary" => "Place an order for a pet",
61+
"nickname" => "place_order",
62+
"responseClass" => "Order",
63+
"endpoint" => "/stores/order",
64+
"notes" => "",
8565
"parameters" => [
8666

8767

88-
{
89-
"name" => "order_id",
90-
"description" => "ID of the order that needs to be deleted",
91-
"dataType" => "string",
92-
"paramType" => "path",
93-
},
9468

9569

70+
{
71+
"name" => "body",
72+
"description" => "order placed for purchasing the pet",
73+
"dataType" => "Order",
74+
"paramType" => "body",
75+
}
9676

9777
]}) do
9878
cross_origin

0 commit comments

Comments
 (0)