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

Support Custom Resolvers #23

Open
patrickDouglas opened this issue Jul 25, 2020 · 4 comments
Open

Support Custom Resolvers #23

patrickDouglas opened this issue Jul 25, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@patrickDouglas
Copy link

Describe the solution you'd like
Please add a new Setting that would allow for Custom $ref Resolving (which is already support by Spectral): https://meta.stoplight.io/docs/spectral/docs/guides/2-cli.md#custom-ref-resolving .

I would this it would be a new Setting spectral.resolverFile:

  • spectral.resolverFile: Location of the resolver file to use when Custom $ref Resolving. If omitted, no resolver will be used. Paths are relative to the workspace.

This path value would be passed to the Spectral CLI via the --resolver flag.

I might personally attempt this work in the near future if you don't get this done.

@nulltoken
Copy link
Contributor

@patrickDouglas 👋 Interesting idea!

I might personally attempt this work in the near future

That would be great!

One little thingie that may be worth attention:
As we want to be able to also lint unsaved/in-memory documents, the passed in custom resolver handling the file scheme will have to be wrapped (ie. upon resolving, try to find in the Documents collection, otherwise delegate to the custom resolver).

@nulltoken nulltoken added the enhancement New feature or request label Jul 25, 2020
@patrickDouglas
Copy link
Author

patrickDouglas commented Jun 24, 2021

Has there been any movement on this? I personally think the best route would be to be able to define all appropriate CLI options in the .spectral.{yml|yaml|json} file, then this extension would just use that. Thoughts?

Another idea would be to just point to a JS File (in each workspace) that exports an instance of Spectral that the user would like to use (would potentially also help solve: #84)

@patrickDouglas
Copy link
Author

patrickDouglas commented Jun 25, 2021

@nulltoken I've started to dive into the code here, but I don't see how we can pass in resolvers as we have 1 shared instance of Spectral shared across all documents, which makes it hard. We could reinitialize the Shared Instance if the configuration changes (ie. settings or the workspace). That may work. Thoughts?

@SirAppSec
Copy link

I'm having a similiar use case where I want to use the custom resolver in the VSCode extention.
Anyone have a solution for this?
I'm thinking, instead, to derefrence in a custom function. but this seems more elegant, as it provide the visibility and elasticity of the resolver used..

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

No branches or pull requests

3 participants