swagger-api / swagger-api/swagger-codegen

[Kotlin] empty data class generated for type refs of additionalProperties

Open
#9,443 4 comments 3 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

The Kotlin generator creates data class Bar ( ) { } which is invalid

where bar is of type object with properties {} and additionalProperties true

Expected behavior:
I would suggest Bar should be a TypeAlias to Any

Swagger-codegen version

3.0.8

Swagger declaration file content or url

https://gist.github.com/andymoody/3007694856b36ddc2a406c2445d8b705

Command line used for generation

swagger-codegen generate -i [file] -l kotlin-server -o /tmp/test/

Steps to reproduce
Related issues/PRs

There are a plethora of them for other languages, e.g. https://github.com/swagger-api/swagger-codegen/issues/9439 but none for Kotlin

Suggest a fix/enhancement

Types with no properties should map as a TypeAlias to Any

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 with the Swagger declaration at the linked gist and run the documented swagger-codegen generate command using the kotlin-server generator. Inspect the generated Bar model for an object with no properties and additionalProperties: true; done means the output is valid Kotlin and follows the expected Any mapping.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.