A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/OpenAPITools/openapi-generator/issues/5247 below:

[BUG][Kotlin] Incorrect enum parameter type · Issue #5247 · OpenAPITools/openapi-generator · GitHub

Description

Kotlin generation is producing a wrong parameter type for an enum that is declared in an array. It is getting the type from another array declared in the same object

openapi-generator version

4.2.3

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  description: Blah
  version: v2
paths:
  /api/v2/query:
    post:
      operationId: foo
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Query"
components:
  schemas:
    Query:
      type: object
      properties:
        groupBy:
          type: array
          items:
            type: string
            enum:
              - value1
              - value2
              - value3
              - value4
        views:
          type: array
          items:
            type: int
Command line used for generation

openapi-generator generate -i test.yml -g kotlin --skip-validate-spec -o output

Steps to reproduce

You will see this code:

    enum class GroupBy(val value: Int){
        @Json(name = "value1") value1("value1"),
        @Json(name = "value2") value2("value2"),
        @Json(name = "value3") value3("value3"),
        @Json(name = "value4") value4("value4");
    }

The Int parameter type here is not correct and will not compile. It should be kotlin.String. That type is coming from the views array type. If you change the type used for the views array it changes the GroupBy parameter type. If you remove the views property it does generate the correct code.

nickbw2003, grEvenX and mattbroekhuis


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4