Skip to content

Commit 1405109

Browse files
committed
Changes report: Setting displayOperationId to false does not work. Fixes #1530.
1 parent f02ef69 commit 1405109

File tree

5 files changed

+116
-71
lines changed

5 files changed

+116
-71
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SwaggerUiConfigParameters.java

Lines changed: 73 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
/*
22
*
33
* *
4+
* * * Copyright 2019-2020 the original author or authors.
45
* * *
5-
* * * * Copyright 2019-2022 the original author or authors.
6-
* * * *
7-
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8-
* * * * you may not use this file except in compliance with the License.
9-
* * * * You may obtain a copy of the License at
10-
* * * *
11-
* * * * https://www.apache.org/licenses/LICENSE-2.0
12-
* * * *
13-
* * * * Unless required by applicable law or agreed to in writing, software
14-
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15-
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16-
* * * * See the License for the specific language governing permissions and
17-
* * * * limitations under the License.
6+
* * * Licensed under the Apache License, Version 2.0 (the "License");
7+
* * * you may not use this file except in compliance with the License.
8+
* * * You may obtain a copy of the License at
189
* * *
10+
* * * https://www.apache.org/licenses/LICENSE-2.0
11+
* * *
12+
* * * Unless required by applicable law or agreed to in writing, software
13+
* * * distributed under the License is distributed on an "AS IS" BASIS,
14+
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* * * See the License for the specific language governing permissions and
16+
* * * limitations under the License.
1917
* *
2018
*
2119
*/
@@ -34,7 +32,6 @@
3432
import org.apache.commons.lang3.StringUtils;
3533
import org.springdoc.core.configuration.SpringDocConfiguration;
3634
import org.springdoc.core.utils.Constants;
37-
import org.springdoc.core.utils.SpringDocPropertiesUtils;
3835

3936
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
4037
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -96,6 +93,46 @@ public class SwaggerUiConfigParameters extends AbstractSwaggerUiConfigProperties
9693
*/
9794
public static final String QUERY_CONFIG_ENABLED_PROPERTY = "queryConfigEnabled";
9895

96+
/**
97+
* The constant DISPLAY_OPERATION_ID.
98+
*/
99+
public static final String DISPLAY_OPERATION_ID_PROPERTY = "displayOperationId";
100+
101+
/**
102+
* The constant DEEP_LINKING.
103+
*/
104+
public static final String DEEP_LINKING_PROPERTY ="deepLinking";
105+
106+
/**
107+
* The constant DISPLAY_REQUEST_DURATION.
108+
*/
109+
public static final String DISPLAY_REQUEST_DURATION_PROPERTY = "displayRequestDuration";
110+
111+
/**
112+
* The constant SHOW_EXTENSIONS_PROPERTY.
113+
*/
114+
public static final String SHOW_EXTENSIONS_PROPERTY ="showExtensions";
115+
116+
/**
117+
* The constant SHOW_COMMON_EXTENSIONS_PROPERTY.
118+
*/
119+
public static final String SHOW_COMMON_EXTENSIONS_PROPERTY ="showCommonExtensions";
120+
121+
/**
122+
* The constant TRY_IT_ENABLED_PROPERTY.
123+
*/
124+
public static final String TRY_IT_ENABLED_PROPERTY ="tryItOutEnabled";
125+
126+
/**
127+
* The constant PERSIST_AUTHORIZATION_PROPERTY.
128+
*/
129+
public static final String PERSIST_AUTHORIZATION_PROPERTY ="persistAuthorization";
130+
131+
/**
132+
* The constant WITH_CREDENTIALS_PROPERTY.
133+
*/
134+
public static final String WITH_CREDENTIALS_PROPERTY ="withCredentials";
135+
99136
/**
100137
* The Ui root path.
101138
*/
@@ -210,30 +247,30 @@ public Map<String, Object> getConfigParameters() {
210247
final Map<String, Object> params = new TreeMap<>();
211248
// empty-string prevents swagger-ui default validation
212249
params.put(VALIDATOR_URL_PROPERTY, validatorUrl != null ? validatorUrl : "");
213-
SpringDocPropertiesUtils.put(CONFIG_URL_PROPERTY, configUrl, params);
214-
SpringDocPropertiesUtils.put("deepLinking", this.deepLinking, params);
215-
SpringDocPropertiesUtils.put("displayOperationId", displayOperationId, params);
216-
SpringDocPropertiesUtils.put("defaultModelsExpandDepth", defaultModelsExpandDepth, params);
217-
SpringDocPropertiesUtils.put("defaultModelExpandDepth", defaultModelExpandDepth, params);
218-
SpringDocPropertiesUtils.put("defaultModelRendering", defaultModelRendering, params);
219-
SpringDocPropertiesUtils.put("displayRequestDuration", displayRequestDuration, params);
220-
SpringDocPropertiesUtils.put("docExpansion", docExpansion, params);
221-
SpringDocPropertiesUtils.put("maxDisplayedTags", maxDisplayedTags, params);
222-
SpringDocPropertiesUtils.put("showExtensions", showExtensions, params);
223-
SpringDocPropertiesUtils.put("showCommonExtensions", showCommonExtensions, params);
224-
SpringDocPropertiesUtils.put("operationsSorter", operationsSorter, params);
225-
SpringDocPropertiesUtils.put("tagsSorter", tagsSorter, params);
226-
SpringDocPropertiesUtils.put(SwaggerUiConfigParameters.LAYOUT_PROPERTY, layout , params);
250+
org.springdoc.core.SpringDocPropertiesUtils.put(CONFIG_URL_PROPERTY, configUrl, params);
251+
org.springdoc.core.SpringDocPropertiesUtils.put(DEEP_LINKING_PROPERTY, this.deepLinking, params);
252+
org.springdoc.core.SpringDocPropertiesUtils.put(DISPLAY_OPERATION_ID_PROPERTY, displayOperationId, params);
253+
org.springdoc.core.SpringDocPropertiesUtils.put("defaultModelsExpandDepth", defaultModelsExpandDepth, params);
254+
org.springdoc.core.SpringDocPropertiesUtils.put("defaultModelExpandDepth", defaultModelExpandDepth, params);
255+
org.springdoc.core.SpringDocPropertiesUtils.put("defaultModelRendering", defaultModelRendering, params);
256+
org.springdoc.core.SpringDocPropertiesUtils.put(DISPLAY_REQUEST_DURATION_PROPERTY, displayRequestDuration, params);
257+
org.springdoc.core.SpringDocPropertiesUtils.put("docExpansion", docExpansion, params);
258+
org.springdoc.core.SpringDocPropertiesUtils.put("maxDisplayedTags", maxDisplayedTags, params);
259+
org.springdoc.core.SpringDocPropertiesUtils.put(SHOW_EXTENSIONS_PROPERTY, showExtensions, params);
260+
org.springdoc.core.SpringDocPropertiesUtils.put(SHOW_COMMON_EXTENSIONS_PROPERTY, showCommonExtensions, params);
261+
org.springdoc.core.SpringDocPropertiesUtils.put("operationsSorter", operationsSorter, params);
262+
org.springdoc.core.SpringDocPropertiesUtils.put("tagsSorter", tagsSorter, params);
263+
org.springdoc.core.SpringDocPropertiesUtils.put(SwaggerUiConfigParameters.LAYOUT_PROPERTY, layout , params);
227264
if (supportedSubmitMethods != null)
228-
SpringDocPropertiesUtils.put("supportedSubmitMethods", supportedSubmitMethods.toString(), params);
229-
SpringDocPropertiesUtils.put(OAUTH2_REDIRECT_URL_PROPERTY, oauth2RedirectUrl, params);
230-
SpringDocPropertiesUtils.put(URL_PROPERTY, url, params);
265+
org.springdoc.core.SpringDocPropertiesUtils.put("supportedSubmitMethods", supportedSubmitMethods.toString(), params);
266+
org.springdoc.core.SpringDocPropertiesUtils.put(OAUTH2_REDIRECT_URL_PROPERTY, oauth2RedirectUrl, params);
267+
org.springdoc.core.SpringDocPropertiesUtils.put(URL_PROPERTY, url, params);
231268
put(URLS_PROPERTY, urls, params);
232-
SpringDocPropertiesUtils.put("urls.primaryName", urlsPrimaryName, params);
233-
SpringDocPropertiesUtils.put("tryItOutEnabled", tryItOutEnabled, params);
234-
SpringDocPropertiesUtils.put("persistAuthorization", persistAuthorization, params);
235-
SpringDocPropertiesUtils.put(FILTER_PROPERTY, filter, params);
236-
SpringDocPropertiesUtils.put("withCredentials", withCredentials, params);
269+
org.springdoc.core.SpringDocPropertiesUtils.put("urls.primaryName", urlsPrimaryName, params);
270+
org.springdoc.core.SpringDocPropertiesUtils.put(TRY_IT_ENABLED_PROPERTY, tryItOutEnabled, params);
271+
org.springdoc.core.SpringDocPropertiesUtils.put(PERSIST_AUTHORIZATION_PROPERTY, persistAuthorization, params);
272+
org.springdoc.core.SpringDocPropertiesUtils.put(FILTER_PROPERTY, filter, params);
273+
org.springdoc.core.SpringDocPropertiesUtils.put(WITH_CREDENTIALS_PROPERTY, withCredentials, params);
237274
return params;
238275
}
239276

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SwaggerUiOAuthProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import java.util.Map;
2828
import java.util.TreeMap;
2929

30+
import org.springdoc.core.SpringDocPropertiesUtils;
3031
import org.springdoc.core.configuration.SpringDocConfiguration;
31-
import org.springdoc.core.utils.SpringDocPropertiesUtils;
3232

3333
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3434
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocPropertiesUtils.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
/*
22
*
33
* *
4+
* * * Copyright 2019-2020 the original author or authors.
45
* * *
5-
* * * * Copyright 2019-2022 the original author or authors.
6-
* * * *
7-
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8-
* * * * you may not use this file except in compliance with the License.
9-
* * * * You may obtain a copy of the License at
10-
* * * *
11-
* * * * https://www.apache.org/licenses/LICENSE-2.0
12-
* * * *
13-
* * * * Unless required by applicable law or agreed to in writing, software
14-
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15-
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16-
* * * * See the License for the specific language governing permissions and
17-
* * * * limitations under the License.
6+
* * * Licensed under the Apache License, Version 2.0 (the "License");
7+
* * * you may not use this file except in compliance with the License.
8+
* * * You may obtain a copy of the License at
189
* * *
10+
* * * https://www.apache.org/licenses/LICENSE-2.0
11+
* * *
12+
* * * Unless required by applicable law or agreed to in writing, software
13+
* * * distributed under the License is distributed on an "AS IS" BASIS,
14+
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* * * See the License for the specific language governing permissions and
16+
* * * limitations under the License.
1917
* *
2018
*
2119
*/
2220

23-
package org.springdoc.core.utils;
21+
package org.springdoc.core;
2422

