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

Option to plain-format some keys like /models/{model} #493

Closed
jedwards1211 opened this issue Aug 16, 2023 · 3 comments · Fixed by #494
Closed

Option to plain-format some keys like /models/{model} #493

jedwards1211 opened this issue Aug 16, 2023 · 3 comments · Fixed by #494
Labels
bug Something isn't working

Comments

@jedwards1211
Copy link

jedwards1211 commented Aug 16, 2023

Is your feature request related to a problem? Please describe.
I'm trying to minimize diffs when using yaml-diff-patch on OpenAPI specs like

openapi: 3.0.0
paths:
  /models/{model}:
    get:
      # etc

The /models/{model} key gets quoted after a roundtrip.

EDIT: I thought this is an implicit key but I think I misinterpreted the spec, so seems like this is valid?

Question: is it actually a valid key? It seems to parse okay and linting tools seem okay with it. But, I found in your code that you intentionally quote implicit keys containing { or }, and the YAML spec seems pretty clear on this:

In addition, inside flow collections, or when used as implicit keys, plain scalars must not contain the “[”, “]”, “{”, “}” and “,” characters. These characters would cause ambiguity with flow collection structures.

Describe the solution you'd like

If an implicit key like /models/{model} is actually unambiguous, can we have defaultKeyType: 'PLAIN' not quote it?

Describe alternatives you've considered

If using an unquoted key in this form is bad and not technically valid, I'm wondering if there's a good example why it shouldn't be done I can relay back to folks who are outputting YAML in this format?

Additional context

@jedwards1211 jedwards1211 added the enhancement New feature or request label Aug 16, 2023
@rattrayalex
Copy link

If the maintainers are open to it, I'm happy to fund a PR.

@eemeli
Copy link
Owner

eemeli commented Aug 17, 2023

Huh, that's a bit odd.

This will probably require some spelunking in the YAML spec and the codebase to figure out if it the check can be safely relaxed, or if the parser should complain about the input. And if the parser really should complain about the input, then the fix might require a major release because it may break user code.

Given the potential impact and delicacy of the work, receiving some targeted funding would indeed help with its prioritisation. As I'm the only maintainer and Finnish donation laws are rather strict, the only platform that's currently set up to funnel any donations is thanks.dev, though you'll also find me on PayPal as eemeli@gmail.com.

@eemeli eemeli added bug Something isn't working and removed enhancement New feature or request labels Aug 17, 2023
@rattrayalex
Copy link

Sent you an email!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants