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

Switch to Spectral aliases from yaml anchors #622

Open
philsturgeon opened this issue Aug 25, 2022 · 2 comments
Open

Switch to Spectral aliases from yaml anchors #622

philsturgeon opened this issue Aug 25, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@philsturgeon
Copy link

Hey, thanks for making such a great ruleset. I'm just dropping by to let you know there's a new feature in Spectral which you could use in your rules which replaces what might be a bit of a hack.

  sec-securitySchemes-jwt:
    <<: *jwt-bcp
    given:
      - >-
        $..[securitySchemes][?(@.bearerFormat=="jwt" || @.bearerFormat=="JWT")]

This is a really clever solution to reduce repetition of the JSON Path, but now we've got Aliases you could do the same with them.

aliases:
  JwtBcp:
    - "$..[securitySchemes][?(@.bearerFormat=="jwt" || @.bearerFormat=="JWT")]"

Then reference it like this:

    rules:
      foo:
        given: "#JwtBcp"

🙌

@ioggstream
Copy link
Collaborator

ioggstream commented Sep 22, 2022

Thanks @philsturgeon ! That's very cool, we need to plan the switch to 6.x first.
Can we override single keys like we do with merge keys, or we can just reference single pieces?

@ioggstream ioggstream added the enhancement New feature or request label Sep 22, 2022
@ioggstream
Copy link
Collaborator

Needs #347

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

2 participants