'Is there ways to convert WebkitFormBoundary to YAML Swagger/OpenAPI?

How to transform below to Swagger/OpenAPI YAML?

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="image"; filename="1.png"
Content-Type: image/png

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="text"
    
This is a picture of me
------WebKitFormBoundary7MA4YWxkTrZu0gW--


Solution 1:[1]

OpenAPI 3.0.x

openapi: 3.0.0
...

paths:
  /something:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              # required: [image, text]  # TODO: Specify which fields are required
              properties:
                image:
                  type: string
                  format: binary
                text:
                  type: string
      responses:
        ...

More info: Multipart Requests on swagger.io

OpenAPI 2.0

In OpenAPI 2.0, individual form fields are defined as in: formData parameters. The operation also need to have consumes: [multipart/form-data]. More info: File Upload on swagger.io.

swagger: '2.0'
...

paths:
  /something:
    post:
      consumes:
        - multipart/form-data
      parameters:
        - in: formData
          name: image
          type: file
          # required: true   # Uncomment if the "image" field is required
        - in: formData
          name: text
          type: string
          # required: true   # Uncomment if the "text" field is required
      responses:
        ...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Helen