Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3596
Closed
Open
Issue created Aug 09, 2019 by Administrator@rootContributor

[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:

  • https://github.com/OpenAPITools/openapi-generator/issues/1205
  • https://github.com/OpenAPITools/openapi-generator/issues/3587
Assignee
Assign to
Time tracking