You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
External ref resolve fails to resolve to same schema and creates duplicate classes #1518
Run the JavaJAXRSSpecServerCodegen.java code generator on it, and you'll see that it generates a Stunts.java and Stunts1.java, but there is only stunts.json.
Also in that repo is a fix, or at least a fix that works for us. Look for "// BEGIN REFERENCE FORK:".
Hi, may I ask why are you using two different kind of ref for the schemas?
in ones you use components schemas assuming it ir will be resolve and in the other you use the relative path to the file.
I also notice that in the main json file you don't use stunts, how ever is listed in the components->schemas section
There's nothing in the OAS spec that makes this an invalid schema.
There's something in the implementation of the OAS parser that makes it unable to conclude that Stunts == Stunts.
If there's a way to rewrite the schema that will produce the same output (other than fixing the duplicates), please explain how to do that, and we can use that as a workaround.
Hi, @jimshowalter the only issue is that stunts_1 and TashotSipe_1 are being added? or is there an issue with the other schemas also being duplicated, as analemmata and reachless.
Is it possible for you to please create a simpler sample for me to work on, it would help the debugging, and also narrow down the real issue. thanks.
I'll try to create a simpler version, but having already reduced the original real schema to what's in the example, another pair of duplicates vanished. I'm afraid whittling it down will unconfuse the parser and the last duplicates will disappear.
I noticed something interesting after boiling it down to essentials. If you remove the enums from stunts.json and tashotSipe.json, then it generates Stunts1.java and TashotSipe1.java, but doesn't generate Stunts.java or TashotSipe.java.
The names are still wrong, because they shouldn't end in "1", but that's a clue.
Hi, @jimshowalter I had to work on another issues, but now I'm back on this one. Yes, the simplified example helped and the enum comment gave me an idea. Thanks. I hope to have a solution soon.
Looking at your branch, it appears that after ignoring tests, the schema, and changes to code that only affect formatting, there is only one file with actual changes: ExternalRefProcessor.java. Can you confirm that's correct?
Hi, @jimshowalter we have merged a solution for the duplication schema issue, and we also released parser, please let us know if this solves the issue.
That was not the only class that changed, so please do a proper test. If you find other issues I'll apreciate if you create new issues and link it to this one.
We test our code generation by starting with 40+ schemas for our services, running the generator at time T0, and checking in the resulting generated code. Then whenever we make a change to our schemas, or to our templates, or to the versions of Swagger we use, or any other change, our unit tests rerun, regenerating everything from the schemas, and fail the build if there are any diffs (including spacing and formatting changes).
If the build fails, we review the diffs. If the diffs are expected, or unexpected but acceptable, we check in the latest generated code, which becomes our new baselines as of time T1. This cycle repeats forever whenever there is a change.
Whenever we launch a new service, we add its schemas and baseline to the test framework.
To test your change, I upgraded all of the Swagger versions, deleted ExternalRefProcessor, and got a bunch of diffs. The diffs are coming entirely from Swagger, because with ExternalRefProcessor no longer forked, we are using the very latest Swagger everything, which includes your parser changes.
The zips I attached show various ways in which the latest Swagger generates code that doesn't match our baselines, with ExternalRefProcessor no longer forked.
You should be able to easily reproduce the problems by unzipping the schemas and running the latest parser on them.
I believe I'm experiencing this issue at 08a7630 with my OpenAPI 3.0.1 specification. Is there a chance I'm experiencing a regression, or has this not been fully resolved yet?
Activity
webron commentedon Jan 22, 2021
@jimshowalter which version of the parser do you use?
jimshowalter commentedon Jan 22, 2021
jimshowalter commentedon Feb 2, 2021
Were you able to reproduce the problem with those versions (which I think are current, or nearly so), and the repo I linked to?
gracekarina commentedon Feb 5, 2021
Hi, may I ask why are you using two different kind of ref for the schemas?
in ones you use components schemas assuming it ir will be resolve and in the other you use the relative path to the file.
I also notice that in the main json file you don't use stunts, how ever is listed in the components->schemas section
jimshowalter commentedon Feb 5, 2021
There's nothing in the OAS spec that makes this an invalid schema.
There's something in the implementation of the OAS parser that makes it unable to conclude that Stunts == Stunts.
If there's a way to rewrite the schema that will produce the same output (other than fixing the duplicates), please explain how to do that, and we can use that as a workaround.
gracekarina commentedon Feb 5, 2021
Hi @jimshowalter , I will start working on a fix for this duplication issue. Haven't found a workaround so far.
jimshowalter commentedon Feb 7, 2021
Thank you--the problem is in some of the most-complicated code in all of OAS!
gracekarina commentedon Feb 7, 2021
Hi, @jimshowalter the only issue is that
stunts_1andTashotSipe_1are being added? or is there an issue with the other schemas also being duplicated, asanalemmataandreachless.jimshowalter commentedon Feb 8, 2021
I'll try to create a simpler version, but having already reduced the original real schema to what's in the example, another pair of duplicates vanished. I'm afraid whittling it down will unconfuse the parser and the last duplicates will disappear.
jimshowalter commentedon Feb 13, 2021
Try now: https://github.com/jimshowalter/swagger-parser-external-ref-bug
I noticed something interesting after boiling it down to essentials. If you remove the enums from stunts.json and tashotSipe.json, then it generates Stunts1.java and TashotSipe1.java, but doesn't generate Stunts.java or TashotSipe.java.
The names are still wrong, because they shouldn't end in "1", but that's a clue.
jimshowalter commentedon Apr 19, 2021
Did the simplified example help?
gracekarina commentedon Apr 19, 2021
Hi, @jimshowalter I had to work on another issues, but now I'm back on this one. Yes, the simplified example helped and the enum comment gave me an idea. Thanks. I hope to have a solution soon.
possible fix for #1518
gracekarina commentedon May 6, 2021
Hi @jimshowalter #1559 here I made some changes, and seems like there are not duplication, can you please check? thanks
14 remaining items
jimshowalter commentedon May 13, 2021
Yes, that's fine. Working on the spec.
Looking at your branch, it appears that after ignoring tests, the schema, and changes to code that only affect formatting, there is only one file with actual changes: ExternalRefProcessor.java. Can you confirm that's correct?
jimshowalter commentedon May 13, 2021
This shows the infinite recurse:
example0.zip
jimshowalter commentedon May 13, 2021
I'll work on examples of the other problems tomorrow.
jimshowalter commentedon May 13, 2021
This one outputs:
public Error setBad(List<CommonmodelsbadJson> bad) {
but it should output:
public Error setBad(List<Bad> bad) {
Note that config.json specifies a modelName.
example1.zip
jimshowalter commentedon May 13, 2021
This one doesn't generate anything for porchOperation.json despite it being referred to in the API schema.
In addition, it generates:
public CollectionItemCreationProps setFoos(CollectionsApiJsoncomponentsschemasLink foos) {
instead of:
public CollectionItemCreationProps setFoos(Link foos) {
If you change the names of collectionCreationProps.json and collectionItemCreationProps.json at all, it makes it stop doing that.
example2.zip
jimshowalter commentedon May 14, 2021
Have you been able to reproduce the problems?
gracekarina commentedon Jun 3, 2021
Hi, @jimshowalter we have merged a solution for the duplication schema issue, and we also released parser, please let us know if this solves the issue.
jimshowalter commentedon Jun 15, 2021
I tested it by deleting the forked ExternalRefProcessor, and it fails with a bunch of errors.
gracekarina commentedon Jun 15, 2021
That was not the only class that changed, so please do a proper test. If you find other issues I'll apreciate if you create new issues and link it to this one.
jimshowalter commentedon Jun 18, 2021
I did a comprehensive test!
We test our code generation by starting with 40+ schemas for our services, running the generator at time T0, and checking in the resulting generated code. Then whenever we make a change to our schemas, or to our templates, or to the versions of Swagger we use, or any other change, our unit tests rerun, regenerating everything from the schemas, and fail the build if there are any diffs (including spacing and formatting changes).
If the build fails, we review the diffs. If the diffs are expected, or unexpected but acceptable, we check in the latest generated code, which becomes our new baselines as of time T1. This cycle repeats forever whenever there is a change.
Whenever we launch a new service, we add its schemas and baseline to the test framework.
To test your change, I upgraded all of the Swagger versions, deleted ExternalRefProcessor, and got a bunch of diffs. The diffs are coming entirely from Swagger, because with ExternalRefProcessor no longer forked, we are using the very latest Swagger everything, which includes your parser changes.
The zips I attached show various ways in which the latest Swagger generates code that doesn't match our baselines, with ExternalRefProcessor no longer forked.
You should be able to easily reproduce the problems by unzipping the schemas and running the latest parser on them.
regniblod commentedon May 25, 2023
Hello, any updates on this?
AmateurECE commentedon Aug 1, 2023
I believe I'm experiencing this issue at 08a7630 with my OpenAPI 3.0.1 specification. Is there a chance I'm experiencing a regression, or has this not been fully resolved yet?
codepred commentedon Mar 14, 2024
Any updates?