Skip to content

Commit 789b43b

Browse files
author
carmine
committed
example 6 enhancements
1 parent 263c641 commit 789b43b

File tree

5 files changed

+1604
-330
lines changed

5 files changed

+1604
-330
lines changed

examples/6-multi-file-spec/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,27 @@ From this `6-multi-file-spec` directory, run:
1515
```shell
1616
npm start
1717
```
18+
19+
## Try
20+
21+
correct validation response with a multi-file spec
22+
```
23+
curl -s -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{}'|jq
24+
{
25+
"message": "request/body must have required property 'id'",
26+
"errors": [
27+
{
28+
"path": "/body/id",
29+
"message": "must have required property 'id'",
30+
"errorCode": "required.openapi.validation"
31+
}
32+
]
33+
}
34+
```
35+
36+
add the required id and it returns correct
37+
38+
```
39+
curl -XPOST localhost:3000/v1/queries -H 'content-type: application/json' -d '{"id": 123}'
40+
{} # note this test server returns empty object upon valid request
41+
```

examples/6-multi-file-spec/app.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const express = require('express');
22
const path = require('path');
3-
const cookieParser = require('cookie-parser');
43
const logger = require('morgan');
54
const http = require('http');
65
const OpenApiValidator = require('express-openapi-validator');
@@ -15,7 +14,6 @@ app.use(express.text());
1514
app.use(express.json());
1615

1716
app.use(logger('dev'));
18-
app.use(cookieParser());
1917
app.use(express.static(path.join(__dirname, 'public')));
2018

2119
app.use('/spec', express.static(apiSpec));

0 commit comments

Comments
 (0)