Skip to content

Commit c06fcdc

Browse files
committed
Support of {*param} path patterns is broken in 1.6.15. Fixes #2188
1 parent 3c34e5f commit c06fcdc

File tree

7 files changed

+352
-1
lines changed

7 files changed

+352
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,8 @@ private PathItem buildPathItem(RequestMethod requestMethod, Operation operation,
10981098
Parameter parameter = paramIt.next();
10991099
if (ParameterIn.PATH.toString().equals(parameter.getIn())) {
11001100
// check it's present in the path
1101-
if (!operationPath.contains("{" + parameter.getName() + "}"))
1101+
String name = parameter.getName();
1102+
if(!StringUtils.containsAny(operationPath, "{" + name + "}", "{*" + name + "}"))
11021103
paramIt.remove();
11031104
}
11041105
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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+
"paths": {
14+
"/coffees": {
15+
"get": {
16+
"tags": [
17+
"coffee-service"
18+
],
19+
"operationId": "getAllCoffees",
20+
"responses": {
21+
"200": {
22+
"description": "OK",
23+
"content": {
24+
"*/*": {
25+
"schema": {
26+
"type": "array",
27+
"items": {
28+
"$ref": "#/components/schemas/Coffee"
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
36+
},
37+
"/coffees/{id}": {
38+
"get": {
39+
"tags": [
40+
"coffee-service"
41+
],
42+
"operationId": "getCoffeeById",
43+
"parameters": [
44+
{
45+
"name": "id",
46+
"in": "path",
47+
"required": true,
48+
"schema": {
49+
"type": "string"
50+
}
51+
}
52+
],
53+
"responses": {
54+
"200": {
55+
"description": "OK",
56+
"content": {
57+
"*/*": {
58+
"schema": {
59+
"$ref": "#/components/schemas/Coffee"
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
},
67+
"/coffees/{id}/orders": {
68+
"get": {
69+
"tags": [
70+
"coffee-service"
71+
],
72+
"operationId": "getOrdersForCoffeeById",
73+
"parameters": [
74+
{
75+
"name": "id",
76+
"in": "path",
77+
"required": true,
78+
"schema": {
79+
"type": "string"
80+
}
81+
}
82+
],
83+
"responses": {
84+
"200": {
85+
"description": "OK",
86+
"content": {
87+
"*/*": {
88+
"schema": {
89+
"type": "array",
90+
"items": {
91+
"$ref": "#/components/schemas/CoffeeOrder"
92+
}
93+
}
94+
}
95+
}
96+
}
97+
}
98+
}
99+
}
100+
},
101+
"components": {
102+
"schemas": {
103+
"Coffee": {
104+
"type": "object",
105+
"properties": {
106+
"id": {
107+
"type": "string"
108+
},
109+
"name": {
110+
"type": "string"
111+
}
112+
}
113+
},
114+
"CoffeeOrder": {
115+
"type": "object",
116+
"properties": {
117+
"coffeeId": {
118+
"type": "string"
119+
},
120+
"whenOrdered": {
121+
"type": "string",
122+
"format": "date-time"
123+
}
124+
}
125+
}
126+
}
127+
}
128+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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+
"paths": {
14+
"/coffees": {
15+
"get": {
16+
"tags": [
17+
"coffee-service"
18+
],
19+
"operationId": "getAllCoffees",
20+
"responses": {
21+
"200": {
22+
"description": "OK",
23+
"content": {
24+
"*/*": {
25+
"schema": {
26+
"type": "array",
27+
"items": {
28+
"$ref": "#/components/schemas/Coffee"
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
36+
},
37+
"/coffees/{id}": {
38+
"get": {
39+
"tags": [
40+
"coffee-service"
41+
],
42+
"operationId": "getCoffeeById",
43+
"parameters": [
44+
{
45+
"name": "id",
46+
"in": "path",
47+
"required": true,
48+
"schema": {
49+
"type": "string"
50+
}
51+
}
52+
],
53+
"responses": {
54+
"200": {
55+
"description": "OK",
56+
"content": {
57+
"*/*": {
58+
"schema": {
59+
"$ref": "#/components/schemas/Coffee"
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
},
67+
"/coffees/{id}/orders": {
68+
"get": {
69+
"tags": [
70+
"coffee-service"
71+
],
72+
"operationId": "getOrdersForCoffeeById",
73+
"parameters": [
74+
{
75+
"name": "id",
76+
"in": "path",
77+
"required": true,
78+
"schema": {
79+
"type": "string"
80+
}
81+
}
82+
],
83+
"responses": {
84+
"200": {
85+
"description": "OK",
86+
"content": {
87+
"*/*": {
88+
"schema": {
89+
"type": "array",
90+
"items": {
91+
"$ref": "#/components/schemas/CoffeeOrder"
92+
}
93+
}
94+
}
95+
}
96+
}
97+
}
98+
}
99+
}
100+
},
101+
"components": {
102+
"schemas": {
103+
"Coffee": {
104+
"type": "object",
105+
"properties": {
106+
"id": {
107+
"type": "string"
108+
},
109+
"name": {
110+
"type": "string"
111+
}
112+
}
113+
},
114+
"CoffeeOrder": {
115+
"type": "object",
116+
"properties": {
117+
"coffeeId": {
118+
"type": "string"
119+
},
120+
"whenOrdered": {
121+
"type": "string",
122+
"format": "date-time"
123+
}
124+
}
125+
}
126+
}
127+
}
128+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package test.org.springdoc.api.v30.app205;
2+
3+
/**
4+
* @author bnasslahsen
5+
*/
6+
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RestController;
10+
11+
12+
public class OrderDemo {
13+
14+
@RestController
15+
public static class MyController {
16+
17+
@GetMapping("/test/{*param}")
18+
public String testingMethod(@PathVariable("param") String param) {
19+
return "foo";
20+
}
21+
}
22+
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package test.org.springdoc.api.v30.app205;
2+
3+
/**
4+
* @author bnasslahsen
5+
*/
6+
7+
import test.org.springdoc.api.v30.AbstractSpringDocV30Test;
8+
9+
import org.springframework.boot.autoconfigure.SpringBootApplication;
10+
import org.springframework.test.context.TestPropertySource;
11+
12+
/**
13+
* Fix regression in #2031
14+
*/
15+
@TestPropertySource(properties = { "springdoc.group-configs[0].group=mygroup", "springdoc.group-configs[0].paths-to-match=/test" })
16+
public class SpringdocApp205Test extends AbstractSpringDocV30Test {
17+
18+
@SpringBootApplication
19+
static class SpringDocTestApp {}
20+
21+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
"paths": {
14+
"/test/{*param}": {
15+
"get": {
16+
"tags": [
17+
"my-controller"
18+
],
19+
"operationId": "testingMethod",
20+
"parameters": [
21+
{
22+
"name": "param",
23+
"in": "path",
24+
"required": true,
25+
"schema": {
26+
"type": "string"
27+
}
28+
}
29+
],
30+
"responses": {
31+
"200": {
32+
"description": "OK",
33+
"content": {
34+
"*/*": {
35+
"schema": {
36+
"type": "string"
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
},
45+
"components": {}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.springdoc.webmvc.ui.SwaggerConfig
2+
org.springdoc.core.properties.SwaggerUiConfigProperties
3+
org.springdoc.core.properties.SwaggerUiConfigParameters
4+
org.springdoc.core.properties.SwaggerUiOAuthProperties

0 commit comments

Comments
 (0)