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
  • #2967
Closed
Open
Issue created May 21, 2019 by Administrator@rootContributor

[BUG] When trying to generate a kotlin server stub, the imports are not correctly generated

Created by: KasperJanssens

When using the 4.0.0 version of the maven plugin to generate kotlin server code like this :

 <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>4.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>api/api.yaml</inputSpec>
                            <generatorName>kotlin-server</generatorName>
                            <configOptions>
                                <sourceFolder>src/gen/kotlin/main</sourceFolder>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

The code being generated seems not to compile. The error seems to be Unresolved reference: KtorExperimentalAPI. I can open the generated code and explicitly add the import for this annotation, but because it's generated code that is of course not a good solution. The api.yaml is directly taken from the openapi specs : https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/api-with-examples.yaml.

The generation of the code happens through mvn clean install. I added these dependencies to the pom :

        <dependency>
            <groupId>io.ktor</groupId>
            <artifactId>ktor-gson</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>io.ktor</groupId>
            <artifactId>ktor-locations</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>io.ktor</groupId>
            <artifactId>ktor-client-apache</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>io.ktor</groupId>
            <artifactId>ktor-metrics</artifactId>
            <version>1.2.0</version>
        </dependency>

I target kotlin version 1.3.31 using the openjdk 11.0.3 on ubuntu linux.

Assignee
Assign to
Time tracking