swagger-jsdoc
swagger-jsdoc copied to clipboard
post an array of string in formData
when i try to post an array of string in formData swagger add double quotes Ex: [ ""Value"" ]
/**
* @swagger
* /accessories-centers:
* post:
* tags:
* - Accessories-Centers
* consumes:
* - "multipart/form-data"
* summary: Create a new Accessories center
* parameters:
* - name: "mainSpecialities[]"
* in: "formData"
* description: "Ids Main Specialities Of accessories center"
* required: false
* collectionFormat: multi
* type: array
* items:
* type: string
* responses:
* 201:
* description: Returns Created accessories-Center
*/
Output:
[ '"id1","id2"' ]
I have the same problem, this issue is opened since january, it seems nobody think it is important to solve.
@kalinchernev @chdanielmueller @devlouisc @fliptoo
@nrayann usually when a given issue needs additional attention, people who want to help do any of the following:
- add steps to reproduce
- explain what is the expected vs actual behavior
- provide snippets of code
- give examples of steps or solutions they've tried before asking for help
Others have previously written about this human part of things. @-ing more people in an issue with unclear problem definition, steps to reproduce or a hint from the reporter he has "done his homework" is normally getting less attention, it's not that "nobody thinks it is important to solve".
Thus, please help by providing details, it will be really useful for anyone having the time to take a look at the problem.
PS: If I had the time to take a look at the issue, I won't be able to simply jump into debugging, I have to assume and imagine a lot before understanding the issue.
Ok @kalinchernev , my problem is very similar to @Crackz 's problem, I will give more details.
When I execute the bellow route via swagger's user interface, the values from users array comes wrapped in a single quote. This route posts a file, an array of strings and string values.
Data from users[] parameter:
[ '"5bc76aadfa97ec274c8556c3","5bc76a3efa97ec274c8556c2"' ]
js doc:
* @swagger
*
* /api/projects:
* post:
* summary: Create a project
* description: Create a project
* security:
* - Bearer: []
* consumes:
* - multipart/form-data
* tags:
* - Project
* produces:
* - application/json
* parameters:
* - in: formData
* name: bimModel
* type: file
* required: true
* description: The file to upload.
* - in: formData
* name: name
* type: string
* required: true
* - in: formData
* name: address
* type: string
* required: true
* - in: formData
* name: bucketKey
* type: string
* required: true
* - in: formData
* collectionFormat: multi
* name: users[]
* type: array
* items:
* type: string
* required: true
* responses:
* 200:
* description: Project is valid request
* 400:
* description: Bad Request
* 401:
* description: Unauthorized
* 404:
* description: Not Found
*
*/
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Im getting the same issue still in 2023