[BUG][kotlin-spring] "SwaggerAnnotations=true" leads into compile error when using inheritance
Created by: d0x
Description
When using inheritance, the generated code won't compile. It fails with this error:
This annotation is not applicable to target 'member property without backing field or delegate'
You can see it in this example:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "animalType", visible = true)
@JsonSubTypes(
JsonSubTypes.Type(value = Pet::class, name = "Pet")
)
interface Animal{
@ApiModelProperty(example = "null", value = "")
// ^^^^^^^^^^^^^^^^^^^ This annotation is not applicable to target 'member property without backing field or delegate'
val weight: java.math.BigDecimal?
}
openapi-generator version
Generator Version 4.0.3 Spec Version 3.0.1
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: example
version: 1.0.0
paths:
/test:
get:
responses:
200:
description: successful operation
components:
schemas:
Animal:
type: object
properties:
weight:
type: number
discriminator:
propertyName: animalType
required:
- animalType
Pet:
allOf:
- $ref: "#/components/schemas/Animal"
- type: object
properties:
name:
type: string
Command line used for generation
openapi-generator generate -i myspec.yml -g kotlin-spring \
-Dmodels \
-Dapis \
--additional-properties=interfaceOnly=true \
--additional-properties=gradleBuildFile=false \
--additional-properties=exceptionHandler=false \
--additional-properties swaggerAnnotations=true \
--additional-properties=sourceFolder=src/gen/kotlin
Steps to reproduce
Generate the spec above and check the Animal class.
Related issues/PRs
There is another issue related to inheritance: