Skip to content

Commit 50b06ad

Browse files
committed
Support of {*param} path patterns is broken in 1.6.15. Fixes #2188
1 parent 4d06552 commit 50b06ad

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,8 @@ private PathItem buildPathItem(RequestMethod requestMethod, Operation operation,
10831083
Parameter parameter = paramIt.next();
10841084
if(ParameterIn.PATH.toString().equals(parameter.getIn())){
10851085
// check it's present in the path
1086-
if(!operationPath.contains("{" + parameter.getName() + "}"))
1086+
String name = parameter.getName();
1087+
if(!StringUtils.containsAny(operationPath, "{" + name + "}", "{*" + name + "}"))
10871088
paramIt.remove();
10881089
}
10891090
}
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+
}
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+
}

0 commit comments

Comments
 (0)