-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
Switch to APIDevTools/json-schema-ref-parser #1054
Comments
Work was started on this a while back but not completed. Feel free to use this as a base: https://github.com/stoplightio/spectral/tree/feat/schema-ref-parser |
Are you guys planning to finish the switch soon? The linked issues forced us to disable linting in our projects due to random errors produced by failure to resolve references properly. |
@philsturgeon It's not about only circular refs, I've created a repo that you can use to reproduce the issue: https://github.com/lehphyro/spectral-ref-issue I usually use maven to run node tools, so you can reproduce it by cloning that repo and then running This is the error you should see:
|
Interesting. There may well be some sort of issue from having a model load up the main openapi file again, which is in turn trying to load up a bunch of refs and then some of them call back to the main file, and on it goes. I'd switch this:
to this:
See if that sorts you out. |
I cannot unfortunately, I need to have all |
Should I assume that this won't be done any time soon? Since I'll have to switch to another linter entirely, it'd be nice to know it before making the effort. |
@lehphyro Lots of work is being done on json-schema-ref-parser and several releases have been made since these discussions started, so I'm sure whatever concerns you have with it will be solved soon enough, if not already. The plan is to wrap up the resolution logic in an adapter pattern as part of v6, and provide an adapter for both resolvers - or allow people to pass in their own entirely - therefore separating the resolution and linting logic entirely. You can keep using the old one until json-schema-ref-parser has solved whatever problems are keeping you off it. Consolidation of efforts is the goal here, meaning two teams are working on improving one tool instead of us both playing whackamole with various edge cases. Neither are good or bad, they've just both got different problems, but json-schema-ref-parser generally has fewer of them, and is getting a lot of PRs from us to remove the rest. Soon comes the new $ref logic for $id and OAS3.1/JSON Schema 2019-09 logic (APIDevTools/json-schema-ref-parser#145), so... no point us all doing that twice. |
@philsturgeon thank you for the update, I'll give it a try when a working solution becomes available. |
If you (accidentally) have a reference inside the spec to the spec itself and run Any idea if switching to this new |
Yes, the new parser is much better at handling circular dependencies of all sorts. The team is currently working on v6 after several delays and changing priorities so Im eagerly waiting for this to be done!
…--
Phil Sturgeon
Product @ Stoplight.io
On Jun 15, 2021, at 20:16, Sebastiaan Brouwer ***@***.***> wrote:
If you (accidentally) have a reference inside the spec to the spec itself and run spectral lint ./self-ref-spec.yaml it will run into an infinite loop and eat up your memory. Not sure if this is a known issue but it might seem related.
Any idea if switching to this new json-schema-ref-parser package would fix this as well?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@philsturgeon any updates on this? is there anyway to bypass circular references, use the new parser, etc in the meantime? |
Ping @mnaumanali94 |
@philsturgeon @mnaumanali94 Hi! Any update? From what I can see in the Stoplight Studio sources a new resolver based on type: object
properties:
someProperty:
type: object
properties:
deepProperty:
$ref: '#/properties/anotherProperty'
anotherProperty:
type: string and comparison:
equals |
Sorry everyone! This is an error in my code. Sorry for the problem but question |
Any update on the effort to do the migration? Especially considering the fact https://github.com/stoplightio/json-ref-resolver is marked as deprecated. Thanks 🙏 |
any update on this, having a number of issues with non-deterministic results which seems related to our usage of $refs |
Also running into issues with this when running spectral on multiple files inside the same cli invocation. |
@mnaumanali94 hey any ideas on when will that be addressed? |
@mnaumanali94 hey, does |
⬆️ Ping @mnaumanali94 🙏 |
Currently we use our home grown json-ref-resolver, but we've switched most of our ecosystem over to APIDevTools/json-schema-ref-parser for it's superior bundling strategy (https://github.com/stoplightio/studio/issues/275) amongst other things.
We've got some outstanding pull requests going on, but so to avoid extra work let's wait for APIDevTools/json-schema-ref-parser#153 to be merged, then switch Spectral over.
The text was updated successfully, but these errors were encountered: