Bug Report Checklist
Description
Openapi-generator equal or greater than 6.0.0 creates subclasses containing unexpected @JsonTypeInfo and @JsonSubTypes annotations. As per my understanding it should be only put on the Base class.
@JsonIgnoreProperties(
value = "category", // ignore manually set category, it will be automatically generated by Jackson during serialization
allowSetters = true // allows the category to be set during deserialization
)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "category", visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = First.class, name = "FIRST")
})
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2023-03-09T00:15:05.886973600+01:00[Europe/Warsaw]")
public class First extends Base implements Serializable {
Meanwhile the code generated by version 5.3.1 looks like I would expect it:
/**
* First
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2023-03-09T00:30:16.351405400+01:00[Europe/Warsaw]")
public class First extends Base implements Serializable {
openapi-generator version
v6.4.0
but happens pretty much with every version equal or greater than 6.0.0, including 6.5.0 and 7.0.0
OpenAPI declaration file content or url
Full example: https://github.com/WojciechZankowski/openapi-defects/blob/master/src/main/resources/openapi-inheritance-test.yaml
openapi: 3.0.3
info:
title: OpenAPI test
version: 1.0.0
paths: { }
components:
schemas:
Base:
type: object
required:
- category
properties:
category:
type: string
enum:
- FIRST
discriminator:
propertyName: category
mapping:
FIRST: '#/components/schemas/First'
First:
allOf:
- $ref: '#/components/schemas/Base'
required:
- value
properties:
value:
type: number
Generation Details
Code generation triggered through maven using openapi-maven-generator plugin. Command: mvn clean install
Bug Report Checklist
Description
Openapi-generator equal or greater than 6.0.0 creates subclasses containing unexpected
@JsonTypeInfoand@JsonSubTypesannotations. As per my understanding it should be only put on the Base class.Meanwhile the code generated by version 5.3.1 looks like I would expect it:
openapi-generator version
v6.4.0
but happens pretty much with every version equal or greater than 6.0.0, including 6.5.0 and 7.0.0
OpenAPI declaration file content or url
Full example: https://github.com/WojciechZankowski/openapi-defects/blob/master/src/main/resources/openapi-inheritance-test.yaml
Generation Details
Code generation triggered through maven using openapi-maven-generator plugin. Command:
mvn clean install