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

Proposal: Option to exclude JSONPaths for the rules definition #2414

Open
pavelkornev opened this issue Feb 28, 2023 · 0 comments
Open

Proposal: Option to exclude JSONPaths for the rules definition #2414

pavelkornev opened this issue Feb 28, 2023 · 0 comments
Labels
enhancement New feature or request triaged

Comments

@pavelkornev
Copy link
Contributor

pavelkornev commented Feb 28, 2023

User story.
As a user of Spectral it would be much flexible for me to have an opportunity to exclude certain paths from the given paths without overcomplicating JSONPaths or without defining a custom function for this purpose.

Describe the solution you'd like

In the following example the rule checks all description or title properties, but excluding examples objects because same-called properties are not part of the OpenAPI documents definition itself, but rather the example of the actual content payload which have their own constrains and requirements/guidelines:

'no-script-tags-in-markdown': {
  description: 'Markdown descriptions must not have "<script>" tags.',
  recommended: true,
  given: '$..[description,title]',
  exclude: '$..examples', // <--- easy way to exclude `title` and `description` inside these objects
  then: {
    function: pattern,
    functionOptions: {
      notMatch: '<script',
    },
  },
},
@pavelkornev pavelkornev changed the title Proposal: Exclude JSONPath option for the rules Proposal: Option to exclude JSONPaths for the rules definitions Feb 28, 2023
@pavelkornev pavelkornev changed the title Proposal: Option to exclude JSONPaths for the rules definitions Proposal: Option to exclude JSONPaths for the rules definition Feb 28, 2023
@P0lip P0lip added the enhancement New feature or request label Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

3 participants