You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a need to send and receive bytes and files via endpoints.
Typically one does this using
content-type: application/octet-stream and sends or receives bytes (file name info is not needed) per rfc 2046
content-type: multipart/form-data where one sends multiple files (and file name info is needed) per rfc 7578
Json schemas do not have data types that include these types of binary information
The v3.1.0 spec says that we should describe these schemas with empty schema which should allow everything.
But that implies that there are allowed types outside of the json schema ecosystem which we need here.
I propose adding two new types which would be used in openapi contexts:
binary
file
Which are used by the above use cases and only allow in content of those kinds.
binary is python type bytes
file is python file like object which must include a file name
Ways one could do this:
One could do this with a new keyword:
opeanpi-type: binary
opeanpi-type: file
or allow in both types
opeanpi-type:
- binary
- file
And that keyword must only apply where a schemas type is unset
2. Allow binary and file as additional types that are valid values for the json schema type keyword
3. Allow describing these types as not json schema types (but this does still not allow differentiation between file and binary types)
not:
type:
- object
- list
- string
- number
- integer
- "null"
- boolean
Allow describing these types as no type (I don't like this, it is too vague)
type: []
This matters for code generation because when describing the types of data that a schema can store, one needs to include all types. Per the openapi definition, binary data is also accepted into empty schema. So when one is sending binary data via
application/octet-stream or multipart/form-data the allowed types would be:
all json schema types + binary
though application/octet-stream would only allow binary data in.
Or tooling needs to take empty schema into consideration for certain content types only and say in this case empty schema means binary only.
It is better to be explicit and have a way of saying this can take binary data only and not this empty schema means binary only, or it allows in all json types and binary even though only binary is used here.
Openapi 3.1.0 spec guidance:
One should be using contentMediaType + contentEncoding
But that assumes that binary data can be converted to a string representation for local storage as a string.
Maybe the code does not know the encoding of the binary data. If that is the case, then we cannot convert those bytes into a string representation. Also, when we do that with files, we lose the filename information.
That filename info is needed for multipart/form-data transmission of files.
The text was updated successfully, but these errors were encountered:
spacether
changed the title
Proposal: v3.1.X add file and binary types to support bytes and file use cases
Proposal: v3.1.X add file and binary types to support bytes/file only use cases
Sep 7, 2022
There is a need to send and receive bytes and files via endpoints.
Typically one does this using
Json schemas do not have data types that include these types of binary information
The v3.1.0 spec says that we should describe these schemas with empty schema which should allow everything.
But that implies that there are allowed types outside of the json schema ecosystem which we need here.
I propose adding two new types which would be used in openapi contexts:
Which are used by the above use cases and only allow in content of those kinds.
binary is python type bytes
file is python file like object which must include a file name
Ways one could do this:
or allow in both types
And that keyword must only apply where a schemas type is unset
2. Allow binary and file as additional types that are valid values for the json schema
type
keyword3. Allow describing these types as not json schema types (but this does still not allow differentiation between file and binary types)
This matters for code generation because when describing the types of data that a schema can store, one needs to include all types. Per the openapi definition, binary data is also accepted into empty schema. So when one is sending binary data via
application/octet-stream or multipart/form-data the allowed types would be:
though application/octet-stream would only allow binary data in.
Or tooling needs to take empty schema into consideration for certain content types only and say in this case empty schema means binary only.
It is better to be explicit and have a way of saying this can take binary data only and not this empty schema means binary only, or it allows in all json types and binary even though only binary is used here.
Openapi 3.1.0 spec guidance:
One should be using contentMediaType + contentEncoding
But that assumes that binary data can be converted to a string representation for local storage as a string.
Maybe the code does not know the encoding of the binary data. If that is the case, then we cannot convert those bytes into a string representation. Also, when we do that with files, we lose the filename information.
That filename info is needed for multipart/form-data transmission of files.
The text was updated successfully, but these errors were encountered: