Open honzour opened 1 year ago
Here is the incorrect generated Kotlin file:
package mypackage.openapi
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonValue
import mypackage.openapi.Cat
import mypackage.openapi.Dog
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Email
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.v3.oas.annotations.media.Schema
/**
*
@param petType
@param hunts
@param age
*/
data class ZOOAnimalsInner(
@Schema(example = "null", required = true, description = "")
@get:JsonProperty("pet_type", required = true) val petType: kotlin.String,
@Schema(example = "null", required = true, description = "")
@get:JsonProperty("hunts", required = true) val hunts: kotlin.Boolean,
@Schema(example = "null", required = true, description = "")
@get:JsonProperty("age", required = true) val age: kotlin.Int,
@Schema(example = "null", required = true, description = "")
@get:JsonProperty("bark", required = true) override val bark: kotlin.Boolean,
@Schema(example = "null", required = true, description = "")
@get:JsonProperty("breed", required = true) override val breed: ZOOAnimalsInner.Breed
) {
}
Description
Openapi generator into kotlin-spring generates incorrect kotlin code when I use list (ZOO) of child objects (Cats or Dog) with the common inheritance parent (Pet) in the openapi definition. It creates a data class ZOOAnimalsInner with all fields required, does matter if it is field of Cat, Dog or Pet.
openapi-generator version
6.6.0
OpenAPI declaration file content or url
Suggest a fix
Fields of Cat and fields of Dog shlould be optional in the generated class ZOOAnimalsInner.