Openapi-generator: [KotlinSpring] Generated model is invalid if 'inheritance' is used

Created on 9 Oct 2018  路  3Comments  路  Source: OpenAPITools/openapi-generator

Description

The Kotlin Spring generator currently generates inheritance of data classes if a schema/type uses allOf and $ref. Kotlin data classes do not support inheritance, so this is invalid code.

The generator will need to generate properties from the main object, as well as the sub-object directly.

openapi-generator version

3.2.3, 3.3.0 and 3.3.1-SNAPSHOT

OpenAPI declaration file content or url

https://gitlab.com/mikezx6r/openapi-test/blob/master/src/main/resources/api.yml

Command line used for generation

Using Gradle. kotlin-spring language. Refer to https://gitlab.com/mikezx6r/openapi-test/blob/master/build.gradle for specifics.

Steps to reproduce

./gradlew oAGenerate and view the models generated into the src/main/generated-kotlin folder

Related issues/PRs
Suggest a fix/enhancement

The data class needs to contain all the properties from itself as well as from the 'child' class directly.

Feature Composition / Inheritance Kotlin

Most helpful comment

Just tested, and this is fixed in 4.0.0-beta. A data class is generated with all the properties explicitly defined rather than attempting invalid inheritance. Now just need that to be released ;)

All 3 comments

Hi,

Tested with the 3.3.3 and still not working.

Best

Just tested, and this is fixed in 4.0.0-beta. A data class is generated with all the properties explicitly defined rather than attempting invalid inheritance. Now just need that to be released ;)

@wing328 Maybe this Issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings