Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2012
Closed
Open
Issue created Jan 28, 2019 by Administrator@rootContributor

[BUG] [Kotlin] Optional parameters

Created by: dlazerka

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? Generated argument types are kotlin.String, but should be kotlin.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
swagger: "2.0"
info:
  version: "2.1.4"
  title: "Test"
  description: ""
host: "example.cm"
basePath: "/2_0"
schemes:
  - "https"
paths:
  /data/foo:
    get:
      operationId: "getFoo"
      produces:
        - "application/json"
      parameters:
        - name: "t0"
          in: "query"
          required: false
          type: "string"
          format: "date-time"
          description: "Filter by start time, e.g. '2018-03-01T00-00'"
      responses:
        200:
          description: "200 response"
          schema:
            type: "string"
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
  1. Generate the code.
  2. Open vi tmp/kotlin/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt
  3. See getFoo argument type.
Suggest a fix

Arguments for which spec says "required: false", should be optional (followed by ? in Kotlin).

Assignee
Assign to
Time tracking