krakenjs / generator-swaggerize

Yeoman generator for design-driven apis with swagger 2.0 and krakenjs/swaggerize tools.
Other
70 stars 34 forks source link

Where are the path(req.params),query(req.query) parameters handles in generator-swaggerize? #108

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi @tlivings , I have hosted APIs from a swagger specification. I am hitting an API from postman. I am receiving the query and path parameters in the URL in the handler.js (generator-swaggerize) using req.query for query parameters in the URL and req.params for path params of the URL of the API.

Where is the datatype of the query and path parameters decided in generator-swaggerize? How can I manipulate it before receiving in req.query or req.params in handler.js?

tlivings commented 6 years ago

Are you using express of hapi? The data type validation is specified in the swagger API document.

ghost commented 6 years ago

Hi @tlivings , I am using express.

Where is the dataype of the query and path params accesed from? Which node module does it? Please let me know .

Regards, vaishnavi

tlivings commented 6 years ago

I am not 100% sure what you are asking but let's see if this answers your question.

When a request comes in, after it has been parsed, the type validation runs. If a parameter isn't valid the client will receive a 400 status code.

In some cases there will be type coercion.

But after validation has run, there will not be a reference to the expected type. There will just be the value of the parameter.