Code Monkey home page Code Monkey logo

Comments (10)

marbemac avatar marbemac commented on May 18, 2024 1

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.

cbetta avatar cbetta commented on May 18, 2024

Ah yes that works. The documentation wasn't quite up to date on this indeed.

from spectral.

tbarn avatar tbarn commented on May 18, 2024

I'm adding a FAQ (or maybe putting it in the code sample) for this right now.

from spectral.

cbetta avatar cbetta commented on May 18, 2024

Did I miss something? I don't see anything added.

from spectral.

tbarn avatar tbarn commented on May 18, 2024

PR #89 isn't merged yet, but that should help some. We might be adding one more thing to it.

from spectral.

cbetta avatar cbetta commented on May 18, 2024

Ah excellent, just confused cause you said "right now". I hadn't spotted the PR.

from spectral.

philsturgeon avatar philsturgeon commented on May 18, 2024

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.

stoplight-bot avatar stoplight-bot commented on May 18, 2024

🎉 This issue has been resolved in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from spectral.

cbetta avatar cbetta commented on May 18, 2024

Upgraded and all works 👍

from spectral.

tbarn avatar tbarn commented on May 18, 2024

@cbetta Glad to hear the improvements worked.

from spectral.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.