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

feat(oas31): add support for file upload #10335

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

char0n
Copy link
Member

@char0n char0n commented Mar 3, 2025

We should now display file input when:

  • contentEncoding is base64
  • contentMediaType is application/octet-stream, image/*, video/* or audio/*
  • Media Type Object is empty

Does not add support for file upload if schema has union type or if type and contentEncoding/contentMediaType are defined in oneOf/anyOf.


Attribution: @glowcloud

const isStringType = schema.get("type") === "string"
const format = schema.get("format")
const isBinaryFormat = format === "binary"
const isBase64Format = format === "base64" || format === "byte"
Copy link
Member Author

@char0n char0n Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment author @glowcloud:

Until now, we always checked for base64 format but not for byte.
In 3.0.3, the data type for base64 encoded characters is byte but when there are examples for file uploads, it specifies format: base64.
In 3.0.4, the data type still specifies byte and one of the examples specifies format: byte. There is no example with format: base64.
Not sure if we should just drop base64.

const isBase64Encoding = schema.get("contentEncoding") === "base64"

return (
(type === "string" || type === "any") &&
Copy link
Member Author

@char0n char0n Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment author @glowcloud:

If the type is not specified, we will get type any because there is no check for contentEncoding or contentMediaType when inferring types. I see that other types also don't have a check for all of the keywords that apply to them - not sure if that is intended or not, so I opted for checking for any instead of adding them there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant