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] additionalEnumTypeAnnotations option missing from Kotlin generator #15479

Open
5 tasks done
RaphaelTarita opened this issue May 11, 2023 · 1 comment
Open
5 tasks done

Comments

@RaphaelTarita
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

Originally, #6055 reported the fact that the annotations from additionalModelTypeAnnotations do not get applied to enumerations when using the Java generator. This was subsequently fixed via #8389 by adding a new additionalEnumTypeAnnotations option. However, this only applies to the Java generator, and this option is still missing from the Kotlin generator. As far as I know, there is currently no configuration that applies a certain annotation to all generated enums.

openapi-generator version

using the gradle plugin with version 6.6.0

OpenAPI declaration file content or url

This is the same spec that is given as an example in #6055:

swagger: "2.0"
info:
    title: Book
    version: 1.0.0
paths:
    /books:
        get:
            summary: Get books
            responses:
                200:
                    description: Successful response
                    schema:
                        type: array
                        items:
                            $ref: '#/definitions/Book'
definitions:
    Book:
        description: Book
        type: object
        properties:
            type:
                $ref: '#/definitions/BookType'
    BookType:
        description: Book type
        type: string
        enum:
            - HARDCOVER
            - PAPERBACK
            - ELECTRONIC
Generation Details

Specifying an additionalEnumTypeAnnotations option in the additional properties has no effect on generated enums (because that behaviour has only been implemented for the Java generator)

Steps to reproduce
  1. run: generate -g kotlin -p additionalModelTypeAnnotations=@Foo for the given spec
  2. inspect the generated enum: It does not have the @Foo annotation
  3. run: generate -g kotlin -p additionalEnumTypeAnnotations=@Foo for the given spec
  4. inspect the generated enum: It does not have the @Foo annotation
Related issues/PRs

#6055
#8389

Suggest a fix

I suggest adding the additionalEnumTypeAnnotations option to the additional properties of the Kotlin generator, with functionality analogous to the option for the Java generator (#8389).

@digulla
Copy link

digulla commented May 11, 2023

It looks like the additionalEnumTypeAnnotations config option isn't used in all the templates where it should be.

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