2523
import java.util.List;
2624
import java.util.Map;
@@ -70,7 +68,7 @@ static void put(final String name, final Integer value, final Map<String, Object
7068
*/
7169
static void put(final String name, final Boolean value, final Map<String, Object> params) {
7270
if (value != null) {
73-
params.put(name, value.toString());
71+
params.put(name, value);
7472
}
7573
}
7674

springdoc-openapi-starter-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,17 @@
33
* *
44
* * * Copyright 2019-2020 the original author or authors.
55
* * *
6-
* * * * Copyright 2019-2022 the original author or authors.
7-
* * * *
8-
* * * * Licensed under the Apache License, Version 2.0 (the "License");
9-
* * * * you may not use this file except in compliance with the License.
10-
* * * * You may obtain a copy of the License at
11-
* * * *
12-
* * * * https://www.apache.org/licenses/LICENSE-2.0
13-
* * * *
14-
* * * * Unless required by applicable law or agreed to in writing, software
15-
* * * * distributed under the License is distributed on an "AS IS" BASIS,
16-
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17-
* * * * See the License for the specific language governing permissions and
18-
* * * * limitations under the License.
6+
* * * Licensed under the Apache License, Version 2.0 (the "License");
7+
* * * you may not use this file except in compliance with the License.
8+
* * * You may obtain a copy of the License at
199
* * *
10+
* * * https://www.apache.org/licenses/LICENSE-2.0
11+
* * *
12+
* * * Unless required by applicable law or agreed to in writing, software
13+
* * * distributed under the License is distributed on an "AS IS" BASIS,
14+
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* * * See the License for the specific language governing permissions and
16+
* * * limitations under the License.
2017
* *
2118
*
2219
*/
@@ -176,7 +173,16 @@ protected String addParameters(String html) throws JsonProcessingException {
176173
.filter(entry -> !SwaggerUiConfigParameters.OAUTH2_REDIRECT_URL_PROPERTY.equals(entry.getKey()))
177174
.filter(entry -> !SwaggerUiConfigParameters.URL_PROPERTY.equals(entry.getKey()))
178175
.filter(entry -> !SwaggerUiConfigParameters.URLS_PROPERTY.equals(entry.getKey()))
179-
.filter(entry -> SwaggerUiConfigParameters.VALIDATOR_URL_PROPERTY.equals(entry.getKey()) || StringUtils.isNotEmpty((String) entry.getValue()))
176+
.filter(entry -> SwaggerUiConfigParameters.VALIDATOR_URL_PROPERTY.equals(entry.getKey())
177+
|| SwaggerUiConfigParameters.DISPLAY_OPERATION_ID_PROPERTY.equals(entry.getKey())
178+
|| SwaggerUiConfigParameters.DEEP_LINKING_PROPERTY.equals(entry.getKey())
179+
|| SwaggerUiConfigParameters.DISPLAY_REQUEST_DURATION_PROPERTY.equals(entry.getKey())
180+
|| SwaggerUiConfigParameters.SHOW_EXTENSIONS_PROPERTY.equals(entry.getKey())
181+
|| SwaggerUiConfigParameters.SHOW_COMMON_EXTENSIONS_PROPERTY.equals(entry.getKey())
182+
|| SwaggerUiConfigParameters.TRY_IT_ENABLED_PROPERTY.equals(entry.getKey())
183+
|| SwaggerUiConfigParameters.PERSIST_AUTHORIZATION_PROPERTY.equals(entry.getKey())
184+
|| SwaggerUiConfigParameters.WITH_CREDENTIALS_PROPERTY.equals(entry.getKey())
185+
|| StringUtils.isNotEmpty((String) entry.getValue()))
180186
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,(e1, e2) -> e2,
181187
LinkedHashMap::new));
182188

springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app18/SpringDocApp18Test.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,22 @@
2929
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
3030
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
3131

32-
@TestPropertySource(properties = "springdoc.swagger-ui.try-it-out-enabled=true" )
32+
@TestPropertySource(properties = {
33+
"springdoc.swagger-ui.try-it-out-enabled=true",
34+
"springdoc.swagger-ui.display-operation-id=true"
35+
} )
3336
public class SpringDocApp18Test extends AbstractSpringDocTest {
3437

3538
@Test
3639
public void testTryItOutEnabled() throws Exception {
3740
mockMvc.perform(get("/v3/api-docs/swagger-config"))
3841
.andExpect(status().isOk())
39-
.andExpect(jsonPath("tryItOutEnabled", equalTo("true")));
42+
.andExpect(jsonPath("displayOperationId", equalTo(true)))
43+
.andExpect(jsonPath("tryItOutEnabled", equalTo(true)));
4044
}
4145

42-
@SpringBootApplication
43-
static class SpringDocTestApp {
44-
}
46+
@SpringBootApplication
47+
static class SpringDocTestApp {
48+
}
4549

4650
}

0 commit comments

Comments
 (0)