Skip to content

Commit

Permalink
example 6 enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
carmine committed Oct 16, 2024
1 parent 263c641 commit 789b43b
Show file tree
Hide file tree
Showing 5 changed files with 1,604 additions and 330 deletions.
24 changes: 24 additions & 0 deletions examples/6-multi-file-spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,27 @@ From this `6-multi-file-spec` directory, run:
```shell
npm start
```

## Try

correct validation response with a multi-file spec
```
curl -s -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{}'|jq
{
"message": "request/body must have required property 'id'",
"errors": [
{
"path": "/body/id",
"message": "must have required property 'id'",
"errorCode": "required.openapi.validation"
}
]
}
```

add the required id and it returns correct

```
curl -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{"id": 123}'
{} # note this test server returns empty object upon valid request
```
2 changes: 0 additions & 2 deletions examples/6-multi-file-spec/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const http = require('http');
const OpenApiValidator = require('express-openapi-validator');
Expand All @@ -15,7 +14,6 @@ app.use(express.text());
app.use(express.json());

app.use(logger('dev'));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/spec', express.static(apiSpec));
Expand Down
Loading

0 comments on commit 789b43b

Please sign in to comment.