-
Notifications
You must be signed in to change notification settings - Fork 9.1k
clarification about YAML #635
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
Conversation
As YAML has a superset of features, the following YAML features are NOT supported by the OAS: | ||
|
||
* YAML Merge. Consider using JSON Pointers instead | ||
* Numeric keys. All numeric keys should be quoted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one mention of YAML anchors in REUSE.md
, we might want to be sure to either clarify it there, or link to this section.
https://github.com/OAI/OpenAPI-Specification/blob/3cb58cd1da4051d9d3d5401b9fa7eb7abe70dc90/guidelines/REUSE.md#yaml-example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better add the clarification than link to an extra document we produced ourselves. It's a bit too meta ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All numeric keys must be quoted
would be stronger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we mean "All keys must be strings" here, and "Keys looking like a number need to be quoted to be a string" is just a hint to the reader on how to implement this.
@OAI/tdc decided that @webron will review the YAML spec before we move on this |
@webron I'm happy to give you a hand wading through issues related to the YAML spec. I actually liked the spec last time I read it. It has a certain style that takes a bit of getting used to but I found it very consistent. |
@@ -51,7 +51,12 @@ The HTTP Status Codes are used to indicate the status of the executed operation. | |||
### Format | |||
|
|||
The files describing the RESTful API in accordance with the OpenAPI Specification are represented as JSON objects and conform to the JSON standards. YAML, being a superset of JSON, can be used as well to | |||
represent a OAS (OpenAPI Specification) file. | |||
represent a OAS (OpenAPI Specification) file. For YAML, version `1.1` is supported for OAS documents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a link to the spec?
I don't find "Merge" in that document, does it have a different name there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it was defined in a separate doc http://yaml.org/type/merge.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. This seems actually useful – maybe suggest using a preprocessor to resolve it (thereby eliminating the need to deal with it in the spec, but still allowing to use it for users?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ePaul you can preprocess whatever you like in a tool, but per the spec--as I'm trying to make extremely explicit, merge is NOT supported.
@darrelmiller Thanks! Would appreciate the extra pair of eyes. |
Suggest we keep this one open for a bit until @darrelmiller and I (and of course anyone else in the TDC who'd like to read it) have a chance to go over the YAML spec and propose additional clarifications. I don't think this delays the progress of work on 3.0. |
@OAI/tdc please approve or reject |
If this requires an additional review as @webron states, let's do it. But I don't want this issue staying open much longer |
I think it does, but I won't get around to diving into the YAML spec before next week. |
Quoting numeric keys makes complete sense to me. |
Here are my thoughts on the subject: I think we should reference YAML 1.2 instead of 1.1
The constraint on keys should read something like: The use of Tags should be limited to the JSON schema to ensure JSON interoperability. |
I agree with @darrelmiller. I like the idea that JSON is the compatibility layer and whatever in YAML that breaks JSON/JSON Schema compatibility should be unsupported. |
In the .net space there is a 1.2 compliant parser called SharpYaml and I think it was @whitlockjc that mentioned that the JS library they are using supports 1.2. I suspect the tooling list at https://yaml.org is just out-dated. |
I have updated the text to what I believe covers all the issues. I removed the comment about the merge key value because that is a key value that is not defined by the JSON schema ruleset in YAML so therefore is automatically disallowed. I also removed the constraint regarding numeric keys needing to be quoted because numeric keys are valid in both JSON and YAML and will convert seamlessly. I did add a constraint to ensure keys cannot be non-scalar values, which is something that does not convert into JSON. |
Hmm, are you knowing a different JSON than me? Looking at JSON.org, the key in an object needs to be a string, not a number. |
@ePaul My bad. Spending too much time switching between specs and I got confused. I'll fix it. |
After talking with one of YAML's authors - let's stick with 1.2. It will hopefully also drive 1.2 implementations. As for the issue regarding the values of |
@webron Does it make sense to explicitly mention this boolean issue so implementors pay attention to it (and configure their YAML processors to not do this)? |
@ePaul My comment about needing to only use tags from the JSON Schema was my attempt to be explicit about this.
Do you think it is necessary to call out specific literals that are and are not allowed? |
Hmm, I don't know enough about YAML to be able to competently answer this – I hope OpenAPI tooling authors who support YAML know it better. I just observed once someone using |
Fixes #575