Skip to content

Commit afe6f16

Browse files
committed
Test update and summary/description fix
Summary is only filled using javadoc if there is no description from annotation. Failing test update (missing summary or schema description and ordering).
1 parent 1371a29 commit afe6f16

File tree

140 files changed

+1453
-340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+1453
-340
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,16 @@ protected void calculatePath(HandlerMethod handlerMethod, RouterOperation router
463463
// get javadoc method description
464464
if (javadocProvider != null) {
465465
String description = javadocProvider.getMethodJavadocDescription(handlerMethod.getMethod());
466-
if (!StringUtils.isEmpty(description)
467-
&& StringUtils.isEmpty(operation.getDescription())) {
466+
String summary = javadocProvider.getFirstSentence(description);
467+
boolean emptyOverrideDescription = StringUtils.isEmpty(operation.getDescription());
468+
boolean emptyOverrideSummary = StringUtils.isEmpty(operation.getSummary());
469+
if (!StringUtils.isEmpty(description) && emptyOverrideDescription) {
468470
operation.setDescription(description);
469471
}
470-
String summary = javadocProvider.getFirstSentence(description);
471-
if (!StringUtils.isEmpty(summary)
472-
&& StringUtils.isEmpty(operation.getSummary())) {
472+
// if there is a previously set description
473+
// but no summary then it is intentional
474+
// we keep it as is
475+
if (!StringUtils.isEmpty(summary) && emptyOverrideSummary && emptyOverrideDescription) {
473476
operation.setSummary(javadocProvider.getFirstSentence(description));
474477
}
475478
}

springdoc-openapi-javadoc/src/test/resources/results/app1.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
"tags": [
213213
"items"
214214
],
215+
"summary": "Show items list.",
215216
"description": "Show items list.",
216217
"operationId": "showItems",
217218
"parameters": [
@@ -293,6 +294,7 @@
293294
"tags": [
294295
"items"
295296
],
297+
"summary": "Add item response entity.",
296298
"description": "Add item response entity.",
297299
"operationId": "addItem",
298300
"requestBody": {
@@ -494,6 +496,7 @@
494496
"tags": [
495497
"tea"
496498
],
499+
"summary": "Index string.",
497500
"description": "Index string.",
498501
"operationId": "index",
499502
"parameters": [
@@ -554,7 +557,8 @@
554557
"type": "string",
555558
"description": "The Message."
556559
}
557-
}
560+
},
561+
"description": "The type Error message."
558562
},
559563
"PersonDTO": {
560564
"type": "object",
@@ -571,7 +575,8 @@
571575
"type": "string",
572576
"description": "The Last name."
573577
}
574-
}
578+
},
579+
"description": "The type Person dto."
575580
},
576581
"ItemLightDTO": {
577582
"type": "object",
@@ -591,7 +596,8 @@
591596
"format": "int32",
592597
"deprecated": true
593598
}
594-
}
599+
},
600+
"description": "The type Item light dto."
595601
},
596602
"InventoryItem": {
597603
"required": [
@@ -621,7 +627,8 @@
621627
"manufacturer": {
622628
"$ref": "#/components/schemas/Manufacturer"
623629
}
624-
}
630+
},
631+
"description": "InventoryItem"
625632
},
626633
"Manufacturer": {
627634
"required": [
@@ -644,7 +651,8 @@
644651
"description": "The Phone.",
645652
"example": "408-867-5309"
646653
}
647-
}
654+
},
655+
"description": "Manufacturer"
648656
},
649657
"ItemDTO": {
650658
"type": "object",
@@ -668,7 +676,8 @@
668676
"format": "int32",
669677
"deprecated": true
670678
}
671-
}
679+
},
680+
"description": "The type Item dto."
672681
}
673682
},
674683
"securitySchemes": {
@@ -678,4 +687,4 @@
678687
}
679688
}
680689
}
681-
}
690+
}

springdoc-openapi-javadoc/src/test/resources/results/app10.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
"description": "Generated server url"
1111
}
1212
],
13+
"tags": [
14+
{
15+
"name": "hello-controller",
16+
"description": "The type Hello controller."
17+
}
18+
],
1319
"paths": {
1420
"/testreq": {
1521
"get": {
1622
"tags": [
1723
"hello-controller"
1824
],
25+
"summary": "Test request attribute.",
1926
"description": "Test request attribute.",
2027
"operationId": "testRequestAttribute",
2128
"parameters": [
@@ -41,6 +48,7 @@
4148
"tags": [
4249
"hello-controller"
4350
],
51+
"summary": "Test.",
4452
"description": "Test.",
4553
"operationId": "test",
4654
"parameters": [

springdoc-openapi-javadoc/src/test/resources/results/app100.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"hello-ap1",
2626
"hello-ap2"
2727
],
28+
"summary": "Gets all pets.",
2829
"description": "Gets all pets.",
2930
"operationId": "getAllPets",
3031
"parameters": [
@@ -75,8 +76,9 @@
7576
"type": "string",
7677
"description": "The Last name."
7778
}
78-
}
79+
},
80+
"description": "The type Person dto."
7981
}
8082
}
8183
}
82-
}
84+
}

