swagger-node
swagger-node copied to clipboard
Restify req.params is empty
Swagger.yaml
/basket/products/{productId}:
x-swagger-router-controller: basket-controller
delete:
description: Removes product from a basket
operationId: removeProduct
parameters:
- name: productId
description: Product Id
in: path
type: string
required: true
responses:
"200":
description: Success
Controller:
function removeProduct(req, res, next) {
console.log(req.params); // outputs {}
}
Expected to req.params
to be { productId: <product id> }
.
Am I not using it right? Using Restify.
First, put your x-swagger-router-controller
under the http operation (delete
).
Next, you should have res.params['productId'].value as the value being passed in.
First, put your x-swagger-router-controller under the http operation (delete).
Doc says to put it there. Right in main README.md on front page of this repo.
Next, you should have res.params['productId'].value as the value being passed in.
res is a response object, it doesn't have params property on it. Request object has params property, but it's empty.
Do you want full code sample to try it?
Any updates on this? It is a terrible bug.
Okay, so it tuns out that these params are sitting in req.swagger.params.<param>.value
. Why not assign them to req.params
? Query params are there.
Please report this with bigger priority!
I as well have hit this issue. I was able to use fyodorvi's work around for the moment.
Also use fyodorvi's workaround as a temporary solution. Any progress on fixing this bug?
Also use @fyodorvi 's workaround as a temporary solution. Any progress on fixing this bug?