-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[BUG] $ref to common parameter not being resolved #1714
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
Comments
👍 Thanks for opening this issue! Please review the labels and make any necessary changes. |
I can't see how to add a label to this issue, but I think it should also have |
@john3300 Did this work with another tool or a previous version of the generator? It seems to me this is an issue with swagger parser. If it previously worked, can you provide the previous version of openapi-generator so we can look at the regression? |
It works fine with 3.3.4. |
FYI if you expand the ref the issue goes away (not that it helps much):
|
@john3300 can you try with |
Above test file works via the gradle plugin with validateSpec = false. It complains about the error, but seems to continue. Larger test case is failing on another issue. This test case would further test the generated code. Will investigate and comment/log bugs as necessary. (Bug might be same as #1657) |
As requested by @wing328 I tested with Obviously that's not a valid long term solution for something that worked in the previous release. |
I can confirm this happens with 4.0.0 nightly and JavaScript generator. I like the validation, so we'll wait until it is working before migrating to 4.0.0. |
This issue was carried over from swagger-api/swagger-parser#911. Upstream has an open PR: swagger-api/swagger-parser#977 |
I assume this happens in all client generators - maybe we can remove the |
@john3300 please use |
@geneticgenesis done |
I tried this with the new 4.0.0 beta2 version and I could still reproduce this problem. |
I believe this could be the fix? Hoping it gets merged soon. swagger-api/swagger-parser#977 My team is in the same boat as @advance512, we are blocked from upgrading to 4.0.0 beta2 until this is addressed. |
This seems to fail when The workaround for gradle works: |
swagger-api/swagger-parser#977 has now been merged into master of swagger-parser. Can we pull in the latest swagger-parser and re-test? Thanks |
https://github.com/swagger-api/swagger-parser/tree/v2.0.9 is released & should be incorporated. |
Please try the latest master with the upgrade parser to see if it's still an issue. |
Thanks @wing328 This seems to have fixed this specific issue, but sadly ref'd parameters have now been broken by swagger-api/swagger-parser#1063 |
What do you mean when you say "now been broken"? You are referencing a different project. Maybe you mean to say "this fix has exposed an older problem that was hidden" or something like that? |
Sorry I should be more clear @advance512: Using parameters which involves refs was previously broken by swagger-api/swagger-parser#911 which was fixed by pulling in the upstream change in swagger-parser. Using parameters which involves refs is now broken because of another issue in swagger-parser - swagger-api/swagger-parser#1063 which is not yet fixed upstream, so if you're using refs under path parameters, you still have to disable verification on master (and V4 betas) of openapi-generator. |
Having a similar issue:
When automatically generating the code for it, the parameters get omitted and the produced functions take no arguments... Troublesome. I get a lot of those here when skipping validation as well (may be a separate issue):
Same thing, |
I believe the new issue is now fixed upstream in swagger-api/swagger-parser#1063 It looks like they cut release 2.0.12 of swagger-parser 18 hours ago with these fixes, so hopefully this can get bumped here soon. |
Definitely sounds like my issue. So I should update |
@wing328 Since this issue is closed, is there another ticket to refer to? Waiting for the updated swagger parser. |
"I got my eyes on you~" 🎶 https://github.com/OpenAPITools/swagger-parser/tags |
For those following this issue or #2631, swagger-parser was updated: #2775 and I've confirmed that the |
Awesome. Thanks. I'm onto a new issue now: #2580 |
This might be only a symptom of a greater issue, so for the impatient: To fix my problem, I've used https://github.com/APIDevTools/json-schema-ref-parser (after turning my main yaml spec into json) and de-referenced all the Then, I was able to generate the client code :) PSA: This is a hotfix and any code generated should be well tested. |
@lacksfish Interesting... I'm using I'll take a look at the tool you linked, thanks! |
In order to resolve OpenAPITools/openapi-generator#1714, which we were encountering with the latest host inventory spec.
Fixes an issue which was related to OpenAPITools/openapi-generator#1714, which we were encountering with the latest host inventory spec.
Fixes an issue which was related to OpenAPITools/openapi-generator#1714, which we were encountering with the latest host inventory spec.
I can still reproduce this problem with 4.0.3. @wing328 , can we please reopen it and release 4.0.4 with the swagger parser that contains the fix? |
Experienced this issue once when I was running an application with openjdk 8 update 41 RI. I then changed the environment to use oracle jdk 8 update 202 ( 1.8.0_202), and that fixed the problem. My guess: missing schemas in your jdk? |
This issue is still visible with the latest version.
Mostly visible for python target Exception: Cannot invoke "io.swagger.v3.oas.models.media.Schema.getType()" because "schema" is null |
Description
Validation is failing to resolve a
$ref
in the parameter list to a common parameter defined outside the operation. Neither refs local to the same file nor refs to external files work. Both should. I've tried it with both Swagger 2.0 and OAS 3.0 specs, both fail the same way.openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
java -jar openapi-generator-cli-4.0.0-20181217.102953-101.jar generate -g html -i test.yaml
Related issues/PRs
#455 seems to be related. But that one was resolved. So that makes this a regression.
Suggest a fix
This could be another issue with the
swagger-parser
like in #455.The text was updated successfully, but these errors were encountered: