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

Spectral overrides will not match a path with a parameter #2678

Open
nrutman opened this issue Sep 10, 2024 · 1 comment
Open

Spectral overrides will not match a path with a parameter #2678

nrutman opened this issue Sep 10, 2024 · 1 comment

Comments

@nrutman
Copy link

nrutman commented Sep 10, 2024

Describe the bug
I am using Spectral to enforce the URL Style Guidelines against my OpenAPI spec. Overall, I want to enforce the (resource-names-plural)[https://apistylebook.stoplight.io/docs/url-guidelines/#resource-names-plural] rule, but I do have a few exceptions that I'm trying to use overrides for.

One example is the /v1/user/me endpoint. This is simple, as I added the following to my Spectral configuration and get the desired result:

overrides:
  - files:
      - "**#/paths/~1v1~1users~1me"
    rules:
      resource-names-plural: "off"

But I have another endpoint that is /v1/comments/{uuid}/context (notice the parameter with the brackets). I cannot get the override to match. I've tried:

overrides:
  - files:
      - "**#/paths/~1v1~1users~1me"
      - "**#/paths/~1v1~1comments~1{uuid}~1context"
    rules:
      resource-names-plural: "off"

…but it won't suppress the rule for that endpoint. The problem seems to be with the brackets. If I remove them in both the OpenAPI file and my rule (changing the rule to match **#/paths/~1v1~1comments~1uuid~1context), it matches correctly and I get the desired result.

Is there a trick to matching the brackets? My guess is that this is a pretty common flow and I'm just missing something.

Thanks!

To Reproduce

  1. Generate an OpenAPI document with a path that includes brackets
  2. Enable the resource-names-plural rule
  3. Add an override to suppress the rule for the path with brackets
  4. Run the CLI

Expected behavior
Should pass without any warnings or errors

Screenshots
Screenshot 2024-09-10 at 11 37 14 AM\

@nrutman
Copy link
Author

nrutman commented Nov 6, 2024

Any thoughts on this one?

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