-
-
Notifications
You must be signed in to change notification settings - Fork 220
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
Receiving warning: oasOpParams expects a resolved object #88
Comments
Hi @cbetta - great question, and this is something that we could certainly be more clear about (will open a separate PR for readme). Certain rules (like those param rules you mentioned above) need both the resolved and unresolved document in order to function. Since you don't have any $refs in your document, you should be able to supply it as the resolved version like so: const results = spectral.run(specification, { resolvedTarget: specification }); You can find the run signature here: https://github.com/stoplightio/spectral/blob/next/src/spectral.ts#L21. I'm now wondering if we shouldn't just default resolvedTarget to the passed in document if resolvedTarget is not explicitly set. Let me know if the above works for you for now! |
Ah yes that works. The documentation wasn't quite up to date on this indeed. |
I'm adding a FAQ (or maybe putting it in the code sample) for this right now. |
Did I miss something? I don't see anything added. |
PR #89 isn't merged yet, but that should help some. We might be adding one more thing to it. |
Ah excellent, just confused cause you said "right now". I hadn't spotted the PR. |
Users were not expecting to need to pass in the optional resolvedTarget, and it would provide warnings on some rules even when there were no $ref's in there. This will automatically resolve local refs and dereference them too, which is then an object some rules can chose to look at instead of the original object. BREAKING CHANGE: The spectral.run() method is now async, so the await keyword must be prepended. fix #88
Users were not expecting to need to pass in the optional resolvedTarget, and it would provide warnings on some rules even when there were no $ref's in there. This will automatically resolve local refs and dereference them too, which is then an object some rules can chose to look at instead of the original object. BREAKING CHANGE: The spectral.run() method is now async, so the await keyword must be prepended. fix #88
…ct (#99) * feat(run): run is async, no longer need resolvedTarget Users were not expecting to need to pass in the optional resolvedTarget, and it would provide warnings on some rules even when there were no $ref's in there. This will automatically resolve local refs and dereference them too, which is then an object some rules can chose to look at instead of the original object. BREAKING CHANGE: The spectral.run() method is now async, so the await keyword must be prepended. fix #88
Hey folks, just to give you an update: the Before const spectral = new Spectral();
results = spectral.run(obj);
console.log(results.results); v2.0 const spectral = new Spectral();
results = await spectral.run(obj);
console.log(results); Please post new issues with any new bugs you find in there, but this is considered done (and will be closed when v2.0 is merged). |
…ct (#99) * feat(run): run is async, no longer need resolvedTarget Users were not expecting to need to pass in the optional resolvedTarget, and it would provide warnings on some rules even when there were no $ref's in there. This will automatically resolve local refs and dereference them too, which is then an object some rules can chose to look at instead of the original object. BREAKING CHANGE: The spectral.run() method is now async, so the await keyword must be prepended. fix #88
🎉 This issue has been resolved in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Upgraded and all works 👍 |
@cbetta Glad to hear the improvements worked. |
I'm submitting a bug report
What is the current behavior?
I am currently migrating my API specification and running into this warning:
There are no
$ref
mentions in my spec, so I am confused as to why I am getting this error. The code is as follows.What is the expected behavior?
For this not to error
Please tell us about your environment:
@stoplight/spectral": "^1.0.1"
Other information
My code:
The text was updated successfully, but these errors were encountered: