|
6 | 6 | public class SwaggerFeature extends ServerFeature { |
7 | 7 |
|
8 | 8 | { |
9 | | - SwaggerUI.install(this); |
10 | | - |
11 | 9 | use(Pets.class); |
| 10 | + |
| 11 | + new SwaggerUI().install(this); |
12 | 12 | } |
13 | 13 |
|
14 | 14 | @Test |
@@ -47,39 +47,69 @@ public void json() throws Exception { |
47 | 47 | " \"consumes\" : [ \"application/json\" ],\n" + |
48 | 48 | " \"produces\" : [ \"application/json\" ],\n" + |
49 | 49 | " \"paths\" : {\n" + |
50 | | - " \"/pets\" : {\n" + |
| 50 | + " \"/api/pets\" : {\n" + |
51 | 51 | " \"get\" : {\n" + |
52 | 52 | " \"tags\" : [ \"pets\" ],\n" + |
| 53 | + " \"consumes\" : [ \"*/*\" ],\n" + |
| 54 | + " \"produces\" : [ \"*/*\" ],\n" + |
53 | 55 | " \"parameters\" : [ {\n" + |
54 | 56 | " \"name\" : \"size\",\n" + |
55 | 57 | " \"in\" : \"query\",\n" + |
56 | 58 | " \"required\" : false,\n" + |
57 | 59 | " \"type\" : \"integer\",\n" + |
58 | 60 | " \"format\" : \"int32\"\n" + |
59 | | - " } ]\n" + |
| 61 | + " } ],\n" + |
| 62 | + " \"responses\" : {\n" + |
| 63 | + " \"200\" : {\n" + |
| 64 | + " \"description\" : \"Success\",\n" + |
| 65 | + " \"schema\" : {\n" + |
| 66 | + " \"$ref\" : \"#/definitions/IterablePet\"\n" + |
| 67 | + " }\n" + |
| 68 | + " }\n" + |
| 69 | + " }\n" + |
60 | 70 | " },\n" + |
61 | 71 | " \"post\" : {\n" + |
62 | 72 | " \"tags\" : [ \"pets\" ],\n" + |
| 73 | + " \"consumes\" : [ \"*/*\" ],\n" + |
| 74 | + " \"produces\" : [ \"*/*\" ],\n" + |
63 | 75 | " \"parameters\" : [ {\n" + |
64 | 76 | " \"in\" : \"body\",\n" + |
65 | 77 | " \"name\" : \"pet\",\n" + |
66 | 78 | " \"required\" : true,\n" + |
67 | 79 | " \"schema\" : {\n" + |
68 | 80 | " \"$ref\" : \"#/definitions/Pet\"\n" + |
69 | 81 | " }\n" + |
70 | | - " } ]\n" + |
| 82 | + " } ],\n" + |
| 83 | + " \"responses\" : {\n" + |
| 84 | + " \"200\" : {\n" + |
| 85 | + " \"description\" : \"Success\",\n" + |
| 86 | + " \"schema\" : {\n" + |
| 87 | + " \"$ref\" : \"#/definitions/Pet\"\n" + |
| 88 | + " }\n" + |
| 89 | + " }\n" + |
| 90 | + " }\n" + |
71 | 91 | " }\n" + |
72 | 92 | " },\n" + |
73 | | - " \"/pets/{id}\" : {\n" + |
| 93 | + " \"/api/pets/{id}\" : {\n" + |
74 | 94 | " \"get\" : {\n" + |
75 | 95 | " \"tags\" : [ \"pets\" ],\n" + |
| 96 | + " \"consumes\" : [ \"*/*\" ],\n" + |
| 97 | + " \"produces\" : [ \"*/*\" ],\n" + |
76 | 98 | " \"parameters\" : [ {\n" + |
77 | 99 | " \"name\" : \"id\",\n" + |
78 | 100 | " \"in\" : \"path\",\n" + |
79 | 101 | " \"required\" : true,\n" + |
80 | 102 | " \"type\" : \"integer\",\n" + |
81 | 103 | " \"format\" : \"int32\"\n" + |
82 | | - " } ]\n" + |
| 104 | + " } ],\n" + |
| 105 | + " \"responses\" : {\n" + |
| 106 | + " \"200\" : {\n" + |
| 107 | + " \"description\" : \"Success\",\n" + |
| 108 | + " \"schema\" : {\n" + |
| 109 | + " \"$ref\" : \"#/definitions/Pet\"\n" + |
| 110 | + " }\n" + |
| 111 | + " }\n" + |
| 112 | + " }\n" + |
83 | 113 | " }\n" + |
84 | 114 | " }\n" + |
85 | 115 | " },\n" + |
@@ -114,39 +144,69 @@ public void json() throws Exception { |
114 | 144 | " \"consumes\" : [ \"application/json\" ],\n" + |
115 | 145 | " \"produces\" : [ \"application/json\" ],\n" + |
116 | 146 | " \"paths\" : {\n" + |
117 | | - " \"/pets\" : {\n" + |
| 147 | + " \"/api/pets\" : {\n" + |
118 | 148 | " \"get\" : {\n" + |
119 | 149 | " \"tags\" : [ \"pets\" ],\n" + |
| 150 | + " \"consumes\" : [ \"*/*\" ],\n" + |
| 151 | + " \"produces\" : [ \"*/*\" ],\n" + |
120 | 152 | " \"parameters\" : [ {\n" + |
121 | 153 | " \"name\" : \"size\",\n" + |
122 | 154 | " \"in\" : \"query\",\n" + |
123 | 155 | " \"required\" : false,\n" + |
124 | 156 | " \"type\" : \"integer\",\n" + |
125 | 157 | " \"format\" : \"int32\"\n" + |
126 | | - " } ]\n" + |
| 158 | + " } ],\n" + |
| 159 | + " \"responses\" : {\n" + |
| 160 | + " \"200\" : {\n" + |
| 161 | + " \"description\" : \"Success\",\n" + |
| 162 | + " \"schema\" : {\n" + |
| 163 | + " \"$ref\" : \"#/definitions/IterablePet\"\n" + |
| 164 | + " }\n" + |
| 165 | + " }\n" + |
| 166 | + " }\n" + |
127 | 167 | " },\n" + |
128 | 168 | " \"post\" : {\n" + |
129 | 169 | " \"tags\" : [ \"pets\" ],\n" + |
| 170 | + " \"consumes\" : [ \"*/*\" ],\n" + |
| 171 | + " \"produces\" : [ \"*/*\" ],\n" + |
130 | 172 | " \"parameters\" : [ {\n" + |
131 | 173 | " \"in\" : \"body\",\n" + |
132 | 174 | " \"name\" : \"pet\",\n" + |
133 | 175 | " \"required\" : true,\n" + |
134 | 176 | " \"schema\" : {\n" + |
135 | 177 | " \"$ref\" : \"#/definitions/Pet\"\n" + |
136 | 178 | " }\n" + |
137 | | - " } ]\n" + |
| 179 | + " } ],\n" + |
| 180 | + " \"responses\" : {\n" + |
| 181 | + " \"200\" : {\n" + |
| 182 | + " \"description\" : \"Success\",\n" + |
| 183 | + " \"schema\" : {\n" + |
| 184 | + " \"$ref\" : \"#/definitions/Pet\"\n" + |
| 185 | + " }\n" + |
| 186 | + " }\n" + |
| 187 | + " }\n" + |
138 | 188 | " }\n" + |
139 | 189 | " },\n" + |
140 | | - " \"/pets/{id}\" : {\n" + |
| 190 | + " \"/api/pets/{id}\" : {\n" + |
141 | 191 | " \"get\" : {\n" + |
142 | 192 | " \"tags\" : [ \"pets\" ],\n" + |
| 193 | + " \"consumes\" : [ \"*/*\" ],\n" + |
| 194 | + " \"produces\" : [ \"*/*\" ],\n" + |
143 | 195 | " \"parameters\" : [ {\n" + |
144 | 196 | " \"name\" : \"id\",\n" + |
145 | 197 | " \"in\" : \"path\",\n" + |
146 | 198 | " \"required\" : true,\n" + |
147 | 199 | " \"type\" : \"integer\",\n" + |
148 | 200 | " \"format\" : \"int32\"\n" + |
149 | | - " } ]\n" + |
| 201 | + " } ],\n" + |
| 202 | + " \"responses\" : {\n" + |
| 203 | + " \"200\" : {\n" + |
| 204 | + " \"description\" : \"Success\",\n" + |
| 205 | + " \"schema\" : {\n" + |
| 206 | + " \"$ref\" : \"#/definitions/Pet\"\n" + |
| 207 | + " }\n" + |
| 208 | + " }\n" + |
| 209 | + " }\n" + |
150 | 210 | " }\n" + |
151 | 211 | " }\n" + |
152 | 212 | " },\n" + |
@@ -185,35 +245,62 @@ public void yml() throws Exception { |
185 | 245 | "produces:\n" + |
186 | 246 | "- \"application/json\"\n" + |
187 | 247 | "paths:\n" + |
188 | | - " /pets:\n" + |
| 248 | + " /api/pets:\n" + |
189 | 249 | " get:\n" + |
190 | 250 | " tags:\n" + |
191 | 251 | " - \"pets\"\n" + |
| 252 | + " consumes:\n" + |
| 253 | + " - \"*/*\"\n" + |
| 254 | + " produces:\n" + |
| 255 | + " - \"*/*\"\n" + |
192 | 256 | " parameters:\n" + |
193 | 257 | " - name: \"size\"\n" + |
194 | 258 | " in: \"query\"\n" + |
195 | 259 | " required: false\n" + |
196 | 260 | " type: \"integer\"\n" + |
197 | 261 | " format: \"int32\"\n" + |
| 262 | + " responses:\n" + |
| 263 | + " 200:\n" + |
| 264 | + " description: \"Success\"\n" + |
| 265 | + " schema:\n" + |
| 266 | + " $ref: \"#/definitions/IterablePet\"\n" + |
198 | 267 | " post:\n" + |
199 | 268 | " tags:\n" + |
200 | 269 | " - \"pets\"\n" + |
| 270 | + " consumes:\n" + |
| 271 | + " - \"*/*\"\n" + |
| 272 | + " produces:\n" + |
| 273 | + " - \"*/*\"\n" + |
201 | 274 | " parameters:\n" + |
202 | 275 | " - in: \"body\"\n" + |
203 | 276 | " name: \"pet\"\n" + |
204 | 277 | " required: true\n" + |
205 | 278 | " schema:\n" + |
206 | 279 | " $ref: \"#/definitions/Pet\"\n" + |
207 | | - " /pets/{id}:\n" + |
| 280 | + " responses:\n" + |
| 281 | + " 200:\n" + |
| 282 | + " description: \"Success\"\n" + |
| 283 | + " schema:\n" + |
| 284 | + " $ref: \"#/definitions/Pet\"\n" + |
| 285 | + " /api/pets/{id}:\n" + |
208 | 286 | " get:\n" + |
209 | 287 | " tags:\n" + |
210 | 288 | " - \"pets\"\n" + |
| 289 | + " consumes:\n" + |
| 290 | + " - \"*/*\"\n" + |
| 291 | + " produces:\n" + |
| 292 | + " - \"*/*\"\n" + |
211 | 293 | " parameters:\n" + |
212 | 294 | " - name: \"id\"\n" + |
213 | 295 | " in: \"path\"\n" + |
214 | 296 | " required: true\n" + |
215 | 297 | " type: \"integer\"\n" + |
216 | 298 | " format: \"int32\"\n" + |
| 299 | + " responses:\n" + |
| 300 | + " 200:\n" + |
| 301 | + " description: \"Success\"\n" + |
| 302 | + " schema:\n" + |
| 303 | + " $ref: \"#/definitions/Pet\"\n" + |
217 | 304 | "definitions:\n" + |
218 | 305 | " Pet:\n" + |
219 | 306 | " type: \"object\"\n" + |
@@ -241,35 +328,62 @@ public void yml() throws Exception { |
241 | 328 | "produces:\n" + |
242 | 329 | "- \"application/json\"\n" + |
243 | 330 | "paths:\n" + |
244 | | - " /pets:\n" + |
| 331 | + " /api/pets:\n" + |
245 | 332 | " get:\n" + |
246 | 333 | " tags:\n" + |
247 | 334 | " - \"pets\"\n" + |
| 335 | + " consumes:\n" + |
| 336 | + " - \"*/*\"\n" + |
| 337 | + " produces:\n" + |
| 338 | + " - \"*/*\"\n" + |
248 | 339 | " parameters:\n" + |
249 | 340 | " - name: \"size\"\n" + |
250 | 341 | " in: \"query\"\n" + |
251 | 342 | " required: false\n" + |
252 | 343 | " type: \"integer\"\n" + |
253 | 344 | " format: \"int32\"\n" + |
| 345 | + " responses:\n" + |
| 346 | + " 200:\n" + |
| 347 | + " description: \"Success\"\n" + |
| 348 | + " schema:\n" + |
| 349 | + " $ref: \"#/definitions/IterablePet\"\n" + |
254 | 350 | " post:\n" + |
255 | 351 | " tags:\n" + |
256 | 352 | " - \"pets\"\n" + |
| 353 | + " consumes:\n" + |
| 354 | + " - \"*/*\"\n" + |
| 355 | + " produces:\n" + |
| 356 | + " - \"*/*\"\n" + |
257 | 357 | " parameters:\n" + |
258 | 358 | " - in: \"body\"\n" + |
259 | 359 | " name: \"pet\"\n" + |
260 | 360 | " required: true\n" + |
261 | 361 | " schema:\n" + |
262 | 362 | " $ref: \"#/definitions/Pet\"\n" + |
263 | | - " /pets/{id}:\n" + |
| 363 | + " responses:\n" + |
| 364 | + " 200:\n" + |
| 365 | + " description: \"Success\"\n" + |
| 366 | + " schema:\n" + |
| 367 | + " $ref: \"#/definitions/Pet\"\n" + |
| 368 | + " /api/pets/{id}:\n" + |
264 | 369 | " get:\n" + |
265 | 370 | " tags:\n" + |
266 | 371 | " - \"pets\"\n" + |
| 372 | + " consumes:\n" + |
| 373 | + " - \"*/*\"\n" + |
| 374 | + " produces:\n" + |
| 375 | + " - \"*/*\"\n" + |
267 | 376 | " parameters:\n" + |
268 | 377 | " - name: \"id\"\n" + |
269 | 378 | " in: \"path\"\n" + |
270 | 379 | " required: true\n" + |
271 | 380 | " type: \"integer\"\n" + |
272 | 381 | " format: \"int32\"\n" + |
| 382 | + " responses:\n" + |
| 383 | + " 200:\n" + |
| 384 | + " description: \"Success\"\n" + |
| 385 | + " schema:\n" + |
| 386 | + " $ref: \"#/definitions/Pet\"\n" + |
273 | 387 | "definitions:\n" + |
274 | 388 | " Pet:\n" + |
275 | 389 | " type: \"object\"\n" + |
|
0 commit comments