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