ggirodda
ggirodda

Reputation: 790

swagger-ui - open api 3, multipart/form-data array problem

I'm uising swagger-ui with OpenApi 3.0.2 spec.
I set a requestBody with multipart/form-data content.
Everithing works fine when I execute the request from swagger-ui but...
If I add a parameter of type array, it will be transformed in curl call in this way:
-F "tags=my,tag"
I need the array to be exploded

-F 'tags[]=my' \
-F 'tags[]=tag'

I look at the documentation and find some style and explode properties, but they only works on parameters attribute, not on requestBody (?).

In my route file:

post:
  tags:
  - media-image
  summary: Create a media image
  requestBody:
    description: A JSON object containing media image information
    required: true
    content:
      multipart/form-data:
        schema:
          allOf:
          - $ref: '../schemas/media-image-fillable.yaml'
          - required:
            - title
            - back_office_title
            - alt
            - file

The media-image-fillable.yaml

type: object
allOf:
- $ref: './media-image-base.yaml'
- properties:
    file:
      type: string
      format: binary
    tags:
      type: array
      items:
        type: string

and the media-image-base.yaml

type: object
properties:
  title:
    type: string
  back_office_title:
    type: string
  description:
    type: string
  alt:
    type: string

Upvotes: 2

Views: 7074

Answers (1)

ggirodda
ggirodda

Reputation: 790

Ok, I found the solution.
I only had to rename tags property in tags[], now it works.

Upvotes: 1

Related Questions