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 Apr 1, 2023
1 parent 3c34e5f commit c06fcdc
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,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,128 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "",
"description": "Generated server url"
}
],
"paths": {
"/coffees": {
"get": {
"tags": [
"coffee-service"
],
"operationId": "getAllCoffees",
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Coffee"
}
}
}
}
}
}
}
},
"/coffees/{id}": {
"get": {
"tags": [
"coffee-service"
],
"operationId": "getCoffeeById",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/Coffee"
}
}
}
}
}
}
},
"/coffees/{id}/orders": {
"get": {
"tags": [
"coffee-service"
],
"operationId": "getOrdersForCoffeeById",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CoffeeOrder"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Coffee": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"CoffeeOrder": {
"type": "object",
"properties": {
"coffeeId": {
"type": "string"
},
"whenOrdered": {
"type": "string",
"format": "date-time"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "",
"description": "Generated server url"
}
],
"paths": {
"/coffees": {
"get": {
"tags": [
"coffee-service"
],
"operationId": "getAllCoffees",
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Coffee"
}
}
}
}
}
}
}
},
"/coffees/{id}": {
"get": {
"tags": [
"coffee-service"
],
"operationId": "getCoffeeById",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/Coffee"
}
}
}
}
}
}
},
"/coffees/{id}/orders": {
"get": {
"tags": [
"coffee-service"
],
"operationId": "getOrdersForCoffeeById",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CoffeeOrder"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Coffee": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"CoffeeOrder": {
"type": "object",
"properties": {
"coffeeId": {
"type": "string"
},
"whenOrdered": {
"type": "string",
"format": "date-time"
}
}
}
}
}
}
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": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.springdoc.webmvc.ui.SwaggerConfig
org.springdoc.core.properties.SwaggerUiConfigProperties
org.springdoc.core.properties.SwaggerUiConfigParameters
org.springdoc.core.properties.SwaggerUiOAuthProperties

0 comments on commit c06fcdc

Please sign in to comment.