Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 of 6 tasks
GFriedrich opened this issue Jul 16, 2024 · 0 comments
Open
5 of 6 tasks

Comments

@GFriedrich
Copy link

GFriedrich commented Jul 16, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant