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

feature request: Find a way to extend the spectral default ruleset without installing it local #602

Open
Blaimi opened this issue Jun 9, 2023 · 1 comment

Comments

@Blaimi
Copy link
Contributor

Blaimi commented Jun 9, 2023

To extend the @ibm-cloud/openapi-ruleset in the spectral-file, it is necessary to install the ruleset into the project which is checked. (see also the customization documentation)

An extension of the default spectral ruleset spectral:oas can be done without any local installation.

It would be nice to be able to extend the default ibm ruleset without having to run npm install @ibm-cloud/openapi-ruleset especially if rules only needs to be disabled and the users want to run the checks in a container based environment.

Resolving of the upstream included rules is done in spectral's extends.ts.

I'm not experienced enough in typescript to find out how this can be done. This may even need a upstream patch first to be able to register custom rulesets to be able to extend them later.

@dpopp07
Copy link
Member

dpopp07 commented Aug 21, 2023

Hey @Blaimi, thanks for the issue. I very much understand the desire for this feature so I spent some time on Friday investigating how we might approach it but unfortunately, I don't believe it can be done.

Spectral performs this lookup in their own code and there isn't a plugin point for us to be able to add ours. They can give special treatment to their own ruleset by bundling it, like you mentioned.

This may even need a upstream patch first to be able to register custom rulesets to be able to extend them later.

This would probably be the only realistic avenue - getting Spectral to add a feature to support this - but I doubt it would be trivial and I don't know what the priority would be on their end. They seem to have intentionally solved the custom ruleset loading by relying on NPM or local file systems.

So, right now, the only way around a separate dependency is to use the ruleset installed with the validator in your local file system like so:

extends: <path-to-validator>/node_modules/@ibm-cloud/openapi-ruleset/src/ibm-oas.js

I'm going to close, as we're not able to put additional work into this at the moment.

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

2 participants