Skip to content

Commit

Permalink
Restentpoints with same name get mix up. Fixes #2876
Browse files Browse the repository at this point in the history
  • Loading branch information
bnasslahsen committed Feb 15, 2025
2 parents 0775180 + 54ea28e commit ee5ab03
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,7 @@ protected void calculatePath(HandlerMethod handlerMethod, RouterOperation router
}

PathItem pathItemObject = buildPathItem(requestMethod, operation, operationPath, paths);
if (!StringUtils.contains(operationPath, "**"))
paths.addPathItem(operationPath, pathItemObject);
paths.addPathItem(operationPath, pathItemObject);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public class SpringDocHints implements RuntimeHintsRegistrar {
io.swagger.v3.oas.models.media.Schema.class,
io.swagger.v3.oas.models.media.Content.class,
io.swagger.v3.oas.models.media.ArraySchema.class,
io.swagger.v3.oas.models.media.JsonSchema.class,
io.swagger.v3.oas.models.responses.ApiResponse.class,
io.swagger.v3.oas.models.responses.ApiResponses.class,
io.swagger.v3.oas.models.ExternalDocumentation.class,
Expand All @@ -122,6 +123,7 @@ public class SpringDocHints implements RuntimeHintsRegistrar {
io.swagger.v3.oas.models.Operation.class,
io.swagger.v3.oas.models.headers.Header.class,
ModelConverter.class,
io.swagger.v3.core.converter.ModelConverterContextImpl.class,
ModelConverters.class,
SpecFilter.class,
MediaType.class,
Expand Down Expand Up @@ -166,6 +168,7 @@ public class SpringDocHints implements RuntimeHintsRegistrar {
MediaTypeMixin.class,
//oas 3.1
Schema31Mixin.class,
Schema31Mixin.TypeSerializer.class,
Components31Mixin.class,
OpenAPI31Mixin.class,
Discriminator31Mixin.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ protected void getPaths(Map<String, Object> restControllers, Locale locale, Open
Optional<ActuatorProvider> actuatorProviderOptional = springDocProviders.getActuatorProvider();
if (actuatorProviderOptional.isPresent() && springDocConfigProperties.isShowActuator()) {
Map<RequestMappingInfo, HandlerMethod> actuatorMap = actuatorProviderOptional.get().getMethods();
List<RequestMappingInfo> globMatchActuators = actuatorMap.keySet().stream()
.filter(requestMappingInfo -> requestMappingInfo.getPatternValues().stream()
.anyMatch(patternValues -> patternValues.contains("**")))
.toList();
globMatchActuators.forEach(actuatorMap::remove);
this.openAPIService.addTag(new HashSet<>(actuatorMap.values()), getTag());
map.putAll(actuatorMap);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
package test.org.springdoc.api.v31.app240;
/*
*
* *
* * *
* * * *
* * * * *
* * * * * * Copyright 2019-2025 the original author or authors.
* * * * * *
* * * * * * Licensed under the Apache License, Version 2.0 (the "License");
* * * * * * you may not use this file except in compliance with the License.
* * * * * * You may obtain a copy of the License at
* * * * * *
* * * * * * https://www.apache.org/licenses/LICENSE-2.0
* * * * * *
* * * * * * Unless required by applicable law or agreed to in writing, software
* * * * * * distributed under the License is distributed on an "AS IS" BASIS,
* * * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * * * * * See the License for the specific language governing permissions and
* * * * * * limitations under the License.
* * * * *
* * * *
* * *
* *
*
*/

package test.org.springdoc.api.v31.app241;

import java.util.HashSet;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
*
* *
* * *
* * * *
* * * * *
* * * * * * Copyright 2019-2025 the original author or authors.
* * * * * *
* * * * * * Licensed under the Apache License, Version 2.0 (the "License");
* * * * * * you may not use this file except in compliance with the License.
* * * * * * You may obtain a copy of the License at
* * * * * *
* * * * * * https://www.apache.org/licenses/LICENSE-2.0
* * * * * *
* * * * * * Unless required by applicable law or agreed to in writing, software
* * * * * * distributed under the License is distributed on an "AS IS" BASIS,
* * * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * * * * * See the License for the specific language governing permissions and
* * * * * * limitations under the License.
* * * * *
* * * *
* * *
* *
*
*/

package test.org.springdoc.api.v31.app241;

import org.springdoc.core.customizers.OpenApiCustomizer;
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpRequest;

@Configuration
public class OpenApiConfig {

@Bean
public OpenApiCustomizer openApiCustomiser() {
return openApi -> {

};
}

@Bean
ServerBaseUrlCustomizer serverBaseUrlCustomizer() {
return new ServerBaseUrlCustomizer() {

@Override
public String customize(final String serverBaseUrl,
final HttpRequest request) {
// TODO Auto-generated method stub
return null;
}

};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
*
*/

package test.org.springdoc.api.v31.app240;
package test.org.springdoc.api.v31.app241;

import test.org.springdoc.api.v31.AbstractSpringDocTest;

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

@TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true" )
public class SpringDocApp240Test extends AbstractSpringDocTest {
public class SpringDocApp241Test extends AbstractSpringDocTest {

@SpringBootApplication
static class SpringDocTestApp {}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
<<<<<<< HEAD
"openapi": "3.1.0",
"info": {
"title": "OpenAPI definition",
Expand Down Expand Up @@ -149,3 +150,41 @@
},
"components": {}
}
=======
"openapi": "3.1.0",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"paths": {
"/**": {
"post": {
"tags": [
"wildcard-controller"
],
"summary": "My Wildcard Operation",
"operationId": "getItem",
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"components": {}
}
>>>>>>> origin/main

0 comments on commit ee5ab03

Please sign in to comment.