swagger-api / swagger-api/swagger-ui

Missing square brackets on object array property after serializing.

Open
#8,614 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

  • OS: Windows
  • Browser: Chrome
  • Version: 113.0.5672.63
  • Method of installation: PHP port for swagger UI - https://github.com/zircote/swagger-php
  • Swagger-UI version:v4.18.3
  • Swagger/OpenAPI version: 3.0

When using content-type as multi-part/form-data with array object parameters, it seems that swagger UI encodes the parameter incorrectly, its missing square brackets for arrays []:
image

image

Here is my open api definition, you can see the problem for yourself on https://editor-next.swagger.io just paste the definition and test the field.

openapi: 3.0.3
info:
  title: Swagger Petstore - OpenAPI 3.0
  description: 'test'
  version: "1.0.0"
  termsOfService: http://swagger.io/terms/
servers:
  - url: "https://127.0.0.1"
paths:
  /api/kits:
    post:
      tags:
      - Kit
      summary: Create a new kit
      description: Create a new kit
      operationId: createKit
      requestBody:
        description: Pass kit details
        required: true
        content:
          multipart/form-data:
            schema:
              properties:
                products:
                  type: array
                  items:
                    properties:
                      id:
                        type: integer
                        example: '1'
                      quantity:
                        type: integer
                        example: '1'
                    type: object
                name:
                  type: string
                  format: text
                  example: Kit 1
              type: object
      responses:
        '200':
          description: Successful operation

The array property is not serialized properly, its missing the square brackets...
Is this behavior intended, or is this a bug? How do I fix this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the report in Swagger UI or editor-next.swagger.io with the provided OpenAPI 3.0.3 multipart/form-data definition and inspect the request serialization path. Done means the object array property is serialized with the expected square brackets ([]) while preserving the other form fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.