Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Mar 21, 2019
1 parent 2ca55ab commit 7943376
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ new OpenApiMiddleware({
apiSpecPath: './openapi.yaml',
validateApiDoc: true, // default
enableObjectCoercion: true, // should be default
errorTransform: v => ({ // optional error transform
statusCode: v.status, // the http status to return
error: { // the custom error object
code: v.status,
message: v.errors[0].message,
},
}),
}).install(app);
```

Expand Down Expand Up @@ -57,10 +64,7 @@ new OpenApiMiddleware({
}).install(app);

app.get('/v1/pets', function(req, res, next) {
res.json([
{ id: 1, name: 'max' },
{ id: 2, name: 'mini' },
]);
res.json([{ id: 1, name: 'max' }, { id: 2, name: 'mini' }]);
});

app.post('/v1/pets', function(req, res, next) {
Expand All @@ -72,7 +76,7 @@ app.post('/v1/pets', function(req, res, next) {
app.get('/v1/pets/:id', function(req, res, next) {
res.json({
id: req.params.id,
name: 'sparky'
name: 'sparky',
});
});

Expand Down

0 comments on commit 7943376

Please sign in to comment.