diff --git a/modules/openapi-generator-online/pom.xml b/modules/openapi-generator-online/pom.xml
index c158dd879f34..08f9c33febc1 100644
--- a/modules/openapi-generator-online/pom.xml
+++ b/modules/openapi-generator-online/pom.xml
@@ -15,8 +15,8 @@
1.8
${java.version}
${java.version}
- 2.0.7.RELEASE
- 2.8.0
+ 2.2.9.RELEASE
+ 3.0.0
4.13
2.10.2
@@ -105,13 +105,17 @@
${springfox-version}
- io.swagger
- swagger-annotations
-
+ io.swagger
+ swagger-annotations
+
io.swagger
swagger-models
+
+ com.google.guava
+ guava
+
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/OpenAPI2SpringBoot.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/OpenAPI2SpringBoot.java
index f3d367e22489..91fb6c32fd3b 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/OpenAPI2SpringBoot.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/OpenAPI2SpringBoot.java
@@ -23,6 +23,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.web.filter.ForwardedHeaderFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -60,4 +61,9 @@ public void addCorsMappings(CorsRegistry registry) {
}
};
}
+
+ @Bean
+ ForwardedHeaderFilter forwardedHeaderFilter() {
+ return new ForwardedHeaderFilter();
+ }
}
diff --git a/modules/openapi-generator-online/src/test/java/org/openapitools/codegen/online/api/GenApiControllerTest.java b/modules/openapi-generator-online/src/test/java/org/openapitools/codegen/online/api/GenApiControllerTest.java
index db55abdc3bcf..14254c446a3b 100644
--- a/modules/openapi-generator-online/src/test/java/org/openapitools/codegen/online/api/GenApiControllerTest.java
+++ b/modules/openapi-generator-online/src/test/java/org/openapitools/codegen/online/api/GenApiControllerTest.java
@@ -22,7 +22,7 @@
@WebMvcTest(GenApiController.class)
public class GenApiControllerTest {
- private static final String OPENAPI_URL = "http://petstore.swagger.io/v2/swagger.json";
+ private static final String OPENAPI_URL = "https://raw.githubusercontent.com/OpenAPITools/openapi-generator/v4.3.1/modules/openapi-generator/src/test/resources/petstore.json";
private static final String UUID_REGEX = "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}";
@Autowired
@@ -43,7 +43,7 @@ public void serverFrameworks() throws Exception {
public void getLanguages(String type, String expected) throws Exception {
mockMvc.perform(get("/api/gen/" + type))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.[*]").value(hasItem(expected)));
}
@@ -72,7 +72,7 @@ public void serverOptionsUnknown() throws Exception {
private void getOptions(String type, String name) throws Exception {
mockMvc.perform(get("/api/gen/" + type + "/" + name))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.sortParamsByRequiredFlag.opt").value("sortParamsByRequiredFlag"));
}
@@ -88,10 +88,10 @@ public void generateServer() throws Exception {
private void generateAndDownload(String type, String name) throws Exception {
String result = mockMvc.perform(post("http://test.com:1234/api/gen/" + type + "/" + name)
- .contentType(MediaType.APPLICATION_JSON_UTF8)
+ .contentType(MediaType.APPLICATION_JSON)
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.code").value(matchesPattern(UUID_REGEX)))
.andExpect(jsonPath("$.link").value(matchesPattern("http\\:\\/\\/test.com\\:1234\\/api\\/gen\\/download\\/" + UUID_REGEX)))
.andReturn().getResponse().getContentAsString();
@@ -107,13 +107,13 @@ private void generateAndDownload(String type, String name) throws Exception {
@Test
public void generateWIthForwardedHeaders() throws Exception {
String result = mockMvc.perform(post("http://test.com:1234/api/gen/clients/java")
- .contentType(MediaType.APPLICATION_JSON_UTF8)
+ .contentType(MediaType.APPLICATION_JSON)
.header("X-Forwarded-Proto", "https")
.header("X-Forwarded-Host", "forwarded.com")
.header("X-Forwarded-Port", "5678")
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.code").value(matchesPattern(UUID_REGEX)))
.andExpect(jsonPath("$.link").value(matchesPattern("https\\:\\/\\/forwarded.com\\:5678\\/api\\/gen\\/download\\/" + UUID_REGEX)))
.andReturn().getResponse().getContentAsString();