Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][kotlin-spring] Doesn't create valid model when inheritance is used ($allOf) #3587

Closed
d0x opened this issue Aug 8, 2019 · 3 comments
Closed

Comments

@d0x
Copy link
Contributor

d0x commented Aug 8, 2019

Description

When using inheritance, the generated code won't compile. It fails with this error:

'xxx' hides member of supertype 'YYY' and needs 'override' modifier

You can see it in this example:

data class Pet(
        @JsonProperty("name") val name: kotlin.String? = null,
        @JsonProperty("weight") val weight: java.math.BigDecimal? = null
                                 // ^^^^^^ 'weight' hides member of supertype 'Animal' and needs 'override' modifier
) : Animal {}
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=sourceFolder=src/gen/kotlin
Steps to reproduce

Generate the spec above and check the Pet class.

Related issues/PRs

There is a similar issue which was fixed in 4.0.0.beta and openapi version 2.
But it seems like openapi version 3 breaks it.

#1205

@auto-labeler
Copy link

auto-labeler bot commented Aug 8, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@eliezio
Copy link

eliezio commented Mar 4, 2022

I tried to reproduce the given example and it seems it's already fixed for kotlin-spring generator v5.4.0.
@d0x can you pls confirm?

@d0x
Copy link
Contributor Author

d0x commented Mar 4, 2022

Thanks! Seems to be fixed. I tried the steps to reproduce and it compiles well. 👍🏻

@d0x d0x closed this as completed Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants