Skip to content

Commit 2e600c6

Browse files
author
springdoc
committed
fixes #219
1 parent 26943a4 commit 2e600c6

File tree

10 files changed

+268
-6
lines changed

10 files changed

+268
-6
lines changed

springdoc-openapi-webflux-core/src/main/java/org/springdoc/core/ResponseBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ protected Schema calculateSchemaFromParameterizedType(Components components, Par
4444
schemaN = calculateFluxSchema(components, parameterizedType, jsonView);
4545
}
4646
}
47+
else if (ResponseEntity.class.getName().contentEquals(parameterizedType.getRawType().getTypeName())) {
48+
schemaN = calculateSchemaParameterizedType(components, parameterizedType, jsonView);
49+
}
4750
return schemaN;
4851
}
4952

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package test.org.springdoc.api.app65;
2+
3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.tags.Tag;
5+
import org.springframework.http.MediaType;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
@Tag(name = "Health" , description = "Health check / ping API")
11+
@RestController
12+
public class HelloController {
13+
14+
@Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.")
15+
@GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE)
16+
public ResponseEntity<String> ping() {
17+
return ResponseEntity.ok("Healthy");
18+
}
19+
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package test.org.springdoc.api.app65;
2+
3+
import org.junit.AfterClass;
4+
import org.junit.BeforeClass;
5+
import test.org.springdoc.api.AbstractSpringDocTest;
6+
7+
public class SpringDocApp65Test extends AbstractSpringDocTest {
8+
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package test.org.springdoc.api.app65;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.context.annotation.ComponentScan;
6+
7+
@SpringBootApplication
8+
@ComponentScan(basePackages = {"org.springdoc", "test.org.springdoc.api.app65"})
9+
public class SpringDocTestApp {
10+
public static void main(String[] args) {
11+
SpringApplication.run(SpringDocTestApp.class, args);
12+
}
13+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"openapi": "3.0.1",
3+
"info": {
4+
"title": "OpenAPI definition",
5+
"version": "v0"
6+
},
7+
"servers": [
8+
{
9+
"url": "",
10+
"description": "Generated server url"
11+
}
12+
],
13+
"tags": [
14+
{
15+
"name": "Health",
16+
"description": "Health check / ping API"
17+
}
18+
],
19+
"paths": {
20+
"/health": {
21+
"get": {
22+
"tags": [
23+
"Health"
24+
],
25+
"summary": "Check server status",
26+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
27+
"operationId": "ping",
28+
"responses": {
29+
"200": {
30+
"description": "default response",
31+
"content": {
32+
"text/plain": {
33+
"schema": {
34+
"type": "string"
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
},
42+
"/ping": {
43+
"get": {
44+
"tags": [
45+
"Health"
46+
],
47+
"summary": "Check server status",
48+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
49+
"operationId": "ping_1",
50+
"responses": {
51+
"200": {
52+
"description": "default response",
53+
"content": {
54+
"text/plain": {
55+
"schema": {
56+
"type": "string"
57+
}
58+
}
59+
}
60+
}
61+
}
62+
}
63+
},
64+
"/": {
65+
"get": {
66+
"tags": [
67+
"Health"
68+
],
69+
"summary": "Check server status",
70+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
71+
"operationId": "ping_2",
72+
"responses": {
73+
"200": {
74+
"description": "default response",
75+
"content": {
76+
"text/plain": {
77+
"schema": {
78+
"type": "string"
79+
}
80+
}
81+
}
82+
}
83+
}
84+
}
85+
}
86+
},
87+
"components": {}
88+
}

springdoc-openapi-webmvc-core/src/main/java/org/springdoc/api/OpenApiResource.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ private void calculatePath(Map<String, Object> restControllers, Map<RequestMappi
8686
HandlerMethod handlerMethod = entry.getValue();
8787
PatternsRequestCondition patternsRequestCondition = requestMappingInfo.getPatternsCondition();
8888
Set<String> patterns = patternsRequestCondition.getPatterns();
89-
String operationPath = CollectionUtils.isEmpty(patterns) ? "/" : patterns.iterator().next();
9089
Map<String, String> regexMap = new LinkedHashMap<>();
91-
operationPath = PathUtils.parsePath(operationPath, regexMap);
92-
93-
if (isRestController(restControllers, handlerMethod, operationPath) && isPackageToScan(handlerMethod.getBeanType().getPackage().getName()) && isPathToMatch(operationPath)) {
94-
Set<RequestMethod> requestMethods = requestMappingInfo.getMethodsCondition().getMethods();
95-
calculatePath(openAPIBuilder, handlerMethod, operationPath, requestMethods);
90+
for (String pattern : patterns) {
91+
String operationPath = PathUtils.parsePath(pattern, regexMap);
92+
if (isRestController(restControllers, handlerMethod, operationPath) && isPackageToScan(handlerMethod.getBeanType().getPackage().getName()) && isPathToMatch(operationPath)) {
93+
Set<RequestMethod> requestMethods = requestMappingInfo.getMethodsCondition().getMethods();
94+
calculatePath(openAPIBuilder, handlerMethod, operationPath, requestMethods);
95+
}
9696
}
9797
}
9898
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package test.org.springdoc.api.app65;
2+
3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.tags.Tag;
5+
import org.springframework.http.MediaType;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
@Tag(name = "Health" , description = "Health check / ping API")
11+
@RestController
12+
public class HelloController {
13+
14+
@Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.")
15+
@GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE)
16+
public ResponseEntity<String> ping() {
17+
return ResponseEntity.ok("Healthy");
18+
}
19+
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package test.org.springdoc.api.app65;
2+
3+
import org.junit.AfterClass;
4+
import org.junit.BeforeClass;
5+
import test.org.springdoc.api.AbstractSpringDocTest;
6+
7+
public class SpringDocApp65Test extends AbstractSpringDocTest {
8+
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package test.org.springdoc.api.app65;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class SpringDocTestApp {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(SpringDocTestApp.class, args);
11+
}
12+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"openapi": "3.0.1",
3+
"info": {
4+
"title": "OpenAPI definition",
5+
"version": "v0"
6+
},
7+
"servers": [
8+
{
9+
"url": "http://localhost",
10+
"description": "Generated server url"
11+
}
12+
],
13+
"tags": [
14+
{
15+
"name": "Health",
16+
"description": "Health check / ping API"
17+
}
18+
],
19+
"paths": {
20+
"/ping": {
21+
"get": {
22+
"tags": [
23+
"Health"
24+
],
25+
"summary": "Check server status",
26+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
27+
"operationId": "ping",
28+
"responses": {
29+
"200": {
30+
"description": "default response",
31+
"content": {
32+
"text/plain": {
33+
"schema": {
34+
"type": "string"
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
},
42+
"/health": {
43+
"get": {
44+
"tags": [
45+
"Health"
46+
],
47+
"summary": "Check server status",
48+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
49+
"operationId": "ping_1",
50+
"responses": {
51+
"200": {
52+
"description": "default response",
53+
"content": {
54+
"text/plain": {
55+
"schema": {
56+
"type": "string"
57+
}
58+
}
59+
}
60+
}
61+
}
62+
}
63+
},
64+
"/": {
65+
"get": {
66+
"tags": [
67+
"Health"
68+
],
69+
"summary": "Check server status",
70+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
71+
"operationId": "ping_2",
72+
"responses": {
73+
"200": {
74+
"description": "default response",
75+
"content": {
76+
"text/plain": {
77+
"schema": {
78+
"type": "string"
79+
}
80+
}
81+
}
82+
}
83+
}
84+
}
85+
}
86+
},
87+
"components": {}
88+
}

0 commit comments

Comments
 (0)