swagger-api / swagger-api/swagger-codegen

[Kotlin] Support optional method parameters in codegen

Open
#8,271 2 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Method parameters defined as required = false in API definition do not generate client methods which allow no value to be passed.

Swagger-codegen version

HEAD

Steps to reproduce
  1. Generate Kotlin client for API with optional fields in a method.

Expected Results: Corresponding Kotlin code will allow null to be passed to optional parameter.
Actual Results: Kotlin code requires value to be specified for optional parameter.

Related issues/PRs

Similar feature addition to Scala: https://github.com/swagger-api/swagger-codegen/pull/3677/commits/f12f70d62d73ab73283784aa7c34188dcb939641

Suggest a fix/enhancement

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by generating a Kotlin client for an API with a method parameter marked required = false, then inspect the generated method signature and compare the related Scala change in PR 3677. Done means the generated Kotlin client allows the optional parameter to be omitted or passed as null instead of requiring a value.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.