Open dlazerka opened 5 years ago
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
I think ?
is for nulalble type instead: https://kotlinlang.org/docs/reference/null-safety.html
@wing328 this issue can be closed as it has been fixed by the related PR with 4.0.0
Heads up, the issue has not been fixed:
Omitting the "= null" from "paramName: TypeName? = null" in method signatures forces the consumer to specify null as the value, which makes the "required: false" parameter effectively required, albeit nullable.
The implementation does not handle nullable header values
val localVariableHeaders: MutableMap<String, String> = mutableMapOf("headerName" to headerName.toString(),
... see petstore
This passes the string "null" downstream.
no. 2 is pretty major, as it renders the implementation unusable for APIs that don't handle the "null" header value, e.g. A pretty standard implementation of kotlin-spring, where the value of 'optionalParam' in @RequestHeader(value="optionalHeader", required=false) optionalHeader: String?,
comes through as the string "null"
Edit: I see the multiplatform template has null-friendly code, but the okhttp template has the issue in no. 2 above
I have submitted a small PR re. the above: https://github.com/OpenAPITools/openapi-generator/pull/7341
Who should I @? Someone/everyone from the kotlin technical committee? Or is posting here enough?
@wing328 This issue can probably be closed?
Im using version 7.1.0 and this issues is still there, generated params are not optional (nullable)
A workaround that works for me: declare the params schema, then reference it afterward on the query param
Bug Report Checklist
kotlin.String
, but should bekotlin.String?
Description
Client code generated: It is impossible to not provide an optional param to an API.
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i test.yaml -g kotlin -o tmp/kotlin/
Steps to reproduce
getFoo
argument type.Suggest a fix
Arguments for which spec says "required: false", should be optional (followed by
?
in Kotlin).