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

[RFC] Teach overrides to honor JSON Pointers #1002

Closed
3 of 4 tasks
nulltoken opened this issue Mar 5, 2020 · 7 comments · Fixed by #1702
Closed
3 of 4 tasks

[RFC] Teach overrides to honor JSON Pointers #1002

nulltoken opened this issue Mar 5, 2020 · 7 comments · Fixed by #1702
Assignees
Labels
enhancement New feature or request released

Comments

@nulltoken
Copy link
Contributor

nulltoken commented Mar 5, 2020

Potential laxer locations syntaxes have been evoked in #939 and eventually dropped out to keep the PR on scope.

This issue is a placeholder to gather feedback, use cases and try and measure how important allowing less strict locations would be.

From #939 (comment)

Current location syntax is: <source>#<pointer> where

  • source can be expressed as
    • an absolute uri (file or http based)
    • relatively to the to the rulesepath uri
  • pointer is a Json pointer (cf. https://tools.ietf.org/html/rfc6901) describing the precise document path that should be ignored

Latest update to the proposal was to allow a more open location syntax where

Samples:

  • models/awful.json: [ rule1, rule2]: Would ignore rule1 and rule2 results wheverever in the file
  • #/info": [rule1, rule2]: Would ignore rule1 and rule2 results in any processed document provided they originate from a path that's #/info or below (eg. #/info/sub/path/1). This would be in line with @P0lip's comment
@marcoemidio
Copy link

marcoemidio commented Sep 2, 2020

hi @nulltoken

I'm trying the "except" funcionality, and this issue might solve some problems I'm facing, or perhaps there is already a solution that I'm not aware.

Assuming I have an openAPI2 specification and want to ignore errors from a given rule, e.g., oas2-valid-definition-example or no-$ref-siblings, inside a specific schema, like "/x-configuration-example/definitions".

Is it possible to achieve this in the current version, or this RFC will try to deal with this behaviour?

Thanks

@nulltoken
Copy link
Contributor Author

Assuming I have an openAPI2 specification and want to ignore errors from a given rule, e.g., oas2-valid-definition-example or no-$ref-siblings, inside a specific schema, like "/x-configuration-example/definitions".

Is it possible to achieve this in the current version,

@marcoemidio I'd be happy to take a look at your issue, but I'm unsure to precisely understand the use case.
Could you please create a dedicated issue with a simple repro case?

@P0lip P0lip added the enhancement New feature or request label Nov 19, 2020
@P0lip P0lip self-assigned this Dec 11, 2020
@marcoemidio
Copy link

@marcoemidio I'd be happy to take a look at your issue, but I'm unsure to precisely understand the use case.
Could you please create a dedicated issue with a simple repro case?

Hi again @nulltoken,

I managed to use the except functionality but only when I give full JSON pointer path but not for sub paths. In the second sample you provided, this is possible:

  • #/info": [rule1, rule2]: Would ignore rule1 and rule2 results in any processed document provided they originate from a path that's #/info or below (eg. #/info/sub/path/1). This would be in line with @P0lip's comment

My example:

extends: spectral:oas

except:
 "#/foo/bar": 
   - no-$ref-siblings

I can't ignore no-$ref-siblings in sub paths, like your example.
Am I missing something? I'm using latest version, 5.8.1.

Thank you for your help and keep it up!

@philipbjorge
Copy link

philipbjorge commented Mar 4, 2021

It would be useful for me if source could be expressed as a wildcard.
For example, descriptions/v1/*_api.yaml

We have OpenAPI specifications split apart conceptually for the purpose of our documentation rendering and then we combine them into a single file during a build stage. This would let me easily apply some laxer rules to the split apart specifications and apply a stricter ruleset to the combined file.

I suppose an alternative way to suffice this usecase might be to default to the lax ruleset and apply a stricter ruleset to the final document but it doesn't look like except supports that (specifically for disabling rules).

@ariatron
Copy link

ariatron commented Jun 7, 2021

@mnaumanali94 Wanting to get your review of this request.

@mnaumanali94
Copy link
Contributor

@ariatron This has been added to the scope for v6! 🙏

@mnaumanali94 mnaumanali94 changed the title [RFC] Teach except to honor laxer location syntaxes [RFC] Teach overrides to honor JSON Pointers Jun 22, 2021
@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version @stoplight/spectral-core-v1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

8 participants