Swagger not getting formdata params
I am using swagger version 2.0
Here's my swagger spec:
/citizen_reports:
x-swagger-router-controller: reports
post:
tags:
- citizen_report
summary: Create a new Citizen Report (CitReport)
operationId: createCitizenReport
consumes:
- multipart/form-data
parameters:
- name: remark
type: string
in: formData
required: true
description: The report message
- name: is_urgent
type: boolean
in: formData
required: true
description: The report urgency
- name: latitude
type: string
in: formData
required: true
description: The report latitude
- name: longitude
type: string
in: formData
required: true
description: The report longitude
- name: incident_keyword_id
type: integer
in: formData
required: true
description: The report incident id
- name: event_id
type: integer
in: formData
required: true
description: The report event
- name: rappler_id
type: string
in: formData
required: true
description: The reporter rappler id
- name: reporter_first_name
type: string
in: formData
required: true
description: The reporter first name
- name: reporter_last_name
type: string
in: formData
required: true
description: The reporter last name
- name: reporter_contact_number
type: string
in: formData
required: true
description: The reporter contact number
responses:
401:
description: CitReport not saved
400:
description: CitReport not saved
201:
description: CitReport saved
I am getting this respose:
{
"message": "Validation errors",
"errors": [
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"0"
]
}
],
"in": "formData",
"message": "Invalid parameter (remark): Value is required but was not provided",
"name": "remark",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"0"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"1"
]
}
],
"in": "formData",
"message": "Invalid parameter (is_urgent): Value is required but was not provided",
"name": "is_urgent",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"1"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"2"
]
}
],
"in": "formData",
"message": "Invalid parameter (latitude): Value is required but was not provided",
"name": "latitude",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"2"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"3"
]
}
],
"in": "formData",
"message": "Invalid parameter (longitude): Value is required but was not provided",
"name": "longitude",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"3"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"4"
]
}
],
"in": "formData",
"message": "Invalid parameter (incident_keyword_id): Value is required but was not provided",
"name": "incident_keyword_id",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"4"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"5"
]
}
],
"in": "formData",
"message": "Invalid parameter (event_id): Value is required but was not provided",
"name": "event_id",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"5"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"6"
]
}
],
"in": "formData",
"message": "Invalid parameter (rappler_id): Value is required but was not provided",
"name": "rappler_id",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"6"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"7"
]
}
],
"in": "formData",
"message": "Invalid parameter (reporter_first_name): Value is required but was not provided",
"name": "reporter_first_name",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"7"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"8"
]
}
],
"in": "formData",
"message": "Invalid parameter (reporter_last_name): Value is required but was not provided",
"name": "reporter_last_name",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"8"
]
},
{
"code": "INVALID_REQUEST_PARAMETER",
"errors": [
{
"code": "REQUIRED",
"message": "Value is required but was not provided",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"9"
]
}
],
"in": "formData",
"message": "Invalid parameter (reporter_contact_number): Value is required but was not provided",
"name": "reporter_contact_number",
"path": [
"paths",
"/citizen_reports",
"post",
"parameters",
"9"
]
}
]
}
I tried adding consumes: multipart/form-data still having the same issue. T
The weird part is that, this was working before and all of suddent, it's not working anymore
2.0 is the version of the spec, not of any of the tools that we offer. We'd need to know the version of swagger-ui in this case.
That spec is partial, which makes it a lot more difficult to debug. Please provide a full spec and not a snippet.
I am getting this respose:
You're getting the response when doing what?
I had this issue resolved. The swagger project express project that made this bug is on 0.6.0. I revert the package to 0.1.0 since there have been problems in getting parameters and also conflicts with npm package config. Not quite sure what happened with version 0.6.0 not getting the parameters from the request.
Thanks for the update.
@Louis-at-Rappler Same here. I had to revert back to 0.1.0 from 0.70 and all is well.