Skip to content

[BUG] [Kotlin] additionalEnumTypeAnnotations option missing from Kotlin generator #15479

Description

@RaphaelTarita

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions