Bug Report Checklist
Description
Spring openapi-generator-maven-plugin doesn't support oneOf.

openapi-generator version
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: string
Generation 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 reproduce
- create a pom.xml with openapi-generator-maven-plugin 4.3.1
- create api.yml file above
- mvn clean generate-sources
- see broken code under target directory codegen\server\src\main\java\org\openapitools\model -> MainClass
Related issues/PRs
Suggest a fix
This bug is related to the Server side Java code (SpringBoot)
#2906
Bug Report Checklist
Description
Spring openapi-generator-maven-plugin doesn't support oneOf.

openapi-generator version
4.3.1
pom.xmlOpenAPI declaration file content or url
I tried to generate:
api.ymlGeneration Details
When I use
I get MainClass
which contains list of interfaces MainClassFieldNameOneOf. And ObjectA and ObjectB implement this interface.
Things are good.
BUT need SPRING and when use
the interface OneOfObjectAObjectB is not generated
Steps to reproduce
Related issues/PRs
Suggest a fix
This bug is related to the Server side Java code (SpringBoot)
#2906