Skip to content

Commit

Permalink
Support of {*param} path patterns is broken in 1.6.15. Fixes #2188
Browse files Browse the repository at this point in the history
  • Loading branch information
bnasslahsen committed Mar 31, 2023
1 parent 4d06552 commit 50b06ad
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@ private PathItem buildPathItem(RequestMethod requestMethod, Operation operation,
Parameter parameter = paramIt.next();
if(ParameterIn.PATH.toString().equals(parameter.getIn())){
// check it's present in the path
if(!operationPath.contains("{" + parameter.getName() + "}"))
String name = parameter.getName();
if(!StringUtils.containsAny(operationPath, "{" + name + "}", "{*" + name + "}"))
paramIt.remove();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package test.org.springdoc.api.v30.app205;

/**
* @author bnasslahsen
*/

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


public class OrderDemo {

@RestController
public static class MyController {

@GetMapping("/test/{*param}")
public String testingMethod(@PathVariable("param") String param) {
return "foo";
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package test.org.springdoc.api.v30.app205;

/**
* @author bnasslahsen
*/

import test.org.springdoc.api.v30.AbstractSpringDocV30Test;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.test.context.TestPropertySource;

/**
* Fix regression in #2031
*/
@TestPropertySource(properties = { "springdoc.group-configs[0].group=mygroup", "springdoc.group-configs[0].paths-to-match=/test" })
public class SpringdocApp205Test extends AbstractSpringDocV30Test {

@SpringBootApplication
static class SpringDocTestApp {}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"paths": {
"/test/{*param}": {
"get": {
"tags": [
"my-controller"
],
"operationId": "testingMethod",
"parameters": [
{
"name": "param",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"components": {}
}

0 comments on commit 50b06ad

Please sign in to comment.