Comments (10)
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!
from spectral.
Ah yes that works. The documentation wasn't quite up to date on this indeed.
from spectral.
I'm adding a FAQ (or maybe putting it in the code sample) for this right now.
from spectral.
Did I miss something? I don't see anything added.
from spectral.
PR #89 isn't merged yet, but that should help some. We might be adding one more thing to it.
from spectral.
Ah excellent, just confused cause you said "right now". I hadn't spotted the PR.
from spectral.
Hey folks, just to give you an update: the release/2.0
is getting more mature, so if you would like to check it out your troubles should be over. run now returns a promise, so make sure you add await
. It is no longer an object with .results, it just an array.
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).
from spectral.
🎉 This issue has been resolved in version 2.0.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
from spectral.
Upgraded and all works 👍
from spectral.
@cbetta Glad to hear the improvements worked.
from spectral.
Related Issues (20)
- @stoplight/path: Cannot parse <openapi.yaml> because it is not a string
- Spectral oas3-unused-component warning
- new rule for ambiguous path objects?
- Have a status to know when the lint has found any warning
- [Feature] Pass pattern some regex modifiers as a function option HOT 3
- oas3-valid-media-example not catching some bad example values
- launch Spectral without a defined ruleset , should use default ruleset
- Include documentation URLs for built-in rulesets
- Rule overrides with file paths don't work HOT 2
- oas3-valid-media-example is reported for primitives if type is object
- Path property of error remains empty even if custom function provides some value
- Wrongly declared array not caught as error
- Incorrect example validation on OpenAPI and examples vlaidation on AsyncAPI when using `allOf`.
- Ready to use Aliases to write rulesets
- Provide a solution for for fixing self-signed certificate errors in VSCode HOT 1
- Misbehaviour with Regex and numbers HOT 2
- operation-operationId-valid-in-url message needs small updates
- Error when generating SARIF report HOT 1
- False "oas3-valid-media-example" error reported: "property must match exactly one schema in oneOf"
- oas3-operation-security-defined scopes validation not using resolved securitySchemes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spectral.