-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
Bug: multiple files upload endpoints are broken in the Swagger UI #941
Comments
Interesting, FWIW, I have multi-file working within the swagger interface with the following setup: class UploadCreate(CamelizedBaseSchema):
"""Stores upload."""
collections: list[UploadFile]
@validator("collections", pre=True, allow_reuse=True)
def parse_collections(cls, value: UploadFile | list[UploadFile]) -> list[UploadFile]:
"""Parses a list of Upload Files."""
if isinstance(value, list):
return value
if isinstance(value, UploadFile):
return [value]
raise ValueError(value)
@post(
name="collection_upload",
path="/collections/upload",
cache=False,
tags=["Collections"],
opt={"exclude_from_auth": True},
)
async def upload_file(
data: schemas.UploadCreate = Body(media_type=RequestEncodingType.MULTI_PART),
) -> schemas.Upload:
"""Upload a file."""
uploaded_files = await services.storage.collections.upload(files=data.collections)
logger.info("Uploaded files to: %s", uploaded_files)
return schemas.Upload(
collections=uploaded_files,
message="Assessment queued for processing",
)
the |
I don't know how much we should invest in this. @cofin - can you handle this please? |
I've re-reviewed this one and I don't think there's a great way to implement a fix here. This is due to an incompatibility between the OpenAPI 3.0 and 3.1 specifications. Currently, SwaggerUI only supports OpenAPI 3.0 specification. Here's an example of an OpenAPI schema that works and one that doesn't for reference: working: { "schema": {
"properties": {
"files": {
"items": {
"type": "string",
"format": "binary",
"contentMediaType": "application/octet-stream"
},
"type": "array"
}
},
"type": "object"
}
} not working: {
"schema": {
"items": {
"type": "string",
"format": "binary",
"contentMediaType": "application/octet-stream"
},
"type": "array"
}
} Nesting all response schemas under an type of Since we have a work-around, I'm marking this one as closed. When/If the the feature above is implemented, this should resolve itself. |
Describe the bug
It's asking me to specify a list of strings in the request body instead of providing file upload button(s).
To Reproduce
The text was updated successfully, but these errors were encountered: