Skip to content

Commit

Permalink
Inconsistent casing of swagger-config causes fetch error. Fixes #1277.
Browse files Browse the repository at this point in the history
  • Loading branch information
bnasslahsen committed Oct 2, 2021
1 parent 1a10e35 commit af63811
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Objects;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.springdoc.core.SwaggerUiConfigProperties.SyntaxHighlight;

import static org.springdoc.core.Constants.GROUP_NAME_NOT_NULL;
Expand Down Expand Up @@ -643,11 +644,13 @@ public static class SwaggerUrl {
/**
* The Url.
*/
@JsonProperty("url")
private String url;

/**
* The Name.
*/
@JsonProperty("name")
private String name;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

package test.org.springdoc.ui.app1;

import org.junit.jupiter.api.Test;
import test.org.springdoc.ui.AbstractSpringDocActuatorTest;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;


@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"spring.jackson.property-naming-strategy=UPPER_CAMEL_CASE", "springdoc.show-actuator=true",
"management.endpoints.web.base-path=/management",
"server.servlet.context-path=/demo/api", "management.server.port=9001", "management.server.base-path=/demo/api" })
public class SpringDocSwaggerConfigTest extends AbstractSpringDocActuatorTest {

@Test
public void testIndexSwaggerConfig() throws Exception {
mockMvc.perform(get("/demo/api/v3/api-docs/swagger-config").contextPath("/demo/api"))
.andExpect(status().isOk())
.andExpect(jsonPath("validatorUrl", equalTo("")))
.andExpect(jsonPath("oauth2RedirectUrl", equalTo("http://localhost/demo/api/swagger-ui/oauth2-redirect.html")))
.andExpect(jsonPath("url").doesNotExist())
.andExpect(jsonPath("urls[0].url", equalTo("/demo/api/v3/api-docs/springdocDefault")))
.andExpect(jsonPath("urls[0].name", equalTo("springdocDefault")))
.andExpect(jsonPath("urls[1].url", equalTo("/demo/api/v3/api-docs/x-actuator")))
.andExpect(jsonPath("urls[1].name", equalTo("x-actuator")));
}


@SpringBootApplication
static class SpringDocTestApp {}

}

0 comments on commit af63811

Please sign in to comment.