cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass array of strings in post body?

Highlighted
New Contributor

How to pass array of strings in post body?

Hi everyone, I'm trying to get my Swagger UI 3.17.1 POST operation to take a JSON array of strings but am currently getting a runtime error from Symfony/API Platform: "Invalid value provided (invalid IRI?)."  I'd appreciate any help on how to get my configuration working.  Here is my current YAML configuration:

        zooniverse-datasheets:
            method: 'POST'
            path: '/projects/{id}/zooniverse/datasheets'
            controller: 'App\Controller\ZooniverseSendDatasheetsAction'
            # read: false
            swagger_context:
                summary: Send project's datasheet(s) to Zooniverse
                parameters:
                    - in: path
                      name: id
                      required: true
                      type: string
                    - in: body
                      name: datasheets
                      required: false
                      schema:
                          type: array
                          items:
                              type: string
                          example: ["ID1", "ID2", "ID3"]
                      # description: list of datasheet IDs in JSON array format
                responses:
                    '201':
                        description: 'Success'
                    '400':
                        description: 'Invalid input'
                    '404':
                        description: 'Resource not found'

 and here is a screen shot of the operator so far: Screen Shot 2020-07-14 at 11.25.02 AM.png

 I'm pretty new to Swagger but have gotten other operators to work but having trouble with this one.  Any help is greatly appreciated!

thanks,

Mona

 

2 REPLIES 2
Highlighted
Moderator

Re: How to pass array of strings in post body?

Hi Mona,

The OpenAPI definition of your POST request body is correct.

                    - in: body
                      name: datasheets
                      required: false
                      schema:
                          type: array
                          items:
                              type: string
                          example: ["ID1", "ID2", "ID3"]

The issue seems to be specific to API Platform. I suggest that you open an issue with that project directly.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
New Contributor

Re: How to pass array of strings in post body?

Thank you Helen!  Will do.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors