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
  • #5476
Closed
Open
Issue created Feb 28, 2020 by Administrator@rootContributor

[BUG] The kotlin-spring generator ApiUtil object doesn't compile

Created by: hemynem

Description

the kotlin-spring generator produces code which doesn't compile.

openapi-generator version

openapi-generator version: 4.2.3 gradle version: 5.6.2

Command line used for generation

I'm using gradle to generate the classes

tasks.create<GenerateTask>("generateEndpoint") {
	generatorName.set("kotlin-spring")
	inputSpec.set("${specsDir}/test.yaml")
	outputDir.set("${genDir}/something")
	apiPackage.set("${package}.api")
        invokerPackage.set("${package}.invoker")
	modelPackage.set("${package}.model")
	additionalProperties.set(mapOf("serviceInterface" to "true"))
}
Steps to reproduce

just call gradle task generate endpoints and build, after that you see three compile errors.

e: /home/.../api/ApiUtil.kt: (12, 16): Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type HttpServletResponse? e: /home/.../api/ApiUtil.kt: (13, 16): Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type HttpServletResponse? e: /home/.../api/ApiUtil.kt: (14, 16): Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type HttpServletResponse?

Suggest a fix

fix mustache file: apit-mustache

and add questionmarks

            res?.setCharacterEncoding("UTF-8")
            res?.addHeader("Content-Type", contentType)
            res?.getWriter()?.print(example)
Assignee
Assign to
Time tracking