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.3k stars 6.44k forks source link

[BUG][KOTLIN] object type should not generate property of type "Any" #19180

Open GFriedrich opened 2 months ago

GFriedrich commented 2 months ago

Bug Report Checklist

Description

When using a property of type "object" the generated code uses Kotlin type "Any" which is incorrect. This is because this would allow setting the property to any value on Kotlin side - for example a string. Setting the value to a string is though not in bounds of the given type in the spec, as an "object" should always be a list of properties and their values.

I would expect that using a type "object" generates a Map<String, Any?> as type in Kotlin instead.

openapi-generator version

7.7.0

OpenAPI declaration file content or url
openapi: 3.1.0
info: 
  title: ""
  version: 1.0.0
paths: {}
components:
  schemas:
    SomeNiceClass:
      type: object
      properties:
        someValue:
          type: object
Generation Details

Language: Kotlin

Steps to reproduce

No special steps needed, just generate the model for the spec above.

Related issues/PRs

None - or at least I couldn't find one.

Suggest a fix

I can only tell that the generator for Go does this correctly and generates a map[string]interface{} for type "object".