Skip to content
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

openapi 3.1 - changes for binary data #5507

Open
chrisradek opened this issue Jan 7, 2025 · 1 comment
Open

openapi 3.1 - changes for binary data #5507

chrisradek opened this issue Jan 7, 2025 · 1 comment
Assignees
Labels
emitter:openapi3 Issues for @typespec/openapi3 emitter feature New feature or request triaged:core

Comments

@chrisradek
Copy link
Member

Open API 3.1 uses different fields to describe binary data than Open API 3.0.

Open API 3.0

Open API 3.0: working with binary data
Open API 3.0 uses 2 formats to work with binary data using the string type:

  • binary for unencoded binary data
  • byte for binary data embedded in a text-only format (e.g. application/json).
    Note: byte represents base64 encoded characters.

Open API 3.1

Open API 3.1: working with binary data
Open API 3.1 ignores format for binary data.

For unencoded binary data, the type is also omitted and only contentMediaType is required (even this can be omitted in some cases)

For encoded data, format is effectively replaced with contentEncoding which explicitly states how the content within the text is encoded (e.g. base64).

Example table taken from above spec link:

Keyword Unencoded Encoded
type omit string
contentMediaType application/octet-stream application/octet-stream
contentEncoding omit base64 or base64url

For multipart media types, it's recommended not to specify the contentMediaType since there will be either an implied or explicit contentType that takes precedence. contentEncoding is still relevant.
Open API 3.1: Table showing default contentType based on type/contentEncoding pairs
More details around file uploads can be found here: Open API 3.1: considerations for file uploads

Other considerations

Open API 3.1 allows specifying contentEncodings other than base64/base64url. The contentEncoding and contentMediaType JsonSchema decorators should support customizing these values.

@chrisradek chrisradek self-assigned this Jan 7, 2025
@chrisradek chrisradek removed their assignment Jan 8, 2025
@markcowl
Copy link
Contributor

markcowl commented Jan 8, 2025

est: 5

@markcowl markcowl added this to the [2025] January milestone Jan 8, 2025
@markcowl markcowl added emitter:openapi3 Issues for @typespec/openapi3 emitter feature New feature or request labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:openapi3 Issues for @typespec/openapi3 emitter feature New feature or request triaged:core
Projects
None yet
Development

No branches or pull requests

2 participants