You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
If I specify a field, that is "oneOf" two types, a new type is generated, which contains a superset of all fields in those two types
(or perhaps more than two) - so far correct.
However if those two types contain required fields, the generated superset type also contains required fields, probably for any field, that is required in any of oneOf types, not only for intersection (see example)
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-betslip-schema</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpecRootDirectory>${project.build.directory}/classes/oas/foo</inputSpecRootDirectory>
<generatorName>kotlin</generatorName>
<configOptions>
<library>jvm-ktor</library>
<serializationLibrary>jackson</serializationLibrary>
<modelMutable>true</modelMutable> <!-- true or false, makes no difference in this -->
<enumPropertyNaming>UPPERCASE</enumPropertyNaming>
<sourceFolder>src/main/kotlin</sourceFolder>
<additionalModelTypeAnnotations>@com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY)</additionalModelTypeAnnotations>
</configOptions>
<openapiNormalizer>REF_AS_PARENT_IN_ALLOF=true</openapiNormalizer>
<generateApis>false</generateApis>
<generateModelTests>false</generateModelTests>
<generateApiTests>false</generateApiTests>
<generateSupportingFiles>false</generateSupportingFiles>
<modelPackage>foo.model</modelPackage>
<packageName>foo</packageName>
<additionalProperties>removeEnumValuePrefix=false</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
Expected vs actual
Generated code:
data class SupersetOneOfType (
@field:JsonProperty("fieldA")
val fieldA: kotlin.Int, //this should be Int?
@field:JsonProperty("commonField")
val commonField: kotlin.Int, //OK to be Int!!
@field:JsonProperty("fieldB")
val fieldB: kotlin.Int //this should be Int?
)
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
If I specify a field, that is "oneOf" two types, a new type is generated, which contains a superset of all fields in those two types
(or perhaps more than two) - so far correct.
However if those two types contain required fields, the generated superset type also contains required fields, probably for any field, that is required in any of oneOf types, not only for intersection (see example)
openapi-generator version
7.10
OpenAPI declaration file content or url
Generation Details
Expected vs actual
Generated code:
The text was updated successfully, but these errors were encountered: