Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin-server/ktor doesn't generate nullable types #5198

Closed
mplattr3 opened this issue Feb 3, 2020 · 0 comments · Fixed by #5258
Closed

kotlin-server/ktor doesn't generate nullable types #5198

mplattr3 opened this issue Feb 3, 2020 · 0 comments · Fixed by #5258

Comments

@mplattr3
Copy link

mplattr3 commented Feb 3, 2020

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
  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants