{"action":"created","issue":{"url":"https://api.github.com/repos/apigee-127/swagger-tools/issues/345","repository_url":"https://api.github.com/repos/apigee-127/swagger-tools","labels_url":"https://api.github.com/repos/apigee-127/swagger-tools/issues/345/labels{/name}","comments_url":"https://api.github.com/repos/apigee-127/swagger-tools/issues/345/comments","events_url":"https://api.github.com/repos/apigee-127/swagger-tools/issues/345/events","html_url":"https://github.com/apigee-127/swagger-tools/issues/345","id":132149410,"number":345,"title":"Adding a easier way to access to params [Question ~ Request]","user":{"login":"miduga","id":1561955,"avatar_url":"https://avatars.githubusercontent.com/u/1561955?v=3","gravatar_id":"","url":"https://api.github.com/users/miduga","html_url":"https://github.com/miduga","followers_url":"https://api.github.com/users/miduga/followers","following_url":"https://api.github.com/users/miduga/following{/other_user}","gists_url":"https://api.github.com/users/miduga/gists{/gist_id}","starred_url":"https://api.github.com/users/miduga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miduga/subscriptions","organizations_url":"https://api.github.com/users/miduga/orgs","repos_url":"https://api.github.com/users/miduga/repos","events_url":"https://api.github.com/users/miduga/events{/privacy}","received_events_url":"https://api.github.com/users/miduga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-02-08T14:01:49Z","updated_at":"2016-02-08T23:32:40Z","closed_at":null,"body":"Working with swagger-tools I've found, on my opinion, that is too convoluted access to request params. I've added a manual middleware to deal with it and, so far, I'm pretty happy with the result.\r\n\r\n```javascript\r\n    // Add an easier way to get params from swagger-tools\r\n    app.use((req, res, next) => {\r\n      function getParam (param) {\r\n        if (req.swagger.params[ param ]) {\r\n          return req.swagger.params[ param ].value\r\n        }\r\n      }\r\n\r\n      req.getParams = () => {\r\n        var obj = {}\r\n        for (let param in req.swagger.params) {\r\n          obj[param] = getParam(param)\r\n        }\r\n        return obj\r\n      }\r\n      req.getParam = getParam\r\n      next()\r\n    })\r\n```\r\n\r\nMy question is, how are you dealing with this? Have you found another way to easily access the params?  Would it be a good idea to add something like the middleware above in order to add a better way to access the value of the params to swagger-tools? Any feedback? Thanks for your awesome work!"},"comment":{"url":"https://api.github.com/repos/apigee-127/swagger-tools/issues/comments/181622636","html_url":"https://github.com/apigee-127/swagger-tools/issues/345#issuecomment-181622636","issue_url":"https://api.github.com/repos/apigee-127/swagger-tools/issues/345","id":181622636,"user":{"login":"miduga","id":1561955,"avatar_url":"https://avatars.githubusercontent.com/u/1561955?v=3","gravatar_id":"","url":"https://api.github.com/users/miduga","html_url":"https://github.com/miduga","followers_url":"https://api.github.com/users/miduga/followers","following_url":"https://api.github.com/users/miduga/following{/other_user}","gists_url":"https://api.github.com/users/miduga/gists{/gist_id}","starred_url":"https://api.github.com/users/miduga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miduga/subscriptions","organizations_url":"https://api.github.com/users/miduga/orgs","repos_url":"https://api.github.com/users/miduga/repos","events_url":"https://api.github.com/users/miduga/events{/privacy}","received_events_url":"https://api.github.com/users/miduga/received_events","type":"User","site_admin":false},"created_at":"2016-02-08T23:32:40Z","updated_at":"2016-02-08T23:32:40Z","body":"Yeah, sure, it makes sense! :+1: But it was you the first to mention the word deprecating! :stuck_out_tongue: I would say that's a fantastic idea to separate the modules and I hope to see a great evolution of the new modules. As we're going to build an API using swagger-tools at our company I'll try to be up to date on the ongoing development and try to give a hand. :)"}}