Anyone using the OpenAPI generator? All generated data are kotlin.Any
Answered
Using the OpenAPI generator plugin, it generates a load of files but the interface stub class declarations have `kotlin.Any` for attribute types. It doesn't matter what you put in the YAML type of the property but you do have to put something.
E.g., see the attached and observe that I have put nonsense for type of `username`.
The generated class declaration has `kotlin.Any` as the type of all attributes.
I opened an issue on the project page but it has not been responded-to so far.
Please sign in to leave a comment.
Can anyone see the files I uploaded with this ticket???
Upload id: 2024_02_09_3XC8XCfAFL9GjVJ3NSdcxo (file: Profile200.kt)
Upload id: 2024_02_09_worrxD9Qs4E2X8tg6JtDyR (file: profileGet.yaml)
The repo. was last updated four years ago so looks like abandonware. What should we be using to generate OpenAPI stubs?
Hello,
Please try to use generator from official plugin: https://www.jetbrains.com/help/idea/openapi.html#codegen
I *think* I'm using the official plugin. When I ctrl+shift+F10 on the YAML file, this command is run:
/home/mounty/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/jbr/bin/java -jar /home/mounty/.cache/JetBrains/IntelliJIdea2023.3/openapi/codegen/71aab8d6724718f581fedb5bf4fd5866/openapi-generator-cli-6.2.0.jar generate -g kotlin -i /home/mounty/Miit/Miit2/openapi/profileGet.yaml -o /home/mounty/Miit/Miit2/src/jvmMain/kotlin/au/com/miit/stubs --additional-properties
but the generated files still have the same problem – the types of attributes are all `kotlin.Any`.
Although I uninstalled the broken plugin from my settings, the command above uses the output directory src/jvmMain/kotlin/au/com/miit/stubs that I specific to that plugin when it was installed, so it's like the plugin does not appear in the list of installed plugins but it's still the one in use.
I just noticed this output from the command above:
That Jim Schubert is the author of the broken plugin which I uninstalled.
Plugin list:
Plugin configuration:
Plugin configuration:
Is it possible to provide sample project for investigation? It seems to be working fine on my side with test project.
How do I do that? I am willing to supply the source to JB staff but not to make it publicly available. I can't see how to upload or attach a project to this post. Should I send it to an email address? If so, with what subject-line or reference?
Please share files via https://uploads.jetbrains.com/ form.
Upload id: 2024_02_19_234b2yVQBi8ZXx9auT4xvv (file: Miit2.tar.gz)
The OpenAPI source is openapi/profileGet.yaml and when I ‘run’ it, the command is:
/home/mounty/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/jbr/bin/java -jar /home/mounty/.cache/JetBrains/IntelliJIdea2023.3/openapi/codegen/71aab8d6724718f581fedb5bf4fd5866/openapi-generator-cli-6.2.0.jar generate -g kotlin -i /home/mounty/Miit/Miit2/openapi/profileGet.yaml -o /home/mounty/Miit/Miit2/src/jvmMain/kotlin/au/com/miit/stubs --additional-properties=
I couldn't reproduce the issue with openapi 3.1.0 because of the known issue.
With openapi 3.0.3, the generated results look like below. Does it make any difference if you change the openapi to a lower version 3.0.3?
Yes, it does; it's an acceptable solution, thank you.
BTW, the project is not open source so I'm not too happy that your screen-shot shows a certain amount of the structure of the project as well as the generated code. The upload page states that the upload will be used by JB staff only.
I'm sorry for that. I've deleted the screenshot.