OpenAPITools / OpenAPITools/openapi-generator

[BUG] Kotlin generated class for `type: object` with `additionalProperties` does not compile

Open
#12,763 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

OpenApi allows to define an open ended object (map). When generating Kotlin code for it, the class declaration contains a compile error.
data class Metadata(...) : kotlin.collections.HashMap<String, kotlin.String>{ is generated, but it should be:
data class Metadata(...) : kotlin.collections.HashMap<String, kotlin.String>(){.

openapi-generator version

6.0.0 / 6.0.1

OpenAPI declaration file content or url

Spec:

components:
  schemas:
    Metadata:
      type: "object"
      properties:
        customerIp:
          type: "string"
      additionalProperties:
        type: "string"
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

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 reproducing Kotlin generation with the supplied OpenAPI schema and inspect the generated Metadata declaration. Compare the emitted HashMap inheritance syntax with the expected constructor form; done when the generated Kotlin compiles.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.