Skip to content

[REQ][kotlin] Add = null default for optional parameters in jvm-ktor client and javalin server templates #23100

Closed

Description

@halotukozak

Is your feature request related to a problem? Please describe.

Several Kotlin generator templates make optional parameters nullable (Type?) but don't assign = null as a default value. This forces callers to explicitly pass null for every optional parameter instead of simply
omitting them — defeating the purpose of Kotlin's default parameter feature.

For example, the generated jvm-ktor client produces:

suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?): HttpResponse<Unit>

Callers must write deletePet(123, null) instead of just deletePet(123).

Most templates already handle this correctly (jvm-okhttp, jvm-retrofit2, jvm-spring-restclient, jvm-spring-webclient, jvm-vertx, jvm-volley, multiplatform, and all data_class_opt_var.mustache model templates).
The following templates are inconsistent:

  • kotlin-client/libraries/jvm-ktor/api.mustache
  • kotlin-server/libraries/javalin5/service.mustache
  • kotlin-server/libraries/javalin5/serviceImpl.mustache
  • kotlin-server/libraries/javalin6/service.mustache
  • kotlin-server/libraries/javalin6/serviceImpl.mustache

Describe the solution you'd like

Add = null (or = {{{defaultValue}}} when a default is specified) for optional parameters in the affected templates, matching the pattern already used by multiplatform/api.mustache and jvm-okhttp/api.mustache.
The generated output would then be:

suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String? = null): HttpResponse<Unit>

Describe alternatives you've considered

Manually wrapping every generated API class with extension functions that provide default values. This is tedious and breaks every time the API is regenerated.

Additional context

This is a consistency fix — the majority of Kotlin templates already emit = null for optional params. Only jvm-ktor (client) and javalin5/javalin6 (server) are missing it.

Activity

  1. added a commit that references this issue on Mar 3, 2026
    4a5ec7c
  2. added a commit that references this issue on Aug 1, 2026
    501e5c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions