Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5640
Closed
Open
Issue created Mar 20, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][KOTLIN] kotlin-server generator bug that skips imports for enum classes in Paths.kt file

Created by: svok

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

The full sample project is published in https://github.com/svok/openapi-test The bug concerns kotlin-server (KTOR) generator. The main bug consequence is a lucking import declaration for the enum class in the Paths.kt file that causes Unresolved reference: SomeStatus error message.

openapi-generator version

4.2.3

OpenAPI declaration file content or url

Full declaration is over there: https://github.com/svok/openapi-test/blob/master/spec.yaml

The code causing error is following:

  /pet/findByStatus:
    get:
      tags:
        - pet
      parameters:
        - name: status
          in: query
          schema:
            type: array
            items:
              $ref: '#/components/schemas/SomeStatus'
components:
  schemas:

    SomeStatus:
      type: string
      default: available
      enum:
        - available
        - pending
        - sold
Command line used for generation

The complete set of the parameters can be foun in the generateKotlinModels task of the https://github.com/svok/openapi-test/blob/master/build.gradle.kts file.

Steps to reproduce

To reproduce the error you need to start:

./gradlew generateKotlinModels

After that you can find in Paths.kt file:

    @KtorExperimentalLocationsAPI
    @Location("/pet/findByStatus") class findPetsByStatus(val status: kotlin.Array<SomeStatus>)

where SomeStatus is undeclared

The extra lines to be included into the file:

import org.example.rest.models.SomeStatus

NOTE! The same declaration in kotlin/org/example/rest/models/Pet.kt contains import for SomeStatus, but there it is not required.

Related issues/PRs

Not found

Suggest a fix

Right now I have no idea. The bug may relate to the following file: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-server/libraries/ktor/Paths.kt.mustache

Assignee
Assign to
Time tracking