OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.81k stars 6.58k forks source link

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

Open haliltprkk opened 1 month ago

haliltprkk commented 1 month ago
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)

Shmalikov commented 1 month ago

I am experiencing same behaviour using python generator.

haliltprkk commented 1 month ago

btw it was working with the swaggerCodegen with following yaml ⤵️

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