Spring openapi-generator-maven-plugin doesn't support oneOf.
4.3.1
pom.xml
<plugin> <groupId>org.openapitools</groupId> <artifactId>openapi-generator-maven-plugin</artifactId> <version>4.3.1</version> <executions> <execution> <id>client</id> <goals> <goal>generate</goal> </goals> <phase>generate-sources</phase> <configuration> <inputSpec>api.yml</inputSpec> <output>codegen/client</output> <generatorName>java</generatorName> <configOptions> <library>resttemplate</library> <hideGenerationTimestamp>true</hideGenerationTimestamp> <serializableModel>false</serializableModel> <bigDecimalAsString>false</bigDecimalAsString> <dateLibrary>java8</dateLibrary> <java8>true</java8> <interfaceOnly>true</interfaceOnly> </configOptions> <generateApiTests>false</generateApiTests> <generateModelTests>false</generateModelTests> </configuration> </execution> <execution> <id>server</id> <goals> <goal>generate</goal> </goals> <phase>generate-sources</phase> <configuration> <inputSpec>api.yml</inputSpec> <output>codegen/server</output> <generatorName>spring</generatorName> <configOptions> <hideGenerationTimestamp>true</hideGenerationTimestamp> <serializableModel>false</serializableModel> <bigDecimalAsString>false</bigDecimalAsString> <dateLibrary>java8</dateLibrary> <java8>true</java8> <interfaceOnly>true</interfaceOnly> <useBeanValidation>true</useBeanValidation> </configOptions> </configuration> </execution> </executions> </plugin>OpenAPI declaration file content or url
I tried to generate:
api.yml
openapi: "3.0.0" info: version: "1.0" title: "Main" paths: /class: get: responses: 200: description: Ok content: application/json: schema: $ref: "#/components/schemas/MainClass" components: schemas: MainClass: type: object properties: fieldName: type: array items: oneOf: - $ref: "#/components/schemas/ObjectA" - $ref: "#/components/schemas/ObjectB" ObjectA: type: object properties: name: type: string ObjectB: type: object properties: name: type: stringGeneration Details
When I use
... <generatorName>java</generatorName> <configOptions> <library>resttemplate</library> ...
I get MainClass
... public class MainClass { public static final String JSON_PROPERTY_FIELD_NAME = "fieldName"; private List<MainClassFieldNameOneOf> fieldName = null; ...
which contains list of interfaces MainClassFieldNameOneOf. And ObjectA and ObjectB implement this interface.
Things are good.
BUT need SPRING and when use
... <generatorName>spring</generatorName> ...
the interface OneOfObjectAObjectB is not generated
Steps to reproduceThis bug is related to the Server side Java code (SpringBoot)
#2906
FedorSerg, disappearwang, joke and yennsarah
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4