-
-
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
fix #915: Ignore examples with circular schemas #923
Conversation
…oblem with nullable
Co-Authored-By: Jakub Rożek <[email protected]>
Hello, |
@m-mohr I see, thank you for the information! |
@m-mohr please accept my sincere apologies for dropping a ball here. It's been a couple of hectic days for me and didn't have much time to contribute to Spectral. 😞 I'm more than happy to release a minor release once this is in, since there are a couple of others PRs we've already merged and it makes sense to get that stuff out to public. @nulltoken mind giving a look at this PR? |
@P0lip on it, Sir! @m-mohr Few thoughts:
Minor things that this PR would require in order to be merged:
|
Thanks for the review @nulltoken. No need to apologize, @P0lip :-)
The problem is that (at least in my case) I would still want the CI to fail if examples are not correct, but only for circular referenced examples that can't be validated properly I want to send an info. I can't see anything in typedEnums.ts that lets me set the severity though.
As far as I understood the schemas are dereferenced and $ref are only left in place where it couldn't resolve the ref (usually when there's a circular ref). So that shouldn't be a problem, but I'm not deeply invested in your source code so that might be a wrong assumption (although it works in my tested cases). Ultimately, the dereferencing is why the error occurs and the tool probably shouldn't dereference internal refs so that it can validate circular refs.
That's a bit too deep into things I don't know enough about. I'm also a bit limited on time and can't dig into these details at the moment.
I'm not even sure we need to merge it. As far as I understood PR #939, that PR could also solve the issue as I could just ignore the circular schemas with it?!
The current solution is a bit verbose as required copying rules. Has anyone an answer for the question I raised in the PR description? Beforehand it doesn't make much sense to write docs. |
It wouldn't fix the underlying bug identified by #915. It should help ignore the findings, though. |
Indeed, but I don't see this being fixed anytime soon as it seems to need fundamental changes in spectral?! So maybe we need workarounds to help with getting the CIs running for now. At the moment, spectral is very much useless for us as I can't run it in CI due to this bug.
Didn't know that. I thought it's relatively close to being ready. The issue is I'm pretty busy at the moment and can't work on this PR until mid-March or so. |
@nulltoken do you think the change we discovered in APIDevTools/json-schema-ref-parser#158 will help here? |
I don't think so, but not really sure. How should switching from |
@philsturgeon It's possible than trying to
@m-mohr I haven't studied the |
Hey folks. |
I guess it's obsolete with the "except"ions from @nulltoken. So I'm closing the PR. Issue #915 is not solved though as the "except"ions are basically just a workaround around a spectral bug/limitation. |
Seeing as we have a workaround for now, the long term solution will be handled by switching from stoplight/json-ref-resolver to APIDevTools/json-schema-ref-parser (#1054). Our ref resolver handles many circular reference scenarios, but this one has better support out of the box. If there is still a problem after we switch then it'll need to be fixed over there. |
Fixes #915.
Checklist
Does this PR introduce a breaking change?
Additional context
This is a first very dump attempt at #915, see the issues for more context. This is more a workaround than a proper fix, but I don't see a better alternative that doesn't need a lot of work yet.
Better would be to send an information instead of an error when ignoring, but not sure how to do that.
The rules could be changed as follows whenever users want to ignore examples with circular schemas:
Even better would be to simply inherit by specifying just the additional rule, but I don't know how to achieve it.