Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Spring generated code to use new OAS 3 annotations #9775

Merged
merged 33 commits into from
Nov 2, 2021
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
58c3eff
Resolve #9774
welshm Jun 15, 2021
2d68708
Merge pull request #1 from OpenAPITools/master
welshm Jun 15, 2021
e7919ce
Update spring examples
welshm Jun 15, 2021
baaa0e3
Merge branch 'master' into allow_oas3_annotations
welshm Jun 15, 2021
40e09bc
Update with a clean maven install and regenerate samples
welshm Jun 15, 2021
b603d34
Remove newling at end of param files and regenerate samples
welshm Jun 15, 2021
a3d03bb
Merge pull request #5 from OpenAPITools/master
welshm Jul 30, 2021
31fcabf
Merge branch 'master' into allow_oas3_annotations
welshm Jul 30, 2021
169ce75
Update codegen with merge from master
welshm Jul 30, 2021
8c30649
Merge branch 'master' of github.com:OpenAPITools/openapi-generator
welshm Aug 23, 2021
ef35531
Merge branch 'master' into allow_oas3_annotations
welshm Aug 23, 2021
8b45b76
Update tests and samples
welshm Aug 23, 2021
c531860
Merge branch 'allow_oas3_annotations' of github.com:welshm/openapi-ge…
welshm Aug 23, 2021
c4d9aaa
Remove #vendorParams from API
welshm Aug 23, 2021
2e55e97
Update generated and tests
welshm Aug 23, 2021
ff61560
Merge branch 'master' into allow_oas3_annotations
welshm Sep 2, 2021
0e75696
Get closer to master
welshm Sep 2, 2021
d31f945
Remove SpringFox setter boolean
welshm Sep 2, 2021
814ff7f
Update examples and tests
welshm Sep 2, 2021
b01f425
FIx pojo.mustache (missed update to master) and regenerate tests
welshm Sep 2, 2021
087b1bf
Fix pojo.mustache extra `(`
welshm Sep 2, 2021
a30aca9
Update tests and documentation
welshm Sep 2, 2021
259ed1d
Merge branch 'master' into allow_oas3_annotations
welshm Oct 15, 2021
39110db
Merge branch 'master' into allow_oas3_annotations
welshm Oct 15, 2021
dbd76ee
Update models and documentation
welshm Oct 15, 2021
ef55d27
Merge branch 'allow_oas3_annotations' of github.com:welshm/openapi-ge…
welshm Oct 15, 2021
c03f8fa
Handle boolean property correctly
welshm Oct 19, 2021
08c1bae
Fix more @ApiParam usage with @Parameter
welshm Oct 22, 2021
290dcad
Update samples
welshm Oct 22, 2021
fa01eb3
Merge branch 'master' into allow_oas3_annotations
welshm Oct 22, 2021
2275bfa
Update maven `pom.xml` mustache to use OAS3 annotations
welshm Oct 22, 2021
59e9326
FIx typo in variable name
welshm Oct 24, 2021
f56a96a
Write back `useSpringfox` property
welshm Oct 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
Update spring examples
welshm committed Jun 15, 2021
commit e7919ceb9da68deb6d300a5d5a968f8580ca3e5e
3 changes: 3 additions & 0 deletions docs/generators/spring.md
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|modelPackage|package for generated models| |org.openapitools.model|
|oas3|Use OAS 3 Swagger annotations instead of OAS 2 annotations| |false|
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
|parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
|parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
@@ -64,11 +65,13 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src/main/java|
|springController|Annotate the generated API as a Spring Controller| |false|
|swaggerDocketConfig|Generate Spring OpenAPI Docket configuration class.| |false|
|title|server title name or client service name| |OpenAPI Spring|
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false|
|useBeanValidation|Use BeanValidation API annotations| |true|
|useOptional|Use Optional container for optional parameters| |false|
|useSpringfox|Whether or not to use Springfox. Defaults to true| |true|
|useTags|use tags for creating interface and controller classnames| |false|
|virtualService|Generates the virtual service. For more details refer - https://github.com/virtualansoftware/virtualan/wiki| |false|
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
Original file line number Diff line number Diff line change
@@ -79,8 +79,7 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture
{{#useSpringController}}
@Controller
{{/useSpringController}}
{{#oas3}}@Tag(name = "{{{baseName}}}", description = "the {{{baseName}}} API"){{/oas3}}
{{^oas3}}@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API"){{/oas3}}
{{#oas3}}@Tag(name = "{{{baseName}}}", description = "the {{{baseName}}} API"){{/oas3}}{{^oas3}}@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API"){{/oas3}}
{{#operations}}
{{#virtualService}}
@VirtualService
@@ -141,7 +140,7 @@ public interface {{classname}} {
{{/oas3}}
{{#implicitHeaders}}
{{#oas3}}
@Parameters(
@Parameters({
{{/oas3}}
{{^oas3}}
@ApiImplicitParams({
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import java.util.concurrent.CompletableFuture;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated

@Api(value = "Pet", description = "the Pet API")
public interface PetApi {

@@ -34,6 +35,7 @@ public interface PetApi {
* @param body Pet object that needs to be added to the store (required)
* @return Invalid input (status code 405)
*/

@ApiOperation(value = "Add a new pet to the store", nickname = "addPet", notes = "", authorizations = {
@Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@@ -45,7 +47,11 @@ public interface PetApi {
value = "/pet",
consumes = "application/json"
)
CompletableFuture<ResponseEntity<Void>> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
CompletableFuture<ResponseEntity<Void>> addPet(


@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body
);


/**
@@ -55,6 +61,7 @@ public interface PetApi {
* @param apiKey (optional)
* @return Invalid pet value (status code 400)
*/

@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
@Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@@ -65,7 +72,15 @@ public interface PetApi {
@DeleteMapping(
value = "/pet/{petId}"
)
CompletableFuture<ResponseEntity<Void>> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey);
CompletableFuture<ResponseEntity<Void>> deletePet(
@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId


,

@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey

);


/**
@@ -76,6 +91,7 @@ public interface PetApi {
* @return successful operation (status code 200)
* or Invalid status value (status code 400)
*/

@ApiOperation(value = "Finds Pets by status", nickname = "findPetsByStatus", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = {
@Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@@ -88,7 +104,11 @@ public interface PetApi {
value = "/pet/findByStatus",
produces = "application/json"
)
CompletableFuture<ResponseEntity<List<Pet>>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status);
CompletableFuture<ResponseEntity<List<Pet>>> findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) List<String> status



);


/**
@@ -100,6 +120,7 @@ public interface PetApi {
* or Invalid tag value (status code 400)
* @deprecated
*/

@ApiOperation(value = "Finds Pets by tags", nickname = "findPetsByTags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
@Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@@ -112,7 +133,11 @@ public interface PetApi {
value = "/pet/findByTags",
produces = "application/json"
)
CompletableFuture<ResponseEntity<List<Pet>>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags);
CompletableFuture<ResponseEntity<List<Pet>>> findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> tags



);


/**
@@ -124,6 +149,7 @@ public interface PetApi {
* or Invalid ID supplied (status code 400)
* or Pet not found (status code 404)
*/

@ApiOperation(value = "Find pet by ID", nickname = "getPetById", notes = "Returns a single pet", response = Pet.class, authorizations = {

@Authorization(value = "api_key")
@@ -136,7 +162,11 @@ public interface PetApi {
value = "/pet/{petId}",
produces = "application/json"
)
CompletableFuture<ResponseEntity<Pet>> getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId);
CompletableFuture<ResponseEntity<Pet>> getPetById(
@ApiParam(value = "ID of pet to return",required=true) @PathVariable("petId") Long petId


);


/**
@@ -147,6 +177,7 @@ public interface PetApi {
* or Pet not found (status code 404)
* or Validation exception (status code 405)
*/

@ApiOperation(value = "Update an existing pet", nickname = "updatePet", notes = "", authorizations = {
@Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@@ -160,7 +191,11 @@ public interface PetApi {
value = "/pet",
consumes = "application/json"
)
CompletableFuture<ResponseEntity<Void>> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
CompletableFuture<ResponseEntity<Void>> updatePet(


@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body
);


/**
@@ -171,6 +206,7 @@ public interface PetApi {
* @param status Updated status of the pet (optional)
* @return Invalid input (status code 405)
*/

@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
@Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@@ -182,7 +218,19 @@ public interface PetApi {
value = "/pet/{petId}",
consumes = "application/x-www-form-urlencoded"
)
CompletableFuture<ResponseEntity<Void>> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status);
CompletableFuture<ResponseEntity<Void>> updatePetWithForm(
@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId


,



@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name,



@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status);


/**
@@ -193,6 +241,7 @@ public interface PetApi {
* @param file file to upload (optional)
* @return successful operation (status code 200)
*/

@ApiOperation(value = "uploads an image", nickname = "uploadFile", notes = "", response = ModelApiResponse.class, authorizations = {
@Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@@ -205,6 +254,18 @@ public interface PetApi {
produces = "application/json",
consumes = "multipart/form-data"
)
CompletableFuture<ResponseEntity<ModelApiResponse>> uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,@ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file);
CompletableFuture<ResponseEntity<ModelApiResponse>> uploadFile(
@ApiParam(value = "ID of pet to update",required=true) @PathVariable("petId") Long petId


,



@ApiParam(value = "Additional data to pass to server" ) @RequestParam(value="additionalMetadata", required=false) String additionalMetadata,



@ApiParam(value = "file to upload") @RequestParam("file") MultipartFile file);

}
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import java.util.concurrent.CompletableFuture;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated

@Api(value = "Store", description = "the Store API")
public interface StoreApi {

@@ -36,14 +37,19 @@ public interface StoreApi {
* @return Invalid ID supplied (status code 400)
* or Order not found (status code 404)
*/

@ApiOperation(value = "Delete purchase order by ID", nickname = "deleteOrder", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", tags={ "store", })
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "Order not found") })
@DeleteMapping(
value = "/store/order/{orderId}"
)
CompletableFuture<ResponseEntity<Void>> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId);
CompletableFuture<ResponseEntity<Void>> deleteOrder(
@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId


);


/**
@@ -52,6 +58,7 @@ public interface StoreApi {
*
* @return successful operation (status code 200)
*/

@ApiOperation(value = "Returns pet inventories by status", nickname = "getInventory", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {

@Authorization(value = "api_key")
@@ -74,6 +81,7 @@ public interface StoreApi {
* or Invalid ID supplied (status code 400)
* or Order not found (status code 404)
*/

@ApiOperation(value = "Find purchase order by ID", nickname = "getOrderById", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
@@ -83,7 +91,11 @@ public interface StoreApi {
value = "/store/order/{orderId}",
produces = "application/json"
)
CompletableFuture<ResponseEntity<Order>> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId);
CompletableFuture<ResponseEntity<Order>> getOrderById(
@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId


);


/**
@@ -93,6 +105,7 @@ public interface StoreApi {
* @return successful operation (status code 200)
* or Invalid Order (status code 400)
*/

@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
@@ -101,6 +114,10 @@ public interface StoreApi {
value = "/store/order",
produces = "application/json"
)
CompletableFuture<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
CompletableFuture<ResponseEntity<Order>> placeOrder(


@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body
);

}
Loading