-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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][JAVA] Bug generating spring server: codegenModel is null. Default to UNKNOWN_BASE_TYPE #2236
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
Hi, |
Facing the same issue. Can confirm that the issues does occur once you use
When we comment |
As a workaround, what about defining the schema separately (instead of inline)? e.g. https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/allOf.yaml#L43-L52 |
@wing328: I tried that, then it parses the yaml correctly and the source code compiles. However, when you look at the generated code, it does not do what the semantics would imply. In my experiments, the code generator generates a Java class that looks exactly (of course, except its name) like the Java class that corresponds to the schema mentioned at last under the |
I remember the oneOf implementation in Java is still being discussed/worked on.
If it's a super-type, what about using |
Same issue here and I don't wat to use the allOf instead. |
related to |
Hey everyone. Was there ever a solution found for this? Facing the same issue with |
Facing the same issue with oneOf. Any solution for this issue? |
I still have this issue with Spring generator. Anything new? |
Generating code that implements oneOf and allOf requires the use of inheritance in the model. From what I see, the generated code does not use inheritance. However, if I use SwaggerHub site to generate code, inheritance is used to implement oneOf and allOf. |
did anyone ever get to the bottom if it? I still see that even latest maven plugin 5.0.0-beta2 fails to generate inheritance code, whereas online generator processes exactly the same yaml correctly. Tried all workarounds found, no luck.. |
Does "openapi-generator validate -i filename.yml" give you any tips? Have you tried using Version 3.0? |
Hi, |
@wing328 Hi, same as @frochi42 I'm getting UNKNOWN_BASE_TYPE with version 5.1.1 with openapi-generator-cli for angular-typescript. Using https://editor.swagger.io/ I'm getting the correct client code. Below is example yaml code: paths: components: schemas: ` |
fyi. this also happens for python-fastapi server generation
|
Tried the following in FastApi, but changing to
|
This issue was opened three years ago!! The spring code generator is STILL completely broken on polymorphic request/respond bodies. What's causing the delay? Do you guys need people to work on this? Is it internal squabbling about how to "fix" it? I'll gladly volunteer some time to get this fixed as this tech holds promise. Update: This is not an easy problem to solve... lol. The schema model handling in the spring generator isn't smart enough to traverse the object hierarchy to determine a suitable common parent. And since this is done "pre-java", there's no way to resolve the base class through reflection because it doesn't exist yet. I'm currently looking at ways to solve these issues. |
Any update @dbcall2? |
I've merged #12353 to the master which seems to address the inline schema issues in the request bodies. Please pull the latest master to give it a try. |
Bug Report Checklist
Description
I am trying to generate a java spring server using 4.0.0-beta2, however generation fails with:
openapi-generator version
4.0.0-beta2 and previous versions.
OpenAPI declaration file content or url
The text was updated successfully, but these errors were encountered: