Forum Discussion

theminja's avatar
theminja
Visitor
2 years ago

Swagger: Submitting integer in multipart/form-data?

I am trying to submit an integer within the form but I get the error: "message": "request/body/price must be integer",

 

Here is the request:

 

 

  /item:
    post:
      security:
        - bearerAuth: []
      description: Upload Item
      requestBody:
        description: Request Body
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Item'
      responses:
        201:
          description: Item Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ItemUploadSuccess'
        default:
          description: Unexpected Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

 

 

And here is the Item schema it's referring to:

 

 

    Item:
      type: object
      properties:
        fileImage:
          type: string
          format: binary
        name:
          type: string
        price:
          type: integer
        condition:
          type: string
          enum: [like new, great, good, poor]
      required:
        - name
        - price
        - condition

 

 

Can I not submit an integer within multipart/form data? Any advice is appreciated

  • Hi theminja ,

     

    There are a few pieces here, more info is needed to see if this is a bug with any specific Swagger tool, or if this is more implementation specific. Couple of questions to help answer that.

    1. What are you using in the backend? Was it generated by Swagger Codegen or other, or is it a framework?

    2. How are you executing requests and where do you see the message "request/body/price must be integer".

     

    Please be specific as possible, in order for us to see how we can help.

    PS: The OpenAPI specification (fka Swagger) does support integers in multipart/form. So it sounds like an implementation issue or possibly a bug