-
Notifications
You must be signed in to change notification settings - Fork 179
fix #810: remove restriction on $ref format #879
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
base: master
Are you sure you want to change the base?
Conversation
5025731 to
996db4e
Compare
996db4e to
c4e1108
Compare
| final String baseRef = getBaseRefForType(refType.getName()); | ||
| if (!ref.startsWith(baseRef)) { | ||
| throw new IllegalArgumentException("Invalid ref: " + ref); | ||
| // If the ref doesn't point to something in #/components, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, looks like just removing this validation would not work well. getRefName method is used by resolveRef method. Under the hood it searches referenced objects only in components section and does not consider remote files. So we need to think here about full support of the remote refs, instead of just removing the validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting; I would have expected an issue like that to be caught by this assertion, since the baseline spec uses an external ref to define the common properties of the Cat schema and the updated spec defines those properties inline.
Is there a different test I could write that would exercise remote ref resolution? Once I have a failing test demonstrating the issue I can work on addressing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few more tests to cover different styles of external $ref and based on the test results, it looks like external references are all being resolved correctly for the purposes of generating a diff. (Although I haven't added a test for external URL references.) Most of the tests added here are checking for an empty diff, but I did add one test to confirm that changes in the content of a remote $ref are detected as a diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 12 files
This updates the
RefPointerclass to return the full$refvalue for references that are not under#/components/instead of throwing anIllegalArgumentException. This change enablesopenapi-diffto run successfully against specs that use any valid$refformat rather than prescribing one specific approach to defining references.Fixes #810