-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[spring] fix void return type for useResponseEntity: false (#16230)
* fix return type * add new sample config as test for the fix * update samples
- Loading branch information
1 parent
097385b
commit 6a3f0ff
Showing
82 changed files
with
13,641 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
generatorName: spring | ||
outputDir: samples/server/petstore/springboot-reactive-noResponseEntity | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring | ||
additionalProperties: | ||
groupId: org.openapitools.openapi3 | ||
artifactId: springboot-reactive-noResponseEntity | ||
documentationProvider: springfox | ||
reactive: "true" | ||
hideGenerationTimestamp: "true" | ||
delegatePattern: "true" | ||
useResponseEntity: "false" |
2 changes: 1 addition & 1 deletion
2
modules/openapi-generator/src/main/resources/JavaSpring/returnTypes.mustache
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 |
---|---|---|
@@ -1 +1 @@ | ||
{{#isMap}}Map<String, {{{returnType}}}>{{/isMap}}{{#isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}{{{returnContainer}}}{{/reactive}}<{{{returnType}}}>{{/isArray}}{{^returnContainer}}{{#useResponseEntity}}{{{returnType}}}{{/useResponseEntity}}{{^useResponseEntity}}{{#isDelegate}}{{#isVoid}}void{{/isVoid}}{{^isVoid}}{{{returnType}}}{{/isVoid}}{{/isDelegate}}{{^isDelegate}}{{#async}}{{{returnType}}}{{/async}}{{^async}}{{#isVoid}}void{{/isVoid}}{{^isVoid}}{{{returnType}}}{{/isVoid}}{{/async}}{{/isDelegate}}{{/useResponseEntity}}{{/returnContainer}} | ||
{{#isMap}}Map<String, {{{returnType}}}>{{/isMap}}{{#isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}{{{returnContainer}}}{{/reactive}}<{{{returnType}}}>{{/isArray}}{{^returnContainer}}{{#useResponseEntity}}{{{returnType}}}{{/useResponseEntity}}{{^useResponseEntity}}{{#isDelegate}}{{#isVoid}}{{#responseWrapper}}{{{returnType}}}{{/responseWrapper}}{{^responseWrapper}}void{{/responseWrapper}}{{/isVoid}}{{^isVoid}}{{{returnType}}}{{/isVoid}}{{/isDelegate}}{{^isDelegate}}{{#async}}{{{returnType}}}{{/async}}{{^async}}{{#isVoid}}{{#responseWrapper}}{{{returnType}}}{{/responseWrapper}}{{^responseWrapper}}void{{/responseWrapper}}{{/isVoid}}{{^isVoid}}{{{returnType}}}{{/isVoid}}{{/async}}{{/isDelegate}}{{/useResponseEntity}}{{/returnContainer}} |
23 changes: 23 additions & 0 deletions
23
samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator-ignore
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,23 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md |
76 changes: 76 additions & 0 deletions
76
samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/FILES
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,76 @@ | ||
README.md | ||
pom.xml | ||
src/main/java/org/openapitools/OpenApiGeneratorApplication.java | ||
src/main/java/org/openapitools/RFC3339DateFormat.java | ||
src/main/java/org/openapitools/api/AnotherFakeApi.java | ||
src/main/java/org/openapitools/api/AnotherFakeApiController.java | ||
src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java | ||
src/main/java/org/openapitools/api/ApiUtil.java | ||
src/main/java/org/openapitools/api/FakeApi.java | ||
src/main/java/org/openapitools/api/FakeApiController.java | ||
src/main/java/org/openapitools/api/FakeApiDelegate.java | ||
src/main/java/org/openapitools/api/FakeClassnameTestApi.java | ||
src/main/java/org/openapitools/api/FakeClassnameTestApiController.java | ||
src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java | ||
src/main/java/org/openapitools/api/PetApi.java | ||
src/main/java/org/openapitools/api/PetApiController.java | ||
src/main/java/org/openapitools/api/PetApiDelegate.java | ||
src/main/java/org/openapitools/api/StoreApi.java | ||
src/main/java/org/openapitools/api/StoreApiController.java | ||
src/main/java/org/openapitools/api/StoreApiDelegate.java | ||
src/main/java/org/openapitools/api/UserApi.java | ||
src/main/java/org/openapitools/api/UserApiController.java | ||
src/main/java/org/openapitools/api/UserApiDelegate.java | ||
src/main/java/org/openapitools/configuration/EnumConverterConfiguration.java | ||
src/main/java/org/openapitools/configuration/HomeController.java | ||
src/main/java/org/openapitools/model/AdditionalPropertiesAnyType.java | ||
src/main/java/org/openapitools/model/AdditionalPropertiesArray.java | ||
src/main/java/org/openapitools/model/AdditionalPropertiesBoolean.java | ||
src/main/java/org/openapitools/model/AdditionalPropertiesClass.java | ||
src/main/java/org/openapitools/model/AdditionalPropertiesInteger.java | ||
src/main/java/org/openapitools/model/AdditionalPropertiesNumber.java | ||
src/main/java/org/openapitools/model/AdditionalPropertiesObject.java | ||
src/main/java/org/openapitools/model/AdditionalPropertiesString.java | ||
src/main/java/org/openapitools/model/Animal.java | ||
src/main/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java | ||
src/main/java/org/openapitools/model/ArrayOfNumberOnly.java | ||
src/main/java/org/openapitools/model/ArrayTest.java | ||
src/main/java/org/openapitools/model/BigCat.java | ||
src/main/java/org/openapitools/model/Capitalization.java | ||
src/main/java/org/openapitools/model/Cat.java | ||
src/main/java/org/openapitools/model/Category.java | ||
src/main/java/org/openapitools/model/ClassModel.java | ||
src/main/java/org/openapitools/model/Client.java | ||
src/main/java/org/openapitools/model/ContainerDefaultValue.java | ||
src/main/java/org/openapitools/model/Dog.java | ||
src/main/java/org/openapitools/model/EnumArrays.java | ||
src/main/java/org/openapitools/model/EnumClass.java | ||
src/main/java/org/openapitools/model/EnumTest.java | ||
src/main/java/org/openapitools/model/File.java | ||
src/main/java/org/openapitools/model/FileSchemaTestClass.java | ||
src/main/java/org/openapitools/model/FormatTest.java | ||
src/main/java/org/openapitools/model/HasOnlyReadOnly.java | ||
src/main/java/org/openapitools/model/MapTest.java | ||
src/main/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java | ||
src/main/java/org/openapitools/model/Model200Response.java | ||
src/main/java/org/openapitools/model/ModelApiResponse.java | ||
src/main/java/org/openapitools/model/ModelList.java | ||
src/main/java/org/openapitools/model/ModelReturn.java | ||
src/main/java/org/openapitools/model/Name.java | ||
src/main/java/org/openapitools/model/NumberOnly.java | ||
src/main/java/org/openapitools/model/Order.java | ||
src/main/java/org/openapitools/model/OuterComposite.java | ||
src/main/java/org/openapitools/model/OuterEnum.java | ||
src/main/java/org/openapitools/model/Pet.java | ||
src/main/java/org/openapitools/model/ReadOnlyFirst.java | ||
src/main/java/org/openapitools/model/ResponseObjectWithDifferentFieldNames.java | ||
src/main/java/org/openapitools/model/SpecialModelName.java | ||
src/main/java/org/openapitools/model/Tag.java | ||
src/main/java/org/openapitools/model/TypeHolderDefault.java | ||
src/main/java/org/openapitools/model/TypeHolderExample.java | ||
src/main/java/org/openapitools/model/User.java | ||
src/main/java/org/openapitools/model/XmlItem.java | ||
src/main/resources/application.properties | ||
src/main/resources/openapi.yaml | ||
src/main/resources/static/swagger-ui.html | ||
src/test/java/org/openapitools/OpenApiGeneratorApplicationTests.java |
1 change: 1 addition & 0 deletions
1
samples/server/petstore/springboot-reactive-noResponseEntity/.openapi-generator/VERSION
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 @@ | ||
7.0.0-SNAPSHOT |
27 changes: 27 additions & 0 deletions
27
samples/server/petstore/springboot-reactive-noResponseEntity/README.md
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,27 @@ | ||
# OpenAPI generated server | ||
|
||
Spring Boot Server | ||
|
||
## Overview | ||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. | ||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. | ||
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. | ||
|
||
The underlying library integrating OpenAPI to Spring Boot is [springfox](https://github.com/springfox/springfox). | ||
Springfox will generate an OpenAPI v2 (fka Swagger RESTful API Documentation Specification) specification based on the | ||
generated Controller and Model classes. The specification is available to download using the following url: | ||
http://localhost:80/v2/api-docs/ | ||
|
||
**HEADS-UP**: Springfox is deprecated for removal in version 6.0.0 of openapi-generator. The project seems to be no longer | ||
maintained (last commit is of Oct 14, 2020). It works with Spring Boot 2.5.x but not with 2.6. Spring Boot 2.5 is | ||
supported until 2022-05-19. Users of openapi-generator should migrate to the springdoc documentation provider which is, | ||
as an added bonus, OpenAPI v3 compatible. | ||
|
||
|
||
|
||
Start your server as a simple java application | ||
|
||
You can view the api documentation in swagger-ui by pointing to | ||
http://localhost:80/swagger-ui.html | ||
|
||
Change default port value in application.properties |
89 changes: 89 additions & 0 deletions
89
samples/server/petstore/springboot-reactive-noResponseEntity/pom.xml
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,89 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.openapitools.openapi3</groupId> | ||
<artifactId>springboot-reactive-noResponseEntity</artifactId> | ||
<packaging>jar</packaging> | ||
<name>springboot-reactive-noResponseEntity</name> | ||
<version>1.0.0</version> | ||
<properties> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.source>${java.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.version}</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<springfox.version>2.9.2</springfox.version> | ||
<swagger-ui.version>4.15.5</swagger-ui.version> | ||
</properties> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.5.14</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-webflux</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-commons</artifactId> | ||
</dependency> | ||
<!--SpringFox dependencies --> | ||
<dependency> | ||
<groupId>io.springfox</groupId> | ||
<artifactId>springfox-swagger2</artifactId> | ||
<version>${springfox.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars</groupId> | ||
<artifactId>swagger-ui</artifactId> | ||
<version>${swagger-ui.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars</groupId> | ||
<artifactId>webjars-locator-core</artifactId> | ||
</dependency> | ||
<!-- @Nullable annotation --> | ||
<dependency> | ||
<groupId>com.google.code.findbugs</groupId> | ||
<artifactId>jsr305</artifactId> | ||
<version>3.0.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-yaml</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.datatype</groupId> | ||
<artifactId>jackson-datatype-jsr310</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openapitools</groupId> | ||
<artifactId>jackson-databind-nullable</artifactId> | ||
<version>0.2.6</version> | ||
</dependency> | ||
<!-- Bean Validation API support --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-validation</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
30 changes: 30 additions & 0 deletions
30
...reactive-noResponseEntity/src/main/java/org/openapitools/OpenApiGeneratorApplication.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,30 @@ | ||
package org.openapitools; | ||
|
||
import com.fasterxml.jackson.databind.Module; | ||
import org.openapitools.jackson.nullable.JsonNullableModule; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.FilterType; | ||
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator; | ||
|
||
@SpringBootApplication( | ||
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class | ||
) | ||
@ComponentScan( | ||
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"}, | ||
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class | ||
) | ||
public class OpenApiGeneratorApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(OpenApiGeneratorApplication.class, args); | ||
} | ||
|
||
@Bean(name = "org.openapitools.OpenApiGeneratorApplication.jsonNullableModule") | ||
public Module jsonNullableModule() { | ||
return new JsonNullableModule(); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...pringboot-reactive-noResponseEntity/src/main/java/org/openapitools/RFC3339DateFormat.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,38 @@ | ||
package org.openapitools; | ||
|
||
import com.fasterxml.jackson.databind.util.StdDateFormat; | ||
|
||
import java.text.DateFormat; | ||
import java.text.FieldPosition; | ||
import java.text.ParsePosition; | ||
import java.util.Date; | ||
import java.util.GregorianCalendar; | ||
import java.util.TimeZone; | ||
|
||
public class RFC3339DateFormat extends DateFormat { | ||
private static final long serialVersionUID = 1L; | ||
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); | ||
|
||
private final StdDateFormat fmt = new StdDateFormat() | ||
.withTimeZone(TIMEZONE_Z) | ||
.withColonInTimeZone(true); | ||
|
||
public RFC3339DateFormat() { | ||
this.calendar = new GregorianCalendar(); | ||
} | ||
|
||
@Override | ||
public Date parse(String source, ParsePosition pos) { | ||
return fmt.parse(source, pos); | ||
} | ||
|
||
@Override | ||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { | ||
return fmt.format(date, toAppendTo, fieldPosition); | ||
} | ||
|
||
@Override | ||
public Object clone() { | ||
return this; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...ringboot-reactive-noResponseEntity/src/main/java/org/openapitools/api/AnotherFakeApi.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,66 @@ | ||
/** | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.0.0-SNAPSHOT). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
package org.openapitools.api; | ||
|
||
import springfox.documentation.annotations.ApiIgnore; | ||
import org.openapitools.model.Client; | ||
import io.swagger.annotations.*; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import org.springframework.http.codec.multipart.Part; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.*; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.annotation.Generated; | ||
|
||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen") | ||
@Validated | ||
@Api(value = "$another-fake?", description = "the $another-fake? API") | ||
public interface AnotherFakeApi { | ||
|
||
default AnotherFakeApiDelegate getDelegate() { | ||
return new AnotherFakeApiDelegate() {}; | ||
} | ||
|
||
/** | ||
* PATCH /another-fake/dummy : To test special tags | ||
* To test special tags and operation ID starting with number | ||
* | ||
* @param client client model (required) | ||
* @return successful operation (status code 200) | ||
*/ | ||
@ApiOperation( | ||
tags = { "$another-fake?" }, | ||
value = "To test special tags", | ||
nickname = "call123testSpecialTags", | ||
notes = "To test special tags and operation ID starting with number", | ||
response = Client.class | ||
) | ||
@ApiResponses({ | ||
@ApiResponse(code = 200, message = "successful operation", response = Client.class) | ||
}) | ||
@RequestMapping( | ||
method = RequestMethod.PATCH, | ||
value = "/another-fake/dummy", | ||
produces = { "application/json" }, | ||
consumes = { "application/json" } | ||
) | ||
@ResponseStatus(HttpStatus.OK) | ||
default Mono<Client> call123testSpecialTags( | ||
@ApiParam(value = "client model", required = true) @Valid @RequestBody Mono<Client> client, | ||
@ApiIgnore final ServerWebExchange exchange | ||
) { | ||
return getDelegate().call123testSpecialTags(client, exchange); | ||
} | ||
|
||
} |
Oops, something went wrong.