Custom content type - is registering with IANA mandatory?

独自空忆成欢 提交于 2019-11-29 01:30:37

问题


I'm developing an API as RESTful as possible (though the HATEOAS constraint is not met thus it is not a REST API per se)

I'm versioning the API, and since there are several ways to do this, I think I'm going to use the Accept header. I do know the alternatives, but the purpose of this question is not to find a suitable way to version the API.

As far as I know, there are two ways to version API using the Accept header, as seen here, here and here:

application/vnd.company.myapp-v1+json

or using a qualifier

application/vnd.company.myapp+json;v=1

While this is quite clear, I understood that all x- custom content types have been deprecated and vnd. content types have to be registered with IANA.

The API is not and will not be public, all the clients using it are developed internally.

Is registering a custom vnd. content type with IANA mandatory? What happens if the content type is not registered? Can I simply use Accept header application/vnd.company.myapp+json;v=2 even without registering it with IANA?

Since I need a custom content type for content negociation purely for versioning purposes, can I use qualifier such as application/json;v=2 ?


回答1:


From what I can read from https://tools.ietf.org/html/rfc6838#section-3.2 it is not mandatory, however if you have and API that is public it is encouraged to do so.

RFC6838 is about registering new MIME/Media Types, with the following text it doesn't seem to be a problem for private API (product)

The vendor tree is used for media types associated with publicly
available products.

Also it is not required for the public API (product), like I said it is encouraged.

While public exposure and review of media types to be registered in
the vendor tree are not required, using the media-types@iana.org
mailing list for review is encouraged, to improve the quality of
those specifications. Registrations in the vendor tree may be
submitted directly to the IANA, where they will undergo Expert Review [RFC5226] prior to approval



来源:https://stackoverflow.com/questions/29121241/custom-content-type-is-registering-with-iana-mandatory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!