Skip to content

Commit af63811

Browse files
committed
Inconsistent casing of swagger-config causes fetch error. Fixes #1277.
1 parent 1a10e35 commit af63811

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Objects;
2525
import java.util.Set;
2626

27+
import com.fasterxml.jackson.annotation.JsonProperty;
2728
import org.springdoc.core.SwaggerUiConfigProperties.SyntaxHighlight;
2829

2930
import static org.springdoc.core.Constants.GROUP_NAME_NOT_NULL;
@@ -643,11 +644,13 @@ public static class SwaggerUrl {
643644
/**
644645
* The Url.
645646
*/
647+
@JsonProperty("url")
646648
private String url;
647649

648650
/**
649651
* The Name.
650652
*/
653+
@JsonProperty("name")
651654
private String name;
652655

653656
/**
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.app1;
20+
21+
import org.junit.jupiter.api.Test;
22+
import test.org.springdoc.ui.AbstractSpringDocActuatorTest;
23+
24+
import org.springframework.boot.autoconfigure.SpringBootApplication;
25+
import org.springframework.boot.test.context.SpringBootTest;
26+
27+
import static org.hamcrest.CoreMatchers.equalTo;
28+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
29+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
30+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
31+
32+
33+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
34+
properties = {"spring.jackson.property-naming-strategy=UPPER_CAMEL_CASE", "springdoc.show-actuator=true",
35+
"management.endpoints.web.base-path=/management",
36+
"server.servlet.context-path=/demo/api", "management.server.port=9001", "management.server.base-path=/demo/api" })
37+
public class SpringDocSwaggerConfigTest extends AbstractSpringDocActuatorTest {
38+
39+
@Test
40+
public void testIndexSwaggerConfig() throws Exception {
41+
mockMvc.perform(get("/demo/api/v3/api-docs/swagger-config").contextPath("/demo/api"))
42+
.andExpect(status().isOk())
43+
.andExpect(jsonPath("validatorUrl", equalTo("")))
44+
.andExpect(jsonPath("oauth2RedirectUrl", equalTo("http://localhost/demo/api/swagger-ui/oauth2-redirect.html")))
45+
.andExpect(jsonPath("url").doesNotExist())
46+
.andExpect(jsonPath("urls[0].url", equalTo("/demo/api/v3/api-docs/springdocDefault")))
47+
.andExpect(jsonPath("urls[0].name", equalTo("springdocDefault")))
48+
.andExpect(jsonPath("urls[1].url", equalTo("/demo/api/v3/api-docs/x-actuator")))
49+
.andExpect(jsonPath("urls[1].name", equalTo("x-actuator")));
50+
}
51+
52+
53+
@SpringBootApplication
54+
static class SpringDocTestApp {}
55+
56+
}

0 commit comments

Comments
 (0)