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

Cannot use YAML anchors and references in config files #646

Open
birnbuazn opened this issue Oct 10, 2024 · 2 comments
Open

Cannot use YAML anchors and references in config files #646

birnbuazn opened this issue Oct 10, 2024 · 2 comments
Labels

Comments

@birnbuazn
Copy link

Seems like you are using Jackson Dataformats YAML under the hood, which unfortunately doesn't handle anchors and references in YAML files nicely:

FasterXML/jackson-dataformats-text#98

Which is a pain, because I want to reuse regex patterns in my config file, which currently does not work:

    requestBody:
      allOf:
        - xPath: "/soap:Envelope/soap:Header/wsse:Security/wsu:Timestamp/wsu:Created"
          operator: Matches
          value: &Timestamp ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$
        - xPath: "/soap:Envelope/soap:Header/wsse:Security/wsu:Timestamp/wsu:Expires"
          operator: Matches
          value: *Timestamp
@outofcoffee
Copy link
Owner

Hi @birnbuazn, thanks for raising this.

One work-around could be to set them as an environment variable (or put them into a .env file), and then refer to them using the ${env.SOME_VAR} syntax.

We were considering having something like the components concept that OpenAPI specs use, for reusable elements in a config file. Would something like this work for you?

@birnbuazn
Copy link
Author

Both would work in my case, I guess.

The workaround with the environment variables seems tempting, although it might obscure things a bit, because the regex pattern in my case would be defined outside the YAML file, which can make it easier to read, because you get a nice label for the pattern. On the other hand, it might be a little harder for people to reason about the spec. if some arbitrary environment variables are defined elsewhere.

A fully blown components concept would of course be helpful. Might be a bit too much, though for my use case. Would you consider referencing simple String values as well?

@birnbuazn birnbuazn removed their assignment Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants