Closed khusenov closed 1 day ago
Hello @khusenov you can take a look at Open API's documentation for it - https://swagger.io/docs/specification/v3_0/describing-request-body/describing-request-body/#form-data.
In terms of an API it should be just providing the media type multipart/form-data
. This happens as the key of a request.body
. So it would be something like:
registry.registerPath({
method: 'post',
path: '/some/path',
description: 'Multipart',
request: {
body: {
content: {
'multipart/form-data': { // note this!
schema: z.any() // You can use any form of validation here
},
},
},
},
responses: {
200: {
content: {
'application/json': {
schema: z.object({
message: z.string(),
}),
},
},
description: '',
},
},
});
@AGalabov Thank you for the reply.
I was thinking the same thing, but library provides only application/json.
Maybe this is because zod doesn't support file types
Anyway, I hardcoded without using zod to solve this.
How do I define a form-data schema to upload files in an API request?
I couldn't find it in the documentation.