Skip to content

contentEncoding is a confusing term #1100

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

Closed
ioggstream opened this issue May 11, 2021 · 10 comments
Closed

contentEncoding is a confusing term #1100

ioggstream opened this issue May 11, 2021 · 10 comments
Assignees
Labels

Comments

@ioggstream
Copy link
Contributor

Question

the use of contentEncoding, contentMediaType from here is very confusing
considered the use of json-schema in OAS3.1 spec
https://json-schema.org/understanding-json-schema/reference/non_json_data.html

I suggest to use another term instead of content and contentEncoding.

Suitable values could be stringEncoding or objectEncoding... anything that doesn't remind http :)

@handrews
Copy link
Contributor

@ioggstream we try not to change existing keywords without strong reasons. Many formats have things named around encodings and media types and those names often collide. If we try to match OpenAPI we'll be confusing with someone else. There is no universal answer.

Separately, I wrote the comments on JSON Schema's content* keywords in OAS 3.1, and I did not do a great job. I am working on a patch for OAS 3.1.1 that will hopefully be more clear.

Regarding Understanding JSON Schema, if there are improvements you want there, you should file them under its repo. @jdesrosiers is working on updating it.

@handrews
Copy link
Contributor

@ioggstream we could definitely do better by explaining the derivation of the keyword in the spec. We point to some RFCs but a one-liner "this is analogous to MIME's Content-Transfer-Encoding rather than HTTP's Content-Encoding" would help a lot, probably.

@ioggstream
Copy link
Contributor Author

ioggstream commented May 12, 2021

I think we should spend some time (both in OAS and here) to understand how this kind of functionalities are expected to work together and eg: if the examples we provide with the schema must be "encoded" or not.

For example, what happens when I have contentEncoding in the schema and in OAS I have application/form-urlencoded? Is the property encoded twice? For now it's just brainstorming...

@handrews
Copy link
Contributor

handrews commented May 12, 2021

@ioggstream there is an extensive section of the OAS specification dedicated to the form submission media types.

While it may look confusing at first, there is less going on here than people think. You have a representation of a resource in some media type. You parse the document into an internal representation that is more or less compatible with JSON Schema (this is why OAS does things like explain how to map multipart forms into array data structures - b/c that's what JSON Schema understands). Then you apply the schema.

Each step happens in isolation, unaware of the others. There isn't an interaction.

Keep in mind that contentEncoding is an annotation. It doesn't do anything. It just says that "this string here has content in it that is encoded with this encoding", and it's up to the application (in this case OAS and its tooling) to figure out what to do with that information. JSON Schema doesn't care- that's the entire point of annotations. To provide information to applications so that they can use it as they see fit, because there is no one true use case for these things that JSON Schema can lock down.

@handrews
Copy link
Contributor

In particular, contentEncoding and contentMediaType do not validate that the string described is actually an instance of that media type encoded with that encoding, due to both security and performance concerns. The application has to take that information and decide whether to decode/parse and how to handle the security implications of that action, which are highly media-type and usage-specific and not something JSON Schema can dictate.

@handrews
Copy link
Contributor

I'll make PR clarifying this side of things to the extent that that is possible. The larger work is on the OAS side, which I'll get to at some point.

@handrews handrews self-assigned this May 14, 2021
@handrews handrews added this to the draft-patch milestone May 14, 2021
@Relequestual
Copy link
Member

@ioggstream Does the PR clarify the issue for you?

@ioggstream
Copy link
Contributor Author

@Relequestual sorry for the delay, it clarifies the origin thanks! If it's possible, I'd like to have some more time to proof-read the complete text. Thanks again for asking, R.

@Relequestual
Copy link
Member

@ioggstream I'll leave this open for another 7 days, and close then if you haven't done so already =]

ioggstream added a commit to ioggstream/json-schema-spec that referenced this issue Nov 15, 2021
@ioggstream
Copy link
Contributor Author

@Relequestual PTAL #1150 In the meantime I'll close this since it's generally ok.

Relequestual pushed a commit that referenced this issue Nov 19, 2021
* Nitpick content-encoding. See #1100

* Update jsonschema-validation.xml
Relequestual pushed a commit that referenced this issue Jun 16, 2022
* Nitpick content-encoding. See #1100

* Update jsonschema-validation.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants