-
-
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] UNKNOWN BASE TYPE when using allOf in request body schema declaration #2892
Comments
I'm afraid that's not validated. The schema should be either a $ref or an inline schema. in other words, the required properties (name, type) should be in the Workaround definition. |
@wing328 Thanks for commenting. The spec-workaround.yaml seems to be valid according to the Online Validator. You probably meant something else mentioning "not validated"? Anyway, I changed the yaml so that I use only Still, the generator generates the same code after adjusting my yaml according to this gist spec-workaround.yaml. |
Let's have a chat via https://gitter.im (ID: wing328) when you've time. |
@wing328: Alright, I will approach you next week Monday or Tuesday. |
I did a test and got the following "Workaround" class (which does not extend other class):
|
@wing328 Thanks. Can you tell how your spec looked like and which options you passed to the generator? |
Bump. I'm having similar issues with code generation on java with the same error. Schema is defined very similarly to OP's, and I just cannot get it to work. The only difference is that mine is not defined in the requestbody, just as a normal schema. |
Same here, in request body; mine is autogenerated on the server side, so I don't have a lot of control over it: This fails:
This parses correctly:
|
Any update on this issue? |
This is a workaround, works for me, transfer inline required field to a new Model
|
Any update on this issue? |
Same problem for typescript generators as well. |
Any updates on the issue? |
Ran into this issue myself using the Typescript generator from a swagger document generated by .NET Core Swashbuckle with config option |
Probably the same issue as I described in #5903, basically wherever allOf/anyOf/oneOf are used inline (e.g. without a named schema) the generator forgets to generate the model (even though it comes up with a name and adds references in the generated code for it). |
I get this UNKNOWN_BASE_TYPE for every item I have in my requestBodies. I don't know what the idea is for these two use cases, but would it make sense to generate the classes from requestBodies outside of < modelPackage >, maybe as a < requestPackage >? |
As a workaround, I use
Not really a fix, but I hope this could help someone in a pinch... |
any news on this? this seems to be still broken. i am using the described workaround. Would be happy to get any pointers how to fix it. |
This should be fixed via #12353. Please pull the latest master to give it a try. |
Happy to reopen if it's still an issue. |
Bug Report Checklist
Description
Code generation spills out:
openapi-generator version
Both versions are affected.
OpenAPI declaration file content or url
Gist URL:
https://gist.github.com/Emdee89/b3bcab67c46fd6c49d9282a528313990
Command line used for generation
Maven Plugin execution:
api-options.json:
Steps to reproduce
Execute the Maven Plugin with the execution configuration shown above.
Related issues/PRs
Related issues:
#2030
#185
Suggest a fix
The generator appears to lack a concept for creating base types for schemas being used in conjunction with
allOf
.In related issues I found the recommendation to use
allOf
inline. I applied this workaround.See this gist: https://gist.github.com/Emdee89/cd188cb35721b080c101cc10ee757189
####### Workaround
I basically introduced the model named
Workaround
that serves as a layer in between. I declared theallOf
withinWorkaround
instead of withinresponses
of the endpoint.When executing the code generation with this workaround, all warnings/errors from above are gone and the code compiles. However, the generated code looks unexpected.
See Workaround.java:
Workaround
extendsSomewhatIn1
, but it should also be in a relationship withSomewhatIn2
.Consequently, I cannot claim that this workaround solves the problem.
The text was updated successfully, but these errors were encountered: