Formdata in OpenAPI specification file
https://stackoverflow.com/questions/77693580/how-to-use-formdata-in-openapi-with-swagger-ui
https://stackoverflow.com/a/77694365/1504291
The encoding part may not be necessary all the time. What is important is how the schema for FormData is defined.
openapi: 3.0.3
info:
title: test
version: "1.0.0"
description: a description of an api with a "multipart/form-data" request
servers:
- url: 'https://api.host.com/v1'
name: the host server
paths:
"/image":
post:
description: a description of the api
requestBody:
description: a description of the requestBody
required: true
content:
"multipart/form-data":
schema:
type: object
properties:
name:
type: string
file:
type: string
format: binary
encoding:
name:
headers:
content-disposition:
$ref: "#/components/headers/content-disposition"
contentType: "application/json"
file:
headers:
content-disposition:
$ref: "#/components/headers/content-disposition"
contentType: 'image/png, image/jpeg'
responses:
"200":
description: OK
content:
"application/json":
schema:
type: object
properties: {}
components:
headers:
content-disposition:
description: a description of this header
required: true
schema:
type: string