OpenAPITools / OpenAPITools/openapi-generator

The model cannot be created. If the properties section of the object corresponding to the model in the yaml file is empty ?

Open
#19,610 2 comments 0 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

The model is not created while using the Kotlin generator if properties is empty in the yaml file, and For the models using this object assigned as kotlin.Any, For example,

Created model ⤵️

data class RandomRequest(
    @SerializedName("currency") val currency: kotlin.Any,
    .
    .
    .
)

yaml ⤵️

components:
  schemas:
    Currency:
      type: object
      description: |
        This is an empty class map it as you wish

But if I add a properties for the yaml object it gets created without an error, For example,

Created model ⤵️

data class RandomRequest(
    @SerializedName("currency") val currency: Currency,
    .
    .
    .
)

yaml ⤵️

components:
  schemas:
    Currency:
      type: object
      properties:
        amount:
          type: number
      description: |
        This is an empty class map it as you wish

it should be represented as an object in the yaml file cause different clients want to map it as they wish by using typeMappings.

openapi-generator version

classpath "org.openapitools:openapi-generator-gradle-plugin:7.5.0" (But its same with the v7.8.0 as well)

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 Kotlin generator using the issue's empty-object YAML schema, then compare its output with the schema after a property is added. Check how empty object models and typeMappings are handled. Done means the empty Currency schema produces a usable named model instead of kotlin.Any while preserving clients' ability to map it.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, yaml
Domain
devtools
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.