Closed codeclown closed 4 years ago
Just came back from holiday and will look at this PR this week. Before that can you rebase this on master, fix the tests and add tests to keep code coverage at 100%? The travis build and coveralls should be working now.
path-to-regexp uses express style path, while OAS uses another syntax for path parameter, this implementation does not work with OAS path's like /user/{id}
Finally taking a stab at resolving this PR.
@backbone87 Thanks for pointing that out!
I checked the V3 spec about paths and it seems like OpenAPI supports path params in format {name}
and nothing else (also not allowing slashes), so I've implemented a simple transform from OAS to Express path before passing onto path-to-regexp (could've removed the dependency altogether and implemented the regex logic in this project, but I felt it would've been unnecessary).
I have a problem making the OpenApiValidator.test.ts test case pass because TypeScript will not accept the second parameter. Types come from here. Talking about this line in the test:
match(req, { ...baseRes }, () => {});
I've tried null
(obvious fail) and new express.Response
(not so obvious fail).
And the build is failing due to something unrelated:
[error] "2019-10-16T10:11:50.900Z" 'error from lcovParse: ' 'Failed to parse string'
[error] "2019-10-16T10:11:50.903Z" 'input: ' ''
[error] "2019-10-16T10:11:50.903Z" 'error from convertLcovToCoveralls'
@Hilzu Tests are green.
This looks good. Thank you for your contribution and thanks for waiting this long to get the change merged.
@Hilzu Thanks for merging. Added some docs as well in separate PR: https://github.com/Hilzu/express-openapi-validate/pull/37
Addresses issue https://github.com/Hilzu/express-openapi-validate/issues/10.
This is from an older branch I made when I needed this functionality in a project.
Let me know if there's something to adjust (namings, tests, something else) and I'll happily revisit this.