-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverse proxy context path aware support for manually provided files. F…
…ixes #1453.
- Loading branch information
1 parent
ce39c7b
commit fd022ee
Showing
9 changed files
with
156 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
springdoc-openapi-ui/src/test/java/test/org/springdoc/ui/app29/SpringDocApp29Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* | ||
* * 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.app29; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import test.org.springdoc.ui.AbstractSpringDocTest; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
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; | ||
|
||
@TestPropertySource(properties ={ | ||
"springdoc.swagger-ui.url=/api-docs/xxx/v1/openapi.yml", | ||
"server.servlet.context-path=/context-path" | ||
} ) | ||
public class SpringDocApp29Test extends AbstractSpringDocTest { | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
@Test | ||
public void test_url_with_context() throws Exception { | ||
mockMvc.perform(get("/context-path/v3/api-docs/swagger-config").contextPath("/context-path")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("url", equalTo("/context-path/api-docs/xxx/v1/openapi.yml"))) | ||
.andExpect(jsonPath("configUrl", equalTo("/context-path/v3/api-docs/swagger-config"))) | ||
.andExpect(jsonPath("validatorUrl", equalTo(""))) | ||
.andExpect(jsonPath("oauth2RedirectUrl", equalTo("http://localhost/context-path/swagger-ui/oauth2-redirect.html"))); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
springdoc-openapi-ui/src/test/java/test/org/springdoc/ui/app30/SpringDocApp30Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* | ||
* * 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.app30; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import test.org.springdoc.ui.AbstractSpringDocTest; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
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; | ||
|
||
@TestPropertySource(properties ={ | ||
"springdoc.swagger-ui..urls[0].url=/api-docs/xxx/v1/openapi.yml", | ||
"springdoc.swagger-ui.urls[0].name=toto", | ||
"server.servlet.context-path=/context-path" | ||
} ) | ||
public class SpringDocApp30Test extends AbstractSpringDocTest { | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
|
||
@Test | ||
public void test_urls_with_context() throws Exception { | ||
mockMvc.perform(get("/context-path/v3/api-docs/swagger-config").contextPath("/context-path")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("url").doesNotExist()) | ||
.andExpect(jsonPath("urls[0].url", equalTo("/context-path/api-docs/xxx/v1/openapi.yml"))) | ||
.andExpect(jsonPath("urls[0].name", equalTo("toto"))) | ||
.andExpect(jsonPath("validatorUrl", equalTo(""))) | ||
.andExpect(jsonPath("oauth2RedirectUrl", equalTo("http://localhost/context-path/swagger-ui/oauth2-redirect.html"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters