swagger-node icon indicating copy to clipboard operation
swagger-node copied to clipboard

default value does not show up in req.swagger.params if using in: body

Open terencechow opened this issue 8 years ago • 5 comments

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.

terencechow avatar Mar 19 '17 17:03 terencechow

I've just come across this too, super annoying!

Stono avatar Oct 03 '17 02:10 Stono

@terencechow did you ever get anywhere with it?

Stono avatar Oct 03 '17 03:10 Stono

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.

mykumar avatar Mar 21 '18 20:03 mykumar

I have the same problem!

Is Swagger still being actively developed?

JohnOllhorn avatar Jun 08 '18 20:06 JohnOllhorn

Maybe related to https://github.com/apigee-127/swagger-tools/issues/421

dt-atkinson avatar Oct 11 '18 11:10 dt-atkinson