YAML 媒体类型?

发布于 2024-07-09 18:47:38 字数 636 浏览 10 评论 0原文

通过 HTTP 发送使用 YAML 构建的数据时最合适的媒体类型(正式的 MIME 类型)是什么?为什么?

没有注册的申请类型文本类型 我可以看到。

示例:

> GET /example.yaml

< Content-Type: ????
<
< --- # Favorite movies
< - Casablanca
< - North by Northwest
< - Notorious

可能的选项:

  • text/x-yaml
  • text/yaml
  • text/yml
  • application/x-yaml
  • application/x-yml
  • application/yaml
  • application/yml

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

情释 2024-07-16 18:47:38

Ruby on Rails 使用 application/x-yaml 以及 text/yaml 的替代方案 (来源)。

我认为这只是一个惯例问题,据我所知,没有任何技术原因。

Ruby on Rails uses application/x-yaml with an alternative of text/yaml (source).

I think it's just a matter of convention, there is no technical why, as far as I can tell.

与之呼应 2024-07-16 18:47:38

尽管另一个答案已被接受,但请参阅此 建议的媒体类型 剑桥大学信息服务部的 Ben Harris 在 2015 年 7 月代表 YAML 团队提议媒体类型:

text/vnd.yaml

IANA 邮件列表上的 YAML 注册线程用于审查媒体类型, (建议)已弃用的别名:

text/yaml
text/x-yaml
application/x-yaml

仍然建议/待定(该线程不指示建议的状态),因此这个答案并不比其他答案更明确:-)

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 :-)

我乃一代侩神 2024-07-16 18:47:38

我会说 text/x-yaml:

text over application 因为它是人类可读的

x-yaml超过 yaml 因为它尚未被接受到 mime 类型的注册列表中。

编辑:来自 RFC 3023(XML 媒体类型):

顶级媒体类型“文本”具有
对 MIME 实体的一些限制
它们在 [RFC2045] 中进行了描述
和[RFC2046]。 特别是,
UTF-16 系列、UCS-4 和 UTF-32 是
不允许(除非超过
HTTP[RFC2616],它使用类似 MIME 的协议
机制)。

有趣...不太清楚这意味着什么,但值得深思。

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.

情绪少女 2024-07-16 18:47:38

在 Chrome 上,application/yaml 将下载,而 text/yaml 将显示。

On Chrome application/yaml will download, while text/yaml will display.

南街九尾狐 2024-07-16 18:47:38

IETF 正在努力注册 application/yaml 媒体类型和 +yaml 结构化语法后缀。

目前,我们尚未注册 text/yamlhttps://github.com /ietf-wg-httpapi/mediatypes/blob/main/draft-ietf-httpapi-yaml-mediatypes.md

欢迎参与讨论。

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.

黎歌 2024-07-16 18:47:38

不鼓励使用“x-”媒体类型,请参阅 RFC 4288,第 3.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.

友谊不毕业 2024-07-16 18:47:38

我不确定是否将此作为答案发布或作为对另一个答案的评论。 (作为单独的答案发布,因为它相当长。)
然而,我也想知道同样的事情,于是我搜索了 IANA 列表。

目前 (2023-05-13) 有草稿条目 用于在 IANA 列表中注册 YAML。 在 mime-type 下注册它:

application/yaml

但是,它还没有被添加,我不知道剩下的过程会持续多久。

06 草案 IANA 声明:

IANA review state:
  Version Changed - Review Needed

IANA expert review state:
  Need IANA Expert(s)

其中:需要审核,意思是:文件尚未经过 IANA 审核。 [ review-state ]

更新 (2023-06-06)

草案 07 审核状态更改为:

IANA review state               IANA OK - Actions Needed
IANA action state               In Progress
IANA expert review state        Expert Reviews OK 

其中 < code>IANA OK - 需要采取行动,意思是:文档需要 IANA 采取行动,IANA 注意事项部分正确指示了行动的详细信息。以及正在进行中表示:IANA 当前正在处理此文档的操作专家审核正常表示:所有专家审核均已完成,没有任何阻塞问题

更新 (2024-01-30)

目前处于草案版本 10,进展速度没有我预期的那么快,祈祷 2024 年注册。

更新 (2024-03-19)< /em>

正如其他人提到的:

草案现已转移到官方 RFC。
请参阅https://datatracker.ietf.org/doc/rfc9512/

I'm unsure whether to post this as an answer or as a comment to another answer. (Posting as separate answer as it's rather long.)
However, I was wondering the same thing and I searched the IANA listing.

There's currently (2023-05-13) a draft entry for registering YAML in the IANA listing. Registering it under the mime-type:

application/yaml

However, it's not been added yet and I do not know how long the rest of the process is going to last.

Draft 06 IANA state:

IANA review state:
  Version Changed - Review Needed

IANA expert review state:
  Need IANA Expert(s)

Where: Review Needed, means: Document has not yet been reviewed by IANA. [ review-state ]

Update (2023-06-06)

Draft 07 Review State changed to:

IANA review state               IANA OK - Actions Needed
IANA action state               In Progress
IANA expert review state        Expert Reviews OK 

