[BUG] [Kotlin] Kotlin-client with retrofit2 doesn't generate nullable parameters
Created by: Wrakor
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?
Description
The kotlin-client generator when using Retrofit2 library generates a DefaultApi.kt file that doesn't mark optional parameters as nullable.
openapi-generator version
openapi-generator-cli/4.3.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
version: 0.0.1
title: Optional Parameter Demo
paths:
/foo:
get:
parameters:
- in: query
name: optional
required: false
schema:
type: integer
- in: query
name: mandatory
required: true
schema:
type: integer
responses:
200:
description: ''
content:
text/plain:
schema:
type: integer
Command line used for generation
java -jar .\openapi-generator-cli-4.3.0.jar generate -i ".\foo.yaml" --artifact-id kotlin-client -g kotlin -o generated --library jvm-retrofit2
Steps to reproduce
- Run the above command on the declaration file provided
Result will be:
package org.openapitools.client.apis
import org.openapitools.client.infrastructure.CollectionFormats.*
import retrofit2.http.*
import retrofit2.Call
import okhttp3.RequestBody
import okhttp3.ResponseBody
import okhttp3.MultipartBody
interface DefaultApi {
@GET("/foo")
fun fooGet(@Query("mandatory") mandatory: kotlin.Int, @Query("optional") optional: kotlin.Int): Call<kotlin.Int>
}
Related issues/PRs
Suggest a fix
Optional parameter should be @Query("optional") optional: kotlin.Int?