Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrays are sent incorrectly in multipart/form-data #10221

Open
FlameWolf opened this issue Nov 21, 2024 · 0 comments
Open

Arrays are sent incorrectly in multipart/form-data #10221

FlameWolf opened this issue Nov 21, 2024 · 0 comments

Comments

@FlameWolf
Copy link

Q&A (please complete the following information)

  • OS: Windows 11
  • Browser: Firefox
  • Version: 130
  • Method of installation: npm
  • Swagger-UI version: 5.18.2
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: DotNet9WebApi
  version: '1.0'
paths:
  /WeatherForecast/post:
    post:
      tags:
        - DotNet9WebApi
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/PostBody'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/PostBody'
      responses:
        '200':
          description: OK
components:
  schemas:
    PostBody:
      type: object
      properties:
        content:
          type: string
          nullable: true
        intArrProp:
          type: array
          items:
            type: integer
            format: int32
          nullable: true
      additionalProperties: false

Describe the bug you're encountering

When submitting an array as multipart/form-data content, the values are sent as a comma-separated list, instead of as multiple form parts with the same name.

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor-next.swagger.io/
  2. Paste the above sample YAML into the editor
  3. Try out the /WeatherForecast/post endpoint
  4. Add 2 or more items into the intArrProp array using the Add integer item button
  5. Click Execute and observe the resulting curl

Expected behavior

The curl should look like this:

curl -X 'POST' \
  'https://editor-next.swagger.io/WeatherForecast/post' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'content=string' \
  -F 'intArrProp=1' \
  -F 'intArrProp=2' \
  -F 'intArrProp=3'

Actual behavior

The curl looks like this:

curl -X 'POST' \
  'https://editor-next.swagger.io/WeatherForecast/post' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'content=string' \
  -F 'intArrProp=1,2,3'

Screenshots

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant