Skip to content

Commit 3708d7a

Browse files
committed
Removing operationId via customizer does not work anymore. Fixes #2797
1 parent d11da55 commit 3708d7a

File tree

5 files changed

+208
-2
lines changed

5 files changed

+208
-2
lines changed

Diff for: pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<gmavenplus-plugin.version>1.13.1</gmavenplus-plugin.version>
6666
<jjwt.version>0.9.1</jjwt.version>
6767
<therapi-runtime-javadoc.version>0.15.0</therapi-runtime-javadoc.version>
68-
<spring-cloud-function.version>4.2.0</spring-cloud-function.version>
68+
<spring-cloud-function.version>4.2.0-M1</spring-cloud-function.version>
6969
<spring-security-oauth2-authorization-server.version>1.4.0</spring-security-oauth2-authorization-server.version>
7070
</properties>
7171

Diff for: springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/OperationIdCustomizer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private void processOperation(Operation operation, Map<String, Integer> operatio
7272
String originalOperationId = operation.getOperationId();
7373

7474
// Check if operationId already exists
75-
if (operationIdCount.containsKey(originalOperationId)) {
75+
if ( originalOperationId!=null && operationIdCount.containsKey(originalOperationId)) {
7676
// Get the count for the current operationId and increment
7777
int count = operationIdCount.get(originalOperationId);
7878
count++;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package test.org.springdoc.api.v30.app232;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
/**
7+
* @author bnasslahsen
8+
*/
9+
@RestController
10+
@RequestMapping
11+
public class HelloController {
12+
13+
14+
@RequestMapping("/")
15+
public String sayHello() {
16+
return null;
17+
}
18+
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * *
6+
* * * * *
7+
* * * * * * Copyright 2019-2024 the original author or authors.
8+
* * * * * *
9+
* * * * * * Licensed under the Apache License, Version 2.0 (the "License");
10+
* * * * * * you may not use this file except in compliance with the License.
11+
* * * * * * You may obtain a copy of the License at
12+
* * * * * *
13+
* * * * * * https://www.apache.org/licenses/LICENSE-2.0
14+
* * * * * *
15+
* * * * * * Unless required by applicable law or agreed to in writing, software
16+
* * * * * * distributed under the License is distributed on an "AS IS" BASIS,
17+
* * * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* * * * * * See the License for the specific language governing permissions and
19+
* * * * * * limitations under the License.
20+
* * * * *
21+
* * * *
22+
* * *
23+
* *
24+
*
25+
*/
26+
27+
package test.org.springdoc.api.v30.app232;
28+
29+
import org.springdoc.core.customizers.OperationCustomizer;
30+
import test.org.springdoc.api.v30.AbstractSpringDocV30Test;
31+
32+
import org.springframework.boot.autoconfigure.SpringBootApplication;
33+
import org.springframework.context.annotation.Bean;
34+
35+
/**
36+
* @author bnasslahsen
37+
*/
38+
public class SpringDocApp232Test extends AbstractSpringDocV30Test {
39+
40+
@SpringBootApplication
41+
static class SpringDocTestApp {
42+
@Bean
43+
public OperationCustomizer operationIdCustomizer() {
44+
return (operation, handlerMethod) -> {
45+
operation.setOperationId(null);
46+
return operation;
47+
};
48+
}
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
"/": {
15+
"get": {
16+
"tags": [
17+
"hello-controller"
18+
],
19+
"responses": {
20+
"200": {
21+
"description": "OK",
22+
"content": {
23+
"*/*": {
24+
"schema": {
25+
"type": "string"
26+
}
27+
}
28+
}
29+
}
30+
}
31+
},
32+
"put": {
33+
"tags": [
34+
"hello-controller"
35+
],
36+
"responses": {
37+
"200": {
38+
"description": "OK",
39+
"content": {
40+
"*/*": {
41+
"schema": {
42+
"type": "string"
43+
}
44+
}
45+
}
46+
}
47+
}
48+
},
49+
"post": {
50+
"tags": [
51+
"hello-controller"
52+
],
53+
"responses": {
54+
"200": {
55+
"description": "OK",
56+
"content": {
57+
"*/*": {
58+
"schema": {
59+
"type": "string"
60+
}
61+
}
62+
}
63+
}
64+
}
65+
},
66+
"delete": {
67+
"tags": [
68+
"hello-controller"
69+
],
70+
"responses": {
71+
"200": {
72+
"description": "OK",
73+
"content": {
74+
"*/*": {
75+
"schema": {
76+
"type": "string"
77+
}
78+
}
79+
}
80+
}
81+
}
82+
},
83+
"options": {
84+
"tags": [
85+
"hello-controller"
86+
],
87+
"responses": {
88+
"200": {
89+
"description": "OK",
90+
"content": {
91+
"*/*": {
92+
"schema": {
93+
"type": "string"
94+
}
95+
}
96+
}
97+
}
98+
}
99+
},
100+
"head": {
101+
"tags": [
102+
"hello-controller"
103+
],
104+
"responses": {
105+
"200": {
106+
"description": "OK",
107+
"content": {
108+
"*/*": {
109+
"schema": {
110+
"type": "string"
111+
}
112+
}
113+
}
114+
}
115+
}
116+
},
117+
"patch": {
118+
"tags": [
119+
"hello-controller"
120+
],
121+
"responses": {
122+
"200": {
123+
"description": "OK",
124+
"content": {
125+
"*/*": {
126+
"schema": {
127+
"type": "string"
128+
}
129+
}
130+
}
131+
}
132+
}
133+
}
134+
}
135+
},
136+
"components": {}
137+
}

0 commit comments

Comments
 (0)