OAI / OpenAPI-Specification

The OpenAPI Specification Repository
https://openapis.org
Apache License 2.0
28.83k stars 9.07k forks source link

Question: `Content-Encoding` HTTP header field and `contentEncoding` #2476

Closed ioggstream closed 4 months ago

ioggstream commented 3 years ago

Question

Reading the following part https://github.com/OAI/OpenAPI-Specification/blame/master/versions/3.1.0.md#L1451 it is not clear to me the meaning of the following sentence

contentEncoding keyword [..] may be used to specify the Content-Encoding for the schema.

My understanding is that it specifies the encoding used to serialize the application data before it is passed to the HTTP layer, which eventually adds one or more content-codings.

The encoding specified by the contentEncoding keyword is independent of an encoding specified by the Content-Type header in the request or response or metadata of a multipart body [..] then the encoding specified in the Content-Type header.

Is Content-Type the HTTP header field? In that case, iiuc its value is a media-type: how can I specify an encoding? Does it mean "charset"?

cc: @handrews

handrews commented 3 years ago

Hmm... maybe that was supposed to be Content-Encoding? The encodings in Content-Encoding are things like gzip (compression applied at the HTTP layer) while the encodings in contentEncoding are application-level things like base64, base64url, or quoted-printable.

ioggstream commented 3 years ago

Content-Encoding should work, as it contains an ordered list of content-codings. I can make a PR but dunno if we should align json-schema too.

Probably some more explanation are required because if I contentEncoding eg. a jpeg in base64 my understanding is that it's probably no more an HTTP Content-Type: image/jpg but something else. In general, I finf the name contentEncoding bearing a lot of possible different meanings in the HTTP context (again, it's jsonschema stuff probably).

WDYT?

handrews commented 3 years ago

@ioggstream JSON Schema's contentEncoding is correct as it is. I think the only error is that I (or someone) typed Content-Type instead of Content-Encoding.

ioggstream commented 3 years ago

@ioggstream JSON Schema's contentEncoding is correct as it is. I think the only error is that I (or someone) typed Content-Type instead of Content-Encoding.

What I don't get is

contentEncoding keyword [..] may be used to specify the Content-Encoding for the schema

json-schema has a Content-Encoding ?

handrews commented 3 years ago

@ioggstream JSON Schema's contentEncoding keyword does something different from HTTP's Content-Encoding header. This happens when different standards have different backgrounds and there are only so many words to use. JSON Schema's contentEncoding uses encodings from RFC 4648 (and to a lesser degree, RFC 2045. These come from MIME's Content-Transfer-Encoding header, which (again) is not the same as HTTP's Content-Encoding header. But JSON Schema doesn't do transferring. Anyway, HTTP notes this issue (MIME vs HTTP headers) in RFC 7231 as well.

ioggstream commented 3 years ago

@handrews sure! Please check the attached PR which should clarify a bit.

handrews commented 4 months ago

PRs merged for 3.1.1 and 3.2.0 - closing!