Skip to content

Generated code does not implement model inheritance correctly #602

Open
@trohrberg

Description

@trohrberg

In our business project based on Spring Boot, we're using swagger-codegen to generate model classes and REST controller interfaces for our API described in an OpenAPI 3.0 YAML file. However, the recent release 1.0.16 does not correctly generate model classes if they come with an inheritance structure. There are basically two errors involved:

  • The API model is not correctly generated into a classes and interfaces inheritance hierarchy. In our situation, a parent model which should be generated as an interface is in fact generated as a class, but the inheriting model class still uses "implements" instead of "extends" which would then be the correct statement.

  • If using a discriminator mapping, the generated code does not correctly implement that due to an error in the typeInfoAnnotation.mustache template.

Since I already figured where the errors occur within the swagger-codegen-generators project, I am going to provide a pull request which fixes this issue shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions