Skip to content

Commit 0d4bbb9

Browse files
committed
Setting displayOperationId to false does not work. Fixes #1530.
1 parent 9ea1699 commit 0d4bbb9

File tree

4 files changed

+65
-12
lines changed

4 files changed

+65
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void put(final String name, final Integer value, final Map<String, Object
6868
*/
6969
static void put(final String name, final Boolean value, final Map<String, Object> params) {
7070
if (value != null) {
71-
params.put(name, value.toString());
71+
params.put(name, value);
7272
}
7373
}
7474

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

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,46 @@ public class SwaggerUiConfigParameters extends AbstractSwaggerUiConfigProperties
9191
*/
9292
public static final String QUERY_CONFIG_ENABLED_PROPERTY = "queryConfigEnabled";
9393

94+
/**
95+
* The constant DISPLAY_OPERATION_ID.
96+
*/
97+
public static final String DISPLAY_OPERATION_ID_PROPERTY = "displayOperationId";
98+
99+
/**
100+
* The constant DEEP_LINKING.
101+
*/
102+
public static final String DEEP_LINKING_PROPERTY ="deepLinking";
103+
104+
/**
105+
* The constant DISPLAY_REQUEST_DURATION.
106+
*/
107+
public static final String DISPLAY_REQUEST_DURATION_PROPERTY = "displayRequestDuration";
108+
109+
/**
110+
* The constant SHOW_EXTENSIONS_PROPERTY.
111+
*/
112+
public static final String SHOW_EXTENSIONS_PROPERTY ="showExtensions";
113+
114+
/**
115+
* The constant SHOW_COMMON_EXTENSIONS_PROPERTY.
116+
*/
117+
public static final String SHOW_COMMON_EXTENSIONS_PROPERTY ="showCommonExtensions";
118+
119+
/**
120+
* The constant TRY_IT_ENABLED_PROPERTY.
121+
*/
122+
public static final String TRY_IT_ENABLED_PROPERTY ="tryItOutEnabled";
123+
124+
/**
125+
* The constant PERSIST_AUTHORIZATION_PROPERTY.
126+
*/
127+
public static final String PERSIST_AUTHORIZATION_PROPERTY ="persistAuthorization";
128+
129+
/**
130+
* The constant WITH_CREDENTIALS_PROPERTY.
131+
*/
132+
public static final String WITH_CREDENTIALS_PROPERTY ="withCredentials";
133+
94134
/**
95135
* The Ui root path.
96136
*/
@@ -206,16 +246,16 @@ public Map<String, Object> getConfigParameters() {
206246
// empty-string prevents swagger-ui default validation
207247
params.put(VALIDATOR_URL_PROPERTY, validatorUrl != null ? validatorUrl : "");
208248
SpringDocPropertiesUtils.put(CONFIG_URL_PROPERTY, configUrl, params);
209-
SpringDocPropertiesUtils.put("deepLinking", this.deepLinking, params);
210-
SpringDocPropertiesUtils.put("displayOperationId", displayOperationId, params);
249+
SpringDocPropertiesUtils.put(DEEP_LINKING_PROPERTY, this.deepLinking, params);
250+
SpringDocPropertiesUtils.put(DISPLAY_OPERATION_ID_PROPERTY, displayOperationId, params);
211251
SpringDocPropertiesUtils.put("defaultModelsExpandDepth", defaultModelsExpandDepth, params);
212252
SpringDocPropertiesUtils.put("defaultModelExpandDepth", defaultModelExpandDepth, params);
213253
SpringDocPropertiesUtils.put("defaultModelRendering", defaultModelRendering, params);
214-
SpringDocPropertiesUtils.put("displayRequestDuration", displayRequestDuration, params);
254+
SpringDocPropertiesUtils.put(DISPLAY_REQUEST_DURATION_PROPERTY, displayRequestDuration, params);
215255
SpringDocPropertiesUtils.put("docExpansion", docExpansion, params);
216256
SpringDocPropertiesUtils.put("maxDisplayedTags", maxDisplayedTags, params);
217-
SpringDocPropertiesUtils.put("showExtensions", showExtensions, params);
218-
SpringDocPropertiesUtils.put("showCommonExtensions", showCommonExtensions, params);
257+
SpringDocPropertiesUtils.put(SHOW_EXTENSIONS_PROPERTY, showExtensions, params);
258+
SpringDocPropertiesUtils.put(SHOW_COMMON_EXTENSIONS_PROPERTY, showCommonExtensions, params);
219259
SpringDocPropertiesUtils.put("operationsSorter", operationsSorter, params);
220260
SpringDocPropertiesUtils.put("tagsSorter", tagsSorter, params);
221261
SpringDocPropertiesUtils.put(SwaggerUiConfigParameters.LAYOUT_PROPERTY, layout , params);
@@ -225,10 +265,10 @@ public Map<String, Object> getConfigParameters() {
225265
SpringDocPropertiesUtils.put(URL_PROPERTY, url, params);
226266
put(URLS_PROPERTY, urls, params);
227267
SpringDocPropertiesUtils.put("urls.primaryName", urlsPrimaryName, params);
228-
SpringDocPropertiesUtils.put("tryItOutEnabled", tryItOutEnabled, params);
229-
SpringDocPropertiesUtils.put("persistAuthorization", persistAuthorization, params);
268+
SpringDocPropertiesUtils.put(TRY_IT_ENABLED_PROPERTY, tryItOutEnabled, params);
269+
SpringDocPropertiesUtils.put(PERSIST_AUTHORIZATION_PROPERTY, persistAuthorization, params);
230270
SpringDocPropertiesUtils.put(FILTER_PROPERTY, filter, params);
231-
SpringDocPropertiesUtils.put("withCredentials", withCredentials, params);
271+
SpringDocPropertiesUtils.put(WITH_CREDENTIALS_PROPERTY, withCredentials, params);
232272
return params;
233273
}
234274

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,16 @@ protected String addParameters(String html) throws JsonProcessingException {
173173
.filter(entry -> !SwaggerUiConfigParameters.OAUTH2_REDIRECT_URL_PROPERTY.equals(entry.getKey()))
174174
.filter(entry -> !SwaggerUiConfigParameters.URL_PROPERTY.equals(entry.getKey()))
175175
.filter(entry -> !SwaggerUiConfigParameters.URLS_PROPERTY.equals(entry.getKey()))
176-
.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()))
177186
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,(e1, e2) -> e2,
178187
LinkedHashMap::new));
179188

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@
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

4246
@SpringBootApplication

0 commit comments

Comments
 (0)