springdoc-openapi-javadoc/src/test/resources/results/app101.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
"description": "Generated server url"
1111
}
1212
],
13+
"tags": [
14+
{
15+
"name": "hello-controller",
16+
"description": "The type Hello controller."
17+
}
18+
],
1319
"paths": {
1420
"/hello": {
1521
"get": {
1622
"tags": [
1723
"hello-controller"
1824
],
25+
"summary": "Hello hello dto.",
1926
"description": "Hello hello dto.",
2027
"operationId": "hello",
2128
"responses": {

springdoc-openapi-javadoc/src/test/resources/results/app102.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
"description": "Generated server url"
1111
}
1212
],
13+
"tags": [
14+
{
15+
"name": "test-controller",
16+
"description": "The type Test controller."
17+
}
18+
],
1319
"paths": {
1420
"/test": {
1521
"get": {
1622
"tags": [
1723
"test-controller"
1824
],
25+
"summary": "Gets test.",
1926
"description": "Gets test.",
2027
"operationId": "getTest",
2128
"parameters": [
@@ -145,7 +152,8 @@
145152
"type": "integer",
146153
"description": "The Param 2."
147154
}
148-
}
155+
},
156+
"description": "The type Nested."
149157
}
150158
}
151159
}

springdoc-openapi-javadoc/src/test/resources/results/app103.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
"description": "Generated server url"
1111
}
1212
],
13+
"tags": [
14+
{
15+
"name": "hello-controller",
16+
"description": "The type Hello controller."
17+
}
18+
],
1319
"paths": {
1420
"/test/103": {
1521
"post": {
1622
"tags": [
1723
"hello-controller"
1824
],
25+
"summary": "Post my request body string.",
1926
"description": "Post my request body string.",
2027
"operationId": "postMyRequestBody",
2128
"requestBody": {
@@ -75,7 +82,8 @@
7582
"description": "The Int param.",
7683
"format": "int32"
7784
}
78-
}
85+
},
86+
"description": "The type Example body."
7987
}
8088
}
8189
}

springdoc-openapi-javadoc/src/test/resources/results/app105-1.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@
257257
"type": "string",
258258
"description": "Order Status"
259259
}
260-
}
260+
},
261+
"description": "The type Order."
261262
}
262263
},
263264
"securitySchemes": {

springdoc-openapi-javadoc/src/test/resources/results/app105-2.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@
425425
"type": "string",
426426
"description": "The Username."
427427
}
428-
}
428+
},
429+
"description": "The type User."
429430
}
430431
},
431432
"securitySchemes": {

springdoc-openapi-javadoc/src/test/resources/results/app105-3.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@
570570
"type": "string",
571571
"description": "The Type."
572572
}
573-
}
573+
},
574+
"description": "The type Model api response."
574575
},
575576
"Pet": {
576577
"required": [
@@ -615,7 +616,8 @@
615616
"$ref": "#/components/schemas/Tag"
616617
}
617618
}
618-
}
619+
},
620+
"description": "The type Pet."
619621
},
620622
"Tag": {
621623
"type": "object",

springdoc-openapi-javadoc/src/test/resources/results/app105-4.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"tags": [
2929
"store"
3030
],
31+
"summary": "Stores.",
3132
"description": "Stores.",
3233
"operationId": "stores",
3334
"parameters": [

springdoc-openapi-javadoc/src/test/resources/results/app106.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
"description": "Generated server url"
1111
}
1212
],
13+
"tags": [
14+
{
15+
"name": "hello-controller",
16+
"description": "The type Hello controller."
17+
}
18+
],
1319
"paths": {
1420
"/": {
1521
"get": {

springdoc-openapi-javadoc/src/test/resources/results/app107.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
"description": "Generated server url"
1111
}
1212
],
13+
"tags": [
14+
{
15+
"name": "hello-controller",
16+
"description": "The type Hello controller."
17+
}
18+
],
1319
"paths": {
1420
"/entity-b": {
1521
"get": {
1622
"tags": [
1723
"hello-controller"
1824
],
25+
"summary": "Gets entity b.",
1926
"description": "Gets entity b.",
2027
"operationId": "getEntityB",
2128
"responses": {
@@ -50,7 +57,8 @@
5057
"type": "string",
5158
"description": "The Field a."
5259
}
53-
}
60+
},
61+
"description": "The type Entity a."
5462
},
5563
"EntityB": {
5664
"required": [
@@ -66,7 +74,8 @@
6674
"entityA": {
6775
"$ref": "#/components/schemas/EntityA"
6876
}
69-
}
77+
},
78+
"description": "The type Entity b."
7079
}
7180
}
7281
}

springdoc-openapi-javadoc/src/test/resources/results/app108.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
"description": "Generated server url"
1111
}
1212
],
13+
"tags": [
14+
{
15+
"name": "hello-controller",
16+
"description": "The type Hello controller."
17+
}
18+
],
1319
"paths": {
1420
"/": {
1521
"post": {
1622
"tags": [
1723
"hello-controller"
1824
],
25+
"summary": "Update action result.",
1926
"description": "Update action result.",
2027
"operationId": "update",
2128
"parameters": [
@@ -73,8 +80,9 @@
7380
"type": "object",
7481
"description": "The Value."
7582
}
76-
}
83+
},
84+
"description": "The type Action result."
7785
}
7886
}
7987
}
80-
}
88+
}

0 commit comments

Comments
 (0)