diff --git a/modules/openapi-generator-online/README.md b/modules/openapi-generator-online/README.md
index 6d731ceffa9c..6a9cf516c729 100644
--- a/modules/openapi-generator-online/README.md
+++ b/modules/openapi-generator-online/README.md
@@ -10,7 +10,7 @@ By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a ser
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.
-The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox)
+The underlying library integrating OpenAPI to SpringBoot is [springdoc](https://github.com/springdoc/springdoc-openapi)
## Building
@@ -28,13 +28,6 @@ java -jar ./target/openapi-generator-online.jar
This exposes the API on local port 8080.
-Springfox supports configuration of the "host" value in the output OpenAPI document by setting the `Host` HTTP header in the request.
-To set this explicitly, pass the system property `springfox.documentation.swagger.v2.host` with the desired host. For example:
-
-```
-java -Dspringfox.documentation.swagger.v2.host=example.com:8888 -jar ./target/openapi-generator-online.jar
-```
-
### Via Docker
After building from source, change to this module directory (`cd modules/openapi-generator-online`) and build the docker image:
diff --git a/modules/openapi-generator-online/pom.xml b/modules/openapi-generator-online/pom.xml
index 08b7d222b7a6..362381122ef3 100644
--- a/modules/openapi-generator-online/pom.xml
+++ b/modules/openapi-generator-online/pom.xml
@@ -12,8 +12,10 @@
jar
openapi-generator-online
- 2.5.14
- 3.0.0
+ 17
+ 17
+ 3.5.7
+ 2.8.14
**/org/openapitools/codegen/online/**/*
@@ -46,6 +48,13 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ true
+
+
org.apache.maven.plugins
maven-checkstyle-plugin
@@ -53,6 +62,13 @@
${project.parent.basedir}${file.separator}google_checkstyle.xml
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ org.junit.jupiter:junit-jupiter
+
+
org.springframework.boot
spring-boot-maven-plugin
@@ -101,25 +117,11 @@
org.springframework.boot
spring-boot-starter-web
-
+
- io.springfox
- springfox-swagger2
- ${springfox-version}
-
-
- io.swagger
- swagger-annotations
-
-
- io.swagger
- swagger-models
-
-
- com.google.guava
- guava
-
-
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ ${springdoc-version}
@@ -133,12 +135,6 @@
${project.parent.version}
-
- org.junit.jupiter
- junit-jupiter-api
- ${junit.version}
- test
-
org.springframework.boot
spring-boot-starter-test
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 6297bcb2ed6e..08d2b7868ea0 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
@@ -57,7 +57,9 @@ public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
- registry.addMapping("/**").allowedOrigins("*").allowedHeaders("Content-Type");
+ registry.addMapping("/**")
+ .allowedOriginPatterns("*")
+ .allowedHeaders("Content-Type");
}
};
}
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/ApiOriginFilter.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/ApiOriginFilter.java
index a3594aae1430..9d8ec2786274 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/ApiOriginFilter.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/ApiOriginFilter.java
@@ -17,12 +17,12 @@
package org.openapitools.codegen.online.api;
-import javax.servlet.*;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.*;
+import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
-public class ApiOriginFilter implements javax.servlet.Filter {
+public class ApiOriginFilter implements jakarta.servlet.Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/ApiUtil.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/ApiUtil.java
index f6b510480a27..f9fdd623538f 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/ApiUtil.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/ApiUtil.java
@@ -19,7 +19,7 @@
import org.springframework.web.context.request.NativeWebRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
public class ApiUtil {
diff --git a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/GenApi.java b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/GenApi.java
index 70e077cacec0..dcd6a959156d 100644
--- a/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/GenApi.java
+++ b/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/api/GenApi.java
@@ -22,94 +22,125 @@
*/
package org.openapitools.codegen.online.api;
-import io.swagger.annotations.*;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.ExampleObject;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.online.model.GeneratorInput;
import org.openapitools.codegen.online.model.ResponseCode;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.bind.annotation.PostMapping;
-import javax.validation.Valid;
+import jakarta.validation.Valid;
import java.util.List;
import java.util.Map;
-@Api(value = "gen", description = "the gen API")
+@Tag(name = "clients", description = "Client generation APIs")
+@Tag(name = "servers", description = "Server generation APIs")
public interface GenApi {
GenApiDelegate getDelegate();
- @ApiOperation(value = "Gets languages supported by the client generator", nickname = "clientOptions", notes = "", response = String.class, responseContainer = "List", tags = {"clients",})
+ @Operation(summary = "Gets languages supported by the client generator", operationId = "clientOptions", tags = {"clients"})
@ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation", response = String.class, responseContainer = "List")})
- @RequestMapping(value = "/gen/clients",
- method = RequestMethod.GET)
+ @ApiResponse(responseCode = "200", description = "successful operation")})
+ @GetMapping("/gen/clients")
default ResponseEntity> clientOptions() {
return getDelegate().clientOptions();
}
- @ApiOperation(value = "Downloads a pre-generated file", nickname = "downloadFile", notes = "A valid `fileId` is generated by the `/clients/{language}` or `/servers/{language}` POST operations. The fileId code can be used just once, after which a new `fileId` will need to be requested.", response = MultipartFile.class, tags = {"clients", "servers",})
+ @Operation(summary = "Downloads a pre-generated file", operationId = "downloadFile", description = "A valid `fileId` is generated by the `/clients/{language}` or `/servers/{language}` POST operations. The fileId code can be used just once, after which a new `fileId` will need to be requested.", tags = {"clients", "servers"})
@ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation", response = MultipartFile.class)})
- @RequestMapping(value = "/gen/download/{fileId}",
- produces = {"application/octet-stream"},
- method = RequestMethod.GET)
- default ResponseEntity downloadFile(@ApiParam(value = "", required = true) @PathVariable("fileId") String fileId) {
+ @ApiResponse(responseCode = "200", description = "successful operation")})
+ @GetMapping(value = "/gen/download/{fileId}",
+ produces = {"application/octet-stream"})
+ default ResponseEntity downloadFile(@Parameter(description = "", required = true) @PathVariable String fileId) {
return getDelegate().downloadFile(fileId);
}
- @ApiOperation(value = "Generates a client library", nickname = "generateClient", notes = "Accepts a `GeneratorInput` options map for spec location and generation options", response = ResponseCode.class, tags = {"clients",})
+ @Operation(summary = "Generates a client library", operationId = "generateClient", description = "Accepts a `GeneratorInput` options map for spec location and generation options", tags = {"clients"})
@ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation", response = ResponseCode.class)})
- @RequestMapping(value = "/gen/clients/{language}",
- method = RequestMethod.POST)
- default ResponseEntity generateClient(@ApiParam(value = "The target language for the client library", required = true) @PathVariable("language") String language, @ApiParam(value = "Configuration for building the client library", required = true) @Valid @RequestBody GeneratorInput generatorInput) {
+ @ApiResponse(responseCode = "200", description = "successful operation")})
+ @PostMapping(value = "/gen/clients/{language}", consumes = "application/json", produces = "application/json")
+ default ResponseEntity generateClient(
+ @Parameter(description = "The target language for the client library", required = true, example = "java")
+ @PathVariable String language,
+ @RequestBody(description = "Configuration for building the client library", required = true,
+ content = @Content(mediaType = "application/json",
+ schema = @Schema(implementation = GeneratorInput.class),
+ examples = {
+ @ExampleObject(name = "Basic Example",
+ summary = "Basic client generation with OpenAPI URL",
+ value = "{\"openAPIUrl\": \"https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml\", \"options\": {\"packageName\": \"com.example.client\", \"clientPackage\": \"com.example.client\"}}"),
+ @ExampleObject(name = "With Options",
+ summary = "Client generation with additional options",
+ value = "{\"openAPIUrl\": \"https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml\", \"options\": {\"packageName\": \"com.example.petstore\", \"clientPackage\": \"com.example.petstore.client\", \"groupId\": \"com.example\", \"artifactId\": \"petstore-client\", \"artifactVersion\": \"1.0.0\"}}")
+ }))
+ @Valid
+ @org.springframework.web.bind.annotation.RequestBody GeneratorInput generatorInput) {
return getDelegate().generateClient(language, generatorInput);
}
- @ApiOperation(value = "Generates a server library", nickname = "generateServerForLanguage", notes = "Accepts a `GeneratorInput` options map for spec location and generation options.", response = ResponseCode.class, tags = {"servers",})
+ @Operation(summary = "Generates a server library", operationId = "generateServerForLanguage", description = "Accepts a `GeneratorInput` options map for spec location and generation options.", tags = {"servers"})
@ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation", response = ResponseCode.class)})
- @RequestMapping(value = "/gen/servers/{framework}",
- method = RequestMethod.POST)
- default ResponseEntity generateServerForLanguage(@ApiParam(value = "framework", required = true) @PathVariable("framework") String framework, @ApiParam(value = "parameters", required = true) @Valid @RequestBody GeneratorInput generatorInput) {
+ @ApiResponse(responseCode = "200", description = "successful operation")})
+ @PostMapping(value = "/gen/servers/{framework}", consumes = "application/json", produces = "application/json")
+ default ResponseEntity generateServerForLanguage(
+ @Parameter(description = "The target server framework", required = true, example = "spring")
+ @PathVariable String framework,
+ @RequestBody(description = "Configuration for building the server library", required = true,
+ content = @Content(mediaType = "application/json",
+ schema = @Schema(implementation = GeneratorInput.class),
+ examples = {
+ @ExampleObject(name = "Basic Example",
+ summary = "Basic server generation with OpenAPI URL",
+ value = "{\"openAPIUrl\": \"https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml\", \"options\": {\"packageName\": \"com.example.server\", \"basePackage\": \"com.example.server\"}}"),
+ @ExampleObject(name = "Spring Boot Server",
+ summary = "Spring Boot server generation with options",
+ value = "{\"openAPIUrl\": \"https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml\", \"options\": {\"packageName\": \"com.example.petstore.server\", \"basePackage\": \"com.example.petstore\", \"groupId\": \"com.example\", \"artifactId\": \"petstore-server\", \"artifactVersion\": \"1.0.0\"}}")
+ }))
+ @Valid
+ @org.springframework.web.bind.annotation.RequestBody
+ GeneratorInput generatorInput) {
return getDelegate().generateServerForLanguage(framework, generatorInput);
}
- @ApiOperation(value = "Returns options for a client library", nickname = "getClientOptions", notes = "", tags = {"clients",})
+ @Operation(summary = "Returns options for a client library", operationId = "getClientOptions", tags = {"clients"})
@ApiResponses(value = {
- @ApiResponse(code = 200, message = "successful operation")})
- @RequestMapping(value = "/gen/clients/{language}",
- produces = {"application/json"},
- method = RequestMethod.GET)
- default ResponseEntity