Skip to content

Encoding is not exploding a array property in requestBody in swagger-ui. #5106

@knobik

Description

@knobik

Q&A (please complete the following information)

  • OS: ubuntu
  • Browser: chrome
  • Version: 71.0.3578.98 (Official Build) (64-bit)
  • Method of installation: composer
  • Swagger-UI version: 3.18.3
  • Swagger/OpenAPI version: OpenApi 3.0

Content & configuration

Swagger/OpenAPI definition:

paths:
  /match/started:
    post:
      tags:
        - match
      summary: 'Callback for when a game has started.'
      operationId: 'App\Http\Controllers\Api\V1\MatchController::started'
      requestBody:
        description: 'Something something batman!'
        required: true
        content:
          multipart/form-data:
            schema:
              required:
                - match_uuid
              properties:
                game_uuid:
                  type: string
                'player_uuids[]':
                  type: array
                  items:
                    type: string
              type: object
            encoding:
              'player_uuids[]':
                style: form
                explode: true
      responses:
        200:
          description: 'success response'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Api_V1_Match_Started'

Swagger-UI configuration options:

const ui = SwaggerUIBundle({
    dom_id: '#swagger-ui',

    url: "http://matchmaking.test/docs/api-docs.json",
    operationsSorter: null,
    configUrl: null,
    validatorUrl: null,
    oauth2RedirectUrl: "http://matchmaking.test/api/oauth2-callback",

    requestInterceptor: function() {
      this.headers['X-CSRF-TOKEN'] = '';
      return this;h
    },

    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],

    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],

    layout: "StandaloneLayout"
  })

Screenshots

screenshot from 2019-01-04 10-11-56

How can we help?

Encoding is not exploding a array property in requestBody in swagger-ui.
Im getting this command for curl:

curl -X POST "https://editor.swagger.io/api/v1/match/started" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "game_uuid=test" -F "player_uuids[]=aaa,bbb,ccc"

notice this part:
-F "player_uuids=aaa,bbb,ccc"

im trying to get this result
-F "player_uuids[]=aaa" -F "player_uuids[]=bbb" -F "player_uuids[]=ccc"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions