I'm using OpenAPI 3.0.1 and swagger-codegen-maven-plugin 3.0.27 (happy to adjust these veersions). I have defined the following for uploading a file (along with other data) ...
/myobject/:
post:
tags:
- my-objects
operationId: add
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/MyDTO'
required: true
...
schemas:
MyDTO:
type: object
properties:
...
dataFile:
type: string
format: binary
I would like to restrict the types of files uploaded to those with mime types of "application/vnd.ms-excel" and "text/csv". How do I do that with the OpenAPI spec/Swagger CodeGen?
You may define the
encodingpart in your spec, defining the expected mime types, likeRefer to https://swagger.io/docs/specification/describing-request-body/multipart-requests/