'YAML media type?
What is the most appropriate media type (formally MIME type) to use when sending data structured with YAML over HTTP and why?
There is no registered application type or text type that I can see.
Example:
> GET /example.yaml
< Content-Type: ????
<
< --- # Favorite movies
< - Casablanca
< - North by Northwest
< - Notorious
Possible options:
- text/x-yaml
- text/yaml
- text/yml
- application/x-yaml
- application/x-yml
- application/yaml
- application/yml
Solution 1:[1]
Although another answer was accepted, please refer to this Proposed media type registration for YAML thread on the IANA mailing list for reviewing Media Type in which Ben Harris, University of Cambridge Information Services, proposed in July 2015 on behalf of the YAML team the media type:
text/vnd.yaml
with (suggested) deprecated aliases:
text/yaml
text/x-yaml
application/x-yaml
That is still proposed/pending (the thread does not indicate status of the proposal) so this answer is no more definitive than the others :-)
Solution 2:[2]
I'd say text/x-yaml:
text over application because it's a human-readable
x-yaml over yaml because it hasn't been accepted into the registered list of mime types.
Edit: from RFC 3023 (XML Media Types):
The top-level media type "text" has some restrictions on MIME entities and they are described in [RFC2045] and [RFC2046]. In particular, the UTF-16 family, UCS-4, and UTF-32 are not allowed (except over HTTP[RFC2616], which uses a MIME-like mechanism).
Interesting... Not exactly sure what it means, but food for thought.
Solution 3:[3]
On Chrome application/yaml will download, while text/yaml will display.
Solution 4:[4]
"x-" media types are discouraged, see RFC 4288, Section 3.4. The right thing to do is to use the personal tree, the vendor tree, or to actually attempt a proper media type registration.
Solution 5:[5]
As per MIME Types list it's text/yaml, even though it's not in official IANA MIME list
Solution 6:[6]
The IETF is working to register the application/yaml media type and the +yaml structured syntax suffix.
Currently, we are not registering text/yaml. https://github.com/ietf-wg-httpapi/mediatypes/blob/main/draft-ietf-httpapi-yaml-mediatypes.md
Feel free to participate in the discussion.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martin Tournoij |
| Solution 2 | Liam |
| Solution 3 | Giulio |
| Solution 4 | Community |
| Solution 5 | The Godfather |
| Solution 6 | Roberto Polli |
