kotlin-server/ktor doesn't generate nullable types
Created by: mplattr3
Description
The kotlin-server/ Ktor generator generates a Path.kt
file that doesn't mark optional parameters as nullable.
openapi-generator version
openapi-generator-cli/4.2.3
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
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.jar generate -i demo.yaml -g kotlin-server -o test/
Steps to reproduce
- Run the above command on the declaration file provided
This will generate the following template:
/**
* Optional Parameter Demo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.server
import io.ktor.locations.KtorExperimentalLocationsAPI
import io.ktor.locations.Location
object Paths {
/**
*
*
* @param mandatory
* @param optional (optional)
*/
@KtorExperimentalLocationsAPI
@Location("/foo") class fooGet(val mandatory: kotlin.Int, val optional: kotlin.Int)
}
Optional parameters are not annotated as nullable (?
).
Suggest a fix/enhancement
Paths.kt.mustache should be ammended to print ?
for optional parameters.