PayU / openapi-validator-middleware

Input validation using Swagger (Open API) and ajv
Apache License 2.0
144 stars 50 forks source link

Support specifying explicit endpoint path for middleware instance #75

Closed kibertoad closed 5 years ago

kibertoad commented 5 years ago

fixes #36 fixes #62

I would suggest reviewing #74 separately and first, since this once builds on what that PR introduces, but alternatively everything can be reviewed within this PR - it's a superset of #74.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.8%) to 98.291% when pulling 3c0d3a3048572312bd5712169093b794bd6524f4 on feature/36-support-explicit-routes into a5f76cc427707bcde6ce3770a420081a8ca40f53 on master.

kobik commented 5 years ago

@kibertoad, i thought you wanted something to control the route through the middleware. like this

app.post("/echo", validator.validate("post", "/echo"), (req, res, next) => {
  res.json({ output: req.body.input });
});

btw, you'd only need to pass the request, as the middleware has access to the request method from req, so it would look like this.

app.post("/echo", validator.validate({route: "/echo"}), (req, res, next) => {
  res.json({ output: req.body.input });
});

anyway, as with this change we'll need a validate function that returns validate middleware so it could receive the configuration, this would be a breaking change.

kibertoad commented 5 years ago

@kobik Fair point. Can we postpone it till 2.0.0 then? It's not really that high priority feature for me, I'd much rather #69 landed faster.

kobik commented 5 years ago

@kibertoad I have no problem with that

kibertoad commented 5 years ago

@kobik Is everything ready for 1.0.0 then?

kobik commented 5 years ago

@kibertoad i think we should close this MR for now and until we agree on how we solve it.

kibertoad commented 5 years ago

@kobik Makes sense :)