-
-
Notifications
You must be signed in to change notification settings - Fork 528
fix: load yaml file transform ref bug #1097
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
Conversation
|
I found a problem with the code being processed |
@@ -279,6 +279,10 @@ export default async function load( | |||
|
|||
const ref = parseRef(node.$ref); | |||
|
|||
// when ref.path is [], $ref has been transform, skip transform | |||
if (ref.path.length === 0 && (ref.filename.startsWith("components[") || ref.filename.startsWith("external["))) { |
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.
Hm this may not be true in all cases; $ref
s could also reference the operations
interface as well.
This feels like masking a potential bug rather than pinpointing exactly why the $ref
isn’t being transformed correctly.
Is this an invalid schema?
Or is this a specific bug with specific $ref
s?
Rather than change this, we should find out exactly what kind of $ref
isn’t being transformed properly.
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.
The reason for this bug is:
use items: &ref_0 and items: *ref_0, Causes the ref reference in the currentSchema to point to the same address, and the currentSchema data has changed, resulting in ref transform many times!
I use JSON.parse and JSON.stringify to handle schema data before walk currentSchema to refactor code.
c94653a
to
ae7a4f3
Compare
Thanks so much for opening this PR. This updated version is an improvement over the initial PR. But the solution here to The root of the problem lies in the If it’s all right, I’d prefer handling the fix and writing a test, to ensure it’s working as expected. I’d also like to make a performance improvement here as well. I’m going to close this PR as it’s I’d prefer another solution to this bug, but you still get full marks for your contribution! 🙂 |
Changes
fix: #1093
How to Review
How can a reviewer review your changes? What should be kept in mind for this review?
Checklist
examples/
directory updated (if applicable)