Where IANA OK - Actions Needed, means: Document requires IANA actions, and the IANA Considerations section indicates the details of the actions correctly. and, In Progress means: IANA is currently processing the actions for this document and, Expert Reviews OK means: All expert reviews have been completed with no blocking issues.

Update (2024-01-30)

Currently in draft version 10, not moving as fast as I had expected, fingers crossed for a registration in 2024.

Update (2024-03-19)

As mentioned by others:

Draft has now moved to official RFC.
See https://datatracker.ietf.org/doc/rfc9512/

万劫不复 2024-07-16 18:47:38

我在与 TOML 文件格式的 MIME 类型相关的类似非常有趣的对话之后读到了这篇文章。

application/*text/*

来自 RFC (https://tools.ietf.org/html/rfc2046#section-3)

其他子类型将用于丰富文本
应用软件可以增强的形式
文本的外观,但此类软件不得
为了获得总体概念所需要的
内容。 因此,“文本”的可能子类型包括任何
无需阅读即可阅读的文字处理器格式
求助于理解该格式的软件。

来自评论 https://github.com/toml-lang/toml/问题/465#issuecomment-306231107

基于此,我认为文本子类型更适合用于非结构化(但可能是格式化的)文本,而应用程序似乎更适合结构化数据,例如 TOML。
虽然 TOML 强调人类可读性,但它仍然主要是数据
格式,旨在由应用程序读取。 作为对比,降价
文件(文本/markdown)无需处理即可传达其完整含义
进一步由应用程序,而 TOML 文件通常是
在应用程序的上下文之外没有意义
配置。

我们可以对 YAML 格式说同样的话,所以我个人更喜欢 application/*

application/* 的另一个论点是 YAMLJSON 的超集,并且使用 MIME 类型 application/json对于 JSON

application/yamlapplication/x-yaml

除非 MIME 类型已正式注册(假设任何人都计划这样做),否则应使用 application/x-* 。

由于 YAML(以及 TOML)未正式注册,因此最好使用 x- 前缀,因此我们得到 application/x-yaml 作为结果。

有趣的事实:TOML 官方文档建议使用application/toml,即使它还不是官方的。 但并非所有人都认为这是一个正确的决定。

Postman 使用 application/x-yaml

这是使用此类 MIME 类型的另一个原因:)
Postman 使用应用程序/x-yaml

I read this after similar really interesting conversation related to about MIME type for TOML file format.

application/* vs text/*

From RFC (https://tools.ietf.org/html/rfc2046#section-3)

Other subtypes are to be used for enriched text in
forms where application software may enhance the
appearance of the text, but such software must not be
required in order to get the general idea of the
content. Possible subtypes of "text" thus include any
word processor format that can be read without
resorting to software that understands the format.

From comment https://github.com/toml-lang/toml/issues/465#issuecomment-306231107

Based on that, I think subtypes of text is intended to be used more for unstructured (but possibly formatted) text, whereas application seems to be more appropriate for structured data, like TOML.
While TOML emphasizes human-readability, it's still primarily a data
format, intended to be read by applications. As a contrast, a markdown
file (text/markdown) conveys its full meaning without being processed
further by an application, whereas a TOML files are generally
meaningless outside of the context of the application they are
configuring.

We can say the same about YAML format so personally I would prefer application/*.

Another argument for application/* is that YAML is a superset of JSON and MIME type application/json is used for JSON.

application/yaml vs application/x-yaml

Unless the MIME type has officially been registered (assuming that anyone even plans to do that), application/x-* should be used.

Since YAML (as well as TOML) is not registred officially it's better to use x- prefix so we have application/x-yaml as a result.

Interesting fact: TOML official docs suggest using application/toml even if it's not official yet. But not everyone thinks that this is a right decision.

Postman uses application/x-yaml

Just another reason to use such MIME type :)
Postman uses application/x-yaml

画尸师 2024-07-16 18:47:38

来自 https://httptoolkit.com/blog/yaml-media-type-rfc/

自 2024 年 2 月 14 日起,RFC 9512 正式将 application/yaml 注册为所有 YAML 内容的媒体类型,并添加 +yaml 作为所有基于 YAML 的更具体媒体类型的标准结构化后缀。 通过此次注册,它现已包含在 IANA 维护的官方媒体类型列表中。

From https://httptoolkit.com/blog/yaml-media-type-rfc/

As of February 14th 2024, RFC 9512 formally registers application/yaml as the media type for all YAML content, and adds +yaml as a standard structured suffix for all YAML-based more specific media types. With this registration, it's now included in the official media types list maintained by the IANA.

那些过往 2024-07-16 18:47:38

现在我们有 RFC 9512

本文档向 IANA 注册 application/yaml 媒体类型和 `+yaml 结构化语法后缀。 两者都标识根据 YAML 规范序列化的文档组件。

Now we have RFC 9512:

This document registers the application/yaml media type and the `+yaml structured syntax suffix with IANA. Both identify document components that are serialized according to the YAML specification.

如果没有你 2024-07-16 18:47:38

根据 MIME 类型列表,它是 text/yaml ,即使它不在官方 IANA MIME 列表

As per MIME Types list it's text/yaml, even though it's not in official IANA MIME list

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文