default value does not show up in req.swagger.params if using in: body
This seems like a bug to me. Not sure if it is a bug in swagger-node or swagger-core.
Already raised a stackoverflow question with no results.
To reiterate that SO question:
given the below swagger definition:
/myroute:
x-swagger-router-controller: myroute
post:
operationId: createSomething
parameters:
- name: payload
in: body
required: true
schema:
type: object
properties:
somedefault:
type: string
default: teststring
I would expect console.log(req.swagger.params.payload.value) in my createSomething function to be:
{somedefault: 'teststring'}
Instead I get nothing showing for the key somedefault.
Further, if you use default on a parameter that is in: query , the default value exists when console logging it. This tells me the issue may be specific to the in: body.
I've just come across this too, super annoying!
@terencechow did you ever get anywhere with it?
Same problem for me too. In addition, we can send any random parameters which are not defined in the swagger. I mean, if parameter {random:'Random String'} is not defined in the swagger schema, we can send that too and swagger simply accepts them with out any warning or errors.
I have the same problem!
Is Swagger still being actively developed?
Maybe related to https://github.com/apigee-127/swagger-tools/issues/421