|
22 | 22 | */ |
23 | 23 | package org.openapitools.codegen.online.api; |
24 | 24 |
|
25 | | -import io.swagger.annotations.*; |
| 25 | +import io.swagger.v3.oas.annotations.Operation; |
| 26 | +import io.swagger.v3.oas.annotations.Parameter; |
| 27 | +import io.swagger.v3.oas.annotations.media.Content; |
| 28 | +import io.swagger.v3.oas.annotations.media.ExampleObject; |
| 29 | +import io.swagger.v3.oas.annotations.media.Schema; |
| 30 | +import io.swagger.v3.oas.annotations.parameters.RequestBody; |
| 31 | +import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| 32 | +import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| 33 | +import io.swagger.v3.oas.annotations.tags.Tag; |
26 | 34 | import org.openapitools.codegen.CliOption; |
27 | 35 | import org.openapitools.codegen.online.model.GeneratorInput; |
28 | 36 | import org.openapitools.codegen.online.model.ResponseCode; |
29 | 37 | import org.springframework.core.io.Resource; |
30 | 38 | import org.springframework.http.ResponseEntity; |
| 39 | +import org.springframework.web.bind.annotation.GetMapping; |
31 | 40 | import org.springframework.web.bind.annotation.PathVariable; |
32 | | -import org.springframework.web.bind.annotation.RequestBody; |
33 | | -import org.springframework.web.bind.annotation.RequestMapping; |
34 | | -import org.springframework.web.bind.annotation.RequestMethod; |
35 | | -import org.springframework.web.multipart.MultipartFile; |
| 41 | +import org.springframework.web.bind.annotation.PostMapping; |
36 | 42 |
|
37 | | -import javax.validation.Valid; |
| 43 | +import jakarta.validation.Valid; |
38 | 44 | import java.util.List; |
39 | 45 | import java.util.Map; |
40 | 46 |
|
41 | | -@Api(value = "gen", description = "the gen API") |
| 47 | +@Tag(name = "clients", description = "Client generation APIs") |
| 48 | +@Tag(name = "servers", description = "Server generation APIs") |
42 | 49 | public interface GenApi { |
43 | 50 | GenApiDelegate getDelegate(); |
44 | 51 |
|
45 | | - @ApiOperation(value = "Gets languages supported by the client generator", nickname = "clientOptions", notes = "", response = String.class, responseContainer = "List", tags = {"clients",}) |
| 52 | + @Operation(summary = "Gets languages supported by the client generator", operationId = "clientOptions", tags = {"clients"}) |
46 | 53 | @ApiResponses(value = { |
47 | | - @ApiResponse(code = 200, message = "successful operation", response = String.class, responseContainer = "List")}) |
48 | | - @RequestMapping(value = "/gen/clients", |
49 | | - method = RequestMethod.GET) |
| 54 | + @ApiResponse(responseCode = "200", description = "successful operation")}) |
| 55 | + @GetMapping("/gen/clients") |
50 | 56 | default ResponseEntity<List<String>> clientOptions() { |
51 | 57 | return getDelegate().clientOptions(); |
52 | 58 | } |
53 | 59 |
|
54 | 60 |
|
55 | | - @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",}) |
| 61 | + @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"}) |
56 | 62 | @ApiResponses(value = { |
57 | | - @ApiResponse(code = 200, message = "successful operation", response = MultipartFile.class)}) |
58 | | - @RequestMapping(value = "/gen/download/{fileId}", |
59 | | - produces = {"application/octet-stream"}, |
60 | | - method = RequestMethod.GET) |
61 | | - default ResponseEntity<Resource> downloadFile(@ApiParam(value = "", required = true) @PathVariable("fileId") String fileId) { |
| 63 | + @ApiResponse(responseCode = "200", description = "successful operation")}) |
| 64 | + @GetMapping(value = "/gen/download/{fileId}", |
| 65 | + produces = {"application/octet-stream"}) |
| 66 | + default ResponseEntity<Resource> downloadFile(@Parameter(description = "", required = true) @PathVariable String fileId) { |
62 | 67 | return getDelegate().downloadFile(fileId); |
63 | 68 | } |
64 | 69 |
|
65 | 70 |
|
66 | | - @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",}) |
| 71 | + @Operation(summary = "Generates a client library", operationId = "generateClient", description = "Accepts a `GeneratorInput` options map for spec location and generation options", tags = {"clients"}) |
67 | 72 | @ApiResponses(value = { |
68 | | - @ApiResponse(code = 200, message = "successful operation", response = ResponseCode.class)}) |
69 | | - @RequestMapping(value = "/gen/clients/{language}", |
70 | | - method = RequestMethod.POST) |
71 | | - default ResponseEntity<ResponseCode> 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) { |
| 73 | + @ApiResponse(responseCode = "200", description = "successful operation")}) |
| 74 | + @PostMapping(value = "/gen/clients/{language}", consumes = "application/json", produces = "application/json") |
| 75 | + default ResponseEntity<ResponseCode> generateClient( |
| 76 | + @Parameter(description = "The target language for the client library", required = true, example = "java") |
| 77 | + @PathVariable String language, |
| 78 | + @RequestBody(description = "Configuration for building the client library", required = true, |
| 79 | + content = @Content(mediaType = "application/json", |
| 80 | + schema = @Schema(implementation = GeneratorInput.class), |
| 81 | + examples = { |
| 82 | + @ExampleObject(name = "Basic Example", |
| 83 | + summary = "Basic client generation with OpenAPI URL", |
| 84 | + 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\"}}"), |
| 85 | + @ExampleObject(name = "With Options", |
| 86 | + summary = "Client generation with additional options", |
| 87 | + 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\"}}") |
| 88 | + })) |
| 89 | + @Valid GeneratorInput generatorInput) { |
72 | 90 | return getDelegate().generateClient(language, generatorInput); |
73 | 91 | } |
74 | 92 |
|
75 | 93 |
|
76 | | - @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",}) |
| 94 | + @Operation(summary = "Generates a server library", operationId = "generateServerForLanguage", description = "Accepts a `GeneratorInput` options map for spec location and generation options.", tags = {"servers"}) |
77 | 95 | @ApiResponses(value = { |
78 | | - @ApiResponse(code = 200, message = "successful operation", response = ResponseCode.class)}) |
79 | | - @RequestMapping(value = "/gen/servers/{framework}", |
80 | | - method = RequestMethod.POST) |
81 | | - default ResponseEntity<ResponseCode> generateServerForLanguage(@ApiParam(value = "framework", required = true) @PathVariable("framework") String framework, @ApiParam(value = "parameters", required = true) @Valid @RequestBody GeneratorInput generatorInput) { |
| 96 | + @ApiResponse(responseCode = "200", description = "successful operation")}) |
| 97 | + @PostMapping(value = "/gen/servers/{framework}", consumes = "application/json", produces = "application/json") |
| 98 | + default ResponseEntity<ResponseCode> generateServerForLanguage( |
| 99 | + @Parameter(description = "The target server framework", required = true, example = "spring") |
| 100 | + @PathVariable String framework, |
| 101 | + @RequestBody(description = "Configuration for building the server library", required = true, |
| 102 | + content = @Content(mediaType = "application/json", |
| 103 | + schema = @Schema(implementation = GeneratorInput.class), |
| 104 | + examples = { |
| 105 | + @ExampleObject(name = "Basic Example", |
| 106 | + summary = "Basic server generation with OpenAPI URL", |
| 107 | + 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\"}}"), |
| 108 | + @ExampleObject(name = "Spring Boot Server", |
| 109 | + summary = "Spring Boot server generation with options", |
| 110 | + 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\"}}") |
| 111 | + })) |
| 112 | + @Valid GeneratorInput generatorInput) { |
82 | 113 | return getDelegate().generateServerForLanguage(framework, generatorInput); |
83 | 114 | } |
84 | 115 |
|
85 | 116 |
|
86 | | - @ApiOperation(value = "Returns options for a client library", nickname = "getClientOptions", notes = "", tags = {"clients",}) |
| 117 | + @Operation(summary = "Returns options for a client library", operationId = "getClientOptions", tags = {"clients"}) |
87 | 118 | @ApiResponses(value = { |
88 | | - @ApiResponse(code = 200, message = "successful operation")}) |
89 | | - @RequestMapping(value = "/gen/clients/{language}", |
90 | | - produces = {"application/json"}, |
91 | | - method = RequestMethod.GET) |
92 | | - default ResponseEntity<Map<String, CliOption>> getClientOptions(@ApiParam(value = "The target language for the client library", required = true) @PathVariable("language") String language) { |
| 119 | + @ApiResponse(responseCode = "200", description = "successful operation")}) |
| 120 | + @GetMapping(value = "/gen/clients/{language}", |
| 121 | + produces = {"application/json"}) |
| 122 | + default ResponseEntity<Map<String, CliOption>> getClientOptions(@Parameter(description = "The target language for the client library", required = true) @PathVariable String language) { |
93 | 123 | return getDelegate().getClientOptions(language); |
94 | 124 | } |
95 | 125 |
|
96 | 126 |
|
97 | | - @ApiOperation(value = "Returns options for a server framework", nickname = "getServerOptions", notes = "", tags = {"servers",}) |
| 127 | + @Operation(summary = "Returns options for a server framework", operationId = "getServerOptions", tags = {"servers"}) |
98 | 128 | @ApiResponses(value = { |
99 | | - @ApiResponse(code = 200, message = "successful operation")}) |
100 | | - @RequestMapping(value = "/gen/servers/{framework}", |
101 | | - produces = {"application/json"}, |
102 | | - method = RequestMethod.GET) |
103 | | - default ResponseEntity<Map<String, CliOption>> getServerOptions(@ApiParam(value = "The target language for the server framework", required = true) @PathVariable("framework") String framework) { |
| 129 | + @ApiResponse(responseCode = "200", description = "successful operation")}) |
| 130 | + @GetMapping(value = "/gen/servers/{framework}", |
| 131 | + produces = {"application/json"}) |
| 132 | + default ResponseEntity<Map<String, CliOption>> getServerOptions(@Parameter(description = "The target language for the server framework", required = true) @PathVariable String framework) { |
104 | 133 | return getDelegate().getServerOptions(framework); |
105 | 134 | } |
106 | 135 |
|
107 | 136 |
|
108 | | - @ApiOperation(value = "Gets languages supported by the server generator", nickname = "serverOptions", notes = "", response = String.class, responseContainer = "List", tags = {"servers",}) |
| 137 | + @Operation(summary = "Gets languages supported by the server generator", operationId = "serverOptions", tags = {"servers"}) |
109 | 138 | @ApiResponses(value = { |
110 | | - @ApiResponse(code = 200, message = "successful operation", response = String.class, responseContainer = "List")}) |
111 | | - @RequestMapping(value = "/gen/servers", |
112 | | - method = RequestMethod.GET) |
| 139 | + @ApiResponse(responseCode = "200", description = "successful operation")}) |
| 140 | + @GetMapping("/gen/servers") |
113 | 141 | default ResponseEntity<List<String>> serverOptions() { |
114 | 142 | return getDelegate().serverOptions(); |
115 | 143 | } |
|
0 commit comments