When creating my swagger.yaml I have decided to use formData for creating users. So /users POST would contain the following parameters.
parameters:
-
name: first_name
in: formData
description: First name
required: true
type: string
x-example: Jane
-
name: last_name
in: formData
description: Last name
required: true
type: string
x-example: Doe
-
name: username
in: formData
description: Username
required: true
type: string
x-example: janedoe
-
name: password
in: formData
description: Password
required: true
type: string
x-example: abc123
According to the swagger spec and all the examples I've seen this is how you're supposed to do this, however I get an "invalid json" error because it's trying to parse the body, which doesn't exist. I have gotten the in: body type to work by including body-parser in my project. Without it even the in: body type fails saying that "body is required".
When creating my swagger.yaml I have decided to use formData for creating users. So /users POST would contain the following parameters.
According to the swagger spec and all the examples I've seen this is how you're supposed to do this, however I get an "invalid json" error because it's trying to parse the body, which doesn't exist. I have gotten the
in: body
type to work by including body-parser in my project. Without it even thein: body
type fails saying that "body is required".Is body-parser causing the conflict? If so, how can I remove body parser and have both
in: body
andin: formData
work?