Skip to content

Commit 618a836

Browse files
committed
Swagger-ui ignores property springdoc.swagger-ui.supported-submit-methods Fixes #2740
1 parent 2277e88 commit 618a836

File tree

8 files changed

+221
-3
lines changed

8 files changed

+221
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public Map<String, Object> getConfigParameters() {
284284
org.springdoc.core.utils.SpringDocPropertiesUtils.put("tagsSorter", tagsSorter, params);
285285
org.springdoc.core.utils.SpringDocPropertiesUtils.put(SwaggerUiConfigParameters.LAYOUT_PROPERTY, layout, params);
286286
if (supportedSubmitMethods != null)
287-
org.springdoc.core.utils.SpringDocPropertiesUtils.put("supportedSubmitMethods", supportedSubmitMethods.toString(), params);
287+
org.springdoc.core.utils.SpringDocPropertiesUtils.put("supportedSubmitMethods", supportedSubmitMethods, params);
288288
org.springdoc.core.utils.SpringDocPropertiesUtils.put(OAUTH2_REDIRECT_URL_PROPERTY, oauth2RedirectUrl, params);
289289
org.springdoc.core.utils.SpringDocPropertiesUtils.put(URL_PROPERTY, url, params);
290290
put(URLS_PROPERTY, urls, params);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public interface SpringDocPropertiesUtils {
4545
* @param params the params
4646
*/
4747
static void put(String name, List<String> value, Map<String, Object> params) {
48-
if (!CollectionUtils.isEmpty(value)) {
4948
params.put(name, value);
50-
}
5149
}
5250

5351
/**
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.ui.app34;
20+
21+
22+
import jakarta.validation.Valid;
23+
import jakarta.validation.constraints.Size;
24+
25+
import org.springframework.web.bind.annotation.GetMapping;
26+
import org.springframework.web.bind.annotation.RequestParam;
27+
import org.springframework.web.bind.annotation.RestController;
28+
29+
@RestController
30+
public class HelloController {
31+
32+
@GetMapping(value = "/persons")
33+
public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) {
34+
35+
}
36+
37+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.ui.app34;
20+
21+
import org.junit.jupiter.api.Test;
22+
import test.org.springdoc.ui.AbstractSpringDocTest;
23+
24+
import org.springframework.boot.autoconfigure.SpringBootApplication;
25+
import org.springframework.test.context.TestPropertySource;
26+
27+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
28+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
29+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
30+
31+
@TestPropertySource(properties = {
32+
"springdoc.swagger-ui.supported-submit-methods="
33+
})
34+
public class SpringDocApp34Test extends AbstractSpringDocTest {
35+
36+
@Test
37+
public void test() throws Exception {
38+
mockMvc.perform(get("/swagger-ui.html"))
39+
.andExpect(status().isFound())
40+
.andExpect(header().string("Location", "/swagger-ui/index.html"));
41+
42+
super.chekJS();
43+
}
44+
45+
@SpringBootApplication
46+
static class SpringDocTestApp {}
47+
48+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.ui.app35;
20+
21+
22+
import jakarta.validation.Valid;
23+
import jakarta.validation.constraints.Size;
24+
25+
import org.springframework.web.bind.annotation.GetMapping;
26+
import org.springframework.web.bind.annotation.RequestParam;
27+
import org.springframework.web.bind.annotation.RestController;
28+
29+
@RestController
30+
public class HelloController {
31+
32+
@GetMapping(value = "/persons")
33+
public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) {
34+
35+
}
36+
37+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.ui.app35;
20+
21+
import org.junit.jupiter.api.Test;
22+
import test.org.springdoc.ui.AbstractSpringDocTest;
23+
24+
import org.springframework.boot.autoconfigure.SpringBootApplication;
25+
import org.springframework.test.context.TestPropertySource;
26+
27+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
28+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
29+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
30+
31+
@TestPropertySource(properties = {
32+
"springdoc.swagger-ui.supported-submit-methods=put, post, delete, options, head, patch, trace"
33+
})
34+
public class SpringDocApp35Test extends AbstractSpringDocTest {
35+
36+
@Test
37+
public void test() throws Exception {
38+
mockMvc.perform(get("/swagger-ui.html"))
39+
.andExpect(status().isFound())
40+
.andExpect(header().string("Location", "/swagger-ui/index.html"));
41+
42+
super.chekJS();
43+
}
44+
45+
@SpringBootApplication
46+
static class SpringDocTestApp {}
47+
48+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
window.onload = function() {
2+
//<editor-fold desc="Changeable Configuration Block">
3+
4+
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
5+
window.ui = SwaggerUIBundle({
6+
url: "https://petstore.swagger.io/v2/swagger.json",
7+
dom_id: '#swagger-ui',
8+
deepLinking: true,
9+
presets: [
10+
SwaggerUIBundle.presets.apis,
11+
SwaggerUIStandalonePreset
12+
],
13+
plugins: [
14+
SwaggerUIBundle.plugins.DownloadUrl
15+
],
16+
layout: "StandaloneLayout" ,
17+
18+
"configUrl" : "/v3/api-docs/swagger-config",
19+
"supportedSubmitMethods" : [ ],
20+
"validatorUrl" : ""
21+
22+
});
23+
24+
//</editor-fold>
25+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
window.onload = function() {
2+
//<editor-fold desc="Changeable Configuration Block">
3+
4+
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
5+
window.ui = SwaggerUIBundle({
6+
url: "https://petstore.swagger.io/v2/swagger.json",
7+
dom_id: '#swagger-ui',
8+
deepLinking: true,
9+
presets: [
10+
SwaggerUIBundle.presets.apis,
11+
SwaggerUIStandalonePreset
12+
],
13+
plugins: [
14+
SwaggerUIBundle.plugins.DownloadUrl
15+
],
16+
layout: "StandaloneLayout" ,
17+
18+
"configUrl" : "/v3/api-docs/swagger-config",
19+
"supportedSubmitMethods" : [ "put", "post", "delete", "options", "head", "patch", "trace" ],
20+
"validatorUrl" : ""
21+
22+
});
23+
24+
//</editor-fold>
25+
};

0 commit comments

Comments
 (0)