2

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
2
  • Can you post your OpenAPI definition file? Commented Nov 8, 2018 at 17:43
  • Ok, I posted it, thank you Commented Nov 9, 2018 at 7:01

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.