Skip to content

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

@jedwards1211

Description

@jedwards1211

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions