Skip to content

Commit bd3d7c6

Browse files
author
bnasslahsen
committed
Duplicate tags if they are defined on @operation annotation on swagger-ui. Fixes #436.
1 parent 85211de commit bd3d7c6

File tree

4 files changed

+71
-75
lines changed

4 files changed

+71
-75
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
189189
operation.setDeprecated(true);
190190
}
191191

192-
// compute tags
193-
operation = openAPIBuilder.buildTags(handlerMethod, operation, openAPI);
194-
195192
// Add documentation from operation annotation
196193
io.swagger.v3.oas.annotations.Operation apiOperation = ReflectionUtils.getAnnotation(method,
197194
io.swagger.v3.oas.annotations.Operation.class);
@@ -202,6 +199,9 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
202199
openAPI = operationParser.parse(components, apiOperation, operation, openAPI, methodAttributes);
203200
}
204201

202+
// compute tags
203+
operation = openAPIBuilder.buildTags(handlerMethod, operation, openAPI);
204+
205205
io.swagger.v3.oas.annotations.parameters.RequestBody requestBodyDoc = ReflectionUtils.getAnnotation(method,
206206
io.swagger.v3.oas.annotations.parameters.RequestBody.class);
207207

springdoc-openapi-webmvc-core/src/test/resources/results/app1.json

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666
"/inventory": {
6767
"get": {
6868
"tags": [
69-
"inventory",
70-
"developers"
69+
"inventory"
7170
],
7271
"summary": "By passing in the appropriate options, you can search for available inventory in the system ",
7372
"description": "searches inventory",
@@ -147,8 +146,7 @@
147146
},
148147
"post": {
149148
"tags": [
150-
"inventory",
151-
"admins"
149+
"inventory"
152150
],
153151
"summary": "Adds an item to the system",
154152
"description": "adds an inventory item",
@@ -288,6 +286,40 @@
288286
}
289287
}
290288
},
289+
"/people": {
290+
"get": {
291+
"tags": [
292+
"people"
293+
],
294+
"description": "List all people",
295+
"operationId": "getPeople",
296+
"responses": {
297+
"500": {
298+
"description": "default response",
299+
"content": {
300+
"*/*": {
301+
"schema": {
302+
"$ref": "#/components/schemas/ErrorMessage"
303+
}
304+
}
305+
}
306+
},
307+
"200": {
308+
"description": "default response",
309+
"content": {
310+
"application/json": {
311+
"schema": {
312+
"type": "array",
313+
"items": {
314+
"$ref": "#/components/schemas/PersonDTO"
315+
}
316+
}
317+
}
318+
}
319+
}
320+
}
321+
}
322+
},
291323
"/{email}": {
292324
"get": {
293325
"tags": [
@@ -307,18 +339,18 @@
307339
}
308340
],
309341
"responses": {
310-
"200": {
342+
"500": {
311343
"description": "default response",
312344
"content": {
313-
"application/json": {
345+
"*/*": {
314346
"schema": {
315-
"$ref": "#/components/schemas/PersonDTO"
347+
"$ref": "#/components/schemas/ErrorMessage"
316348
}
317349
}
318350
}
319351
},
320-
"404": {
321-
"description": "Person with such e-mail doesn't exists",
352+
"200": {
353+
"description": "default response",
322354
"content": {
323355
"application/json": {
324356
"schema": {
@@ -327,12 +359,12 @@
327359
}
328360
}
329361
},
330-
"500": {
331-
"description": "default response",
362+
"404": {
363+
"description": "Person with such e-mail doesn't exists",
332364
"content": {
333-
"*/*": {
365+
"application/json": {
334366
"schema": {
335-
"$ref": "#/components/schemas/ErrorMessage"
367+
"$ref": "#/components/schemas/PersonDTO"
336368
}
337369
}
338370
}
@@ -375,6 +407,16 @@
375407
}
376408
],
377409
"responses": {
410+
"500": {
411+
"description": "default response",
412+
"content": {
413+
"*/*": {
414+
"schema": {
415+
"$ref": "#/components/schemas/ErrorMessage"
416+
}
417+
}
418+
}
419+
},
378420
"201": {
379421
"description": "default response",
380422
"headers": {
@@ -402,16 +444,6 @@
402444
}
403445
}
404446
}
405-
},
406-
"500": {
407-
"description": "default response",
408-
"content": {
409-
"*/*": {
410-
"schema": {
411-
"$ref": "#/components/schemas/ErrorMessage"
412-
}
413-
}
414-
}
415447
}
416448
}
417449
},
@@ -433,26 +465,6 @@
433465
}
434466
],
435467
"responses": {
436-
"204": {
437-
"description": "Person has been deleted",
438-
"content": {
439-
"*/*": {
440-
"schema": {
441-
"type": "string"
442-
}
443-
}
444-
}
445-
},
446-
"404": {
447-
"description": "Person with such e-mail doesn't exists",
448-
"content": {
449-
"*/*": {
450-
"schema": {
451-
"type": "string"
452-
}
453-
}
454-
}
455-
},
456468
"500": {
457469
"description": "default response",
458470
"content": {
@@ -462,37 +474,23 @@
462474
}
463475
}
464476
}
465-
}
466-
}
467-
}
468-
},
469-
"/people": {
470-
"get": {
471-
"tags": [
472-
"people"
473-
],
474-
"description": "List all people",
475-
"operationId": "getPeople",
476-
"responses": {
477-
"200": {
478-
"description": "default response",
477+
},
478+
"204": {
479+
"description": "Person has been deleted",
479480
"content": {
480-
"application/json": {
481+
"*/*": {
481482
"schema": {
482-
"type": "array",
483-
"items": {
484-
"$ref": "#/components/schemas/PersonDTO"
485-
}
483+
"type": "string"
486484
}
487485
}
488486
}
489487
},
490-
"500": {
491-
"description": "default response",
488+
"404": {
489+
"description": "Person with such e-mail doesn't exists",
492490
"content": {
493491
"*/*": {
494492
"schema": {
495-
"$ref": "#/components/schemas/ErrorMessage"
493+
"type": "string"
496494
}
497495
}
498496
}
@@ -561,12 +559,9 @@
561559
}
562560
}
563561
},
564-
"ItemDTO": {
562+
"ItemLightDTO": {
565563
"type": "object",
566564
"properties": {
567-
"itemID": {
568-
"type": "string"
569-
},
570565
"description": {
571566
"type": "string"
572567
},
@@ -576,9 +571,12 @@
576571
}
577572
}
578573
},
579-
"ItemLightDTO": {
574+
"ItemDTO": {
580575
"type": "object",
581576
"properties": {
577+
"itemID": {
578+
"type": "string"
579+
},
582580
"description": {
583581
"type": "string"
584582
},

springdoc-openapi-webmvc-core/src/test/resources/results/app21.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"/persons": {
1515
"get": {
1616
"tags": [
17-
"hello-controller",
1817
"person"
1918
],
2019
"summary": "Add a new person to the store",

springdoc-openapi-webmvc-core/src/test/resources/results/app46.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"/persons/{subscriptionId}": {
1515
"get": {
1616
"tags": [
17-
"hello-controller",
1817
"Example Tag"
1918
],
2019
"summary": "Operation Summary",

0 commit comments

Comments
 (0)