Skip to content
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

I got always Invalid ruleset provided from bundleAndLoadRuleset #2688

Open
jean13360 opened this issue Sep 16, 2024 · 0 comments
Open

I got always Invalid ruleset provided from bundleAndLoadRuleset #2688

jean13360 opened this issue Sep 16, 2024 · 0 comments

Comments

@jean13360
Copy link

jean13360 commented Sep 16, 2024

I am using spectral and bundleAndLoadRuleset but when i load my rules , i always have an error Invalid ruleset

const {Spectral} = require('@stoplight/spectral-core');
const { bundleAndLoadRuleset } = require('@stoplight/spectral-ruleset-bundler/with-loader');

async function main() {
const spectral = new Spectral();
const myRuleset = [{ extends: "spectral:oas", rules: {} }];
// try to load an external ruleset
const fs = {
promises: {
async readFile(filepath) {
if (filepath === "/.spectral.yaml") {
return myRuleset;
}

      throw new Error(`Could not read ${filepath}`);
    },
  },
};

spectral.setRuleset(await bundleAndLoadRuleset("/.spectral.yaml", { fs, fetch }));
console.log(spectral)

}

if (require.main === module) {
main();
}

i am using
"@stoplight/spectral-core": "^1.16.1",
"@stoplight/spectral-ruleset-bundler": "^1.5.1",
"@stoplight/spectral-runtime": "^1.1.2",
and node 18.18.0
how to correct my ruleSet ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant