Skip to content

Commit 32ade39

Browse files
author
omer
committed
adding a test
1 parent f60f7e6 commit 32ade39

3 files changed

Lines changed: 74 additions & 2 deletions

File tree

test/openapi3/openapi3-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ describe('input-validation middleware tests', function () {
2626
app = testServer;
2727
});
2828
});
29+
it('valid pets', function (done) {
30+
request(app)
31+
.get('/pets')
32+
.expect(200, function (err, res) {
33+
if (err) {
34+
throw err;
35+
}
36+
expect(res.body.result).to.equal('OK');
37+
done();
38+
});
39+
});
2940
it('valid dog', function (done) {
3041
request(app)
3142
.post('/pet')

test/openapi3/pets.yaml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,60 @@ security:
2323
- app-id: []
2424
private-key: []
2525
paths:
26+
/pets:
27+
get:
28+
summary: get all pets
29+
security:
30+
- public-key: []
31+
description: >-
32+
tags:
33+
- pets
34+
operationId: listPets
35+
responses:
36+
'200':
37+
description: list of pets
38+
headers:
39+
x-zooz-request-id:
40+
description: request id
41+
schema:
42+
type: string
43+
content:
44+
application/json:
45+
schema:
46+
$ref: '#/components/schemas/pets'
47+
'400':
48+
description: Bad request
49+
headers:
50+
x-zooz-request-id:
51+
description: request id
52+
schema:
53+
type: string
54+
content:
55+
application/json:
56+
schema:
57+
$ref: '#/components/schemas/error_model'
58+
'401':
59+
description: Unauthorize
60+
headers:
61+
x-zooz-request-id:
62+
description: request id
63+
schema:
64+
type: string
65+
content:
66+
application/json:
67+
schema:
68+
$ref: '#/components/schemas/error_model'
69+
'500':
70+
description: Internal error
71+
headers:
72+
x-zooz-request-id:
73+
description: request id
74+
schema:
75+
type: string
76+
content:
77+
application/json:
78+
schema:
79+
$ref: '#/components/schemas/error_model'
2680
/pet:
2781
post:
2882
summary: Create a Pet
@@ -368,6 +422,10 @@ components:
368422
oneOf:
369423
- $ref: '#/components/schemas/dog_object'
370424
- $ref: '#/components/schemas/cat_object'
425+
pets:
426+
type: array
427+
items:
428+
$ref: "#/components/schemas/pet"
371429
pet-discriminator-on-child:
372430
description: pet
373431
type: object
@@ -454,4 +512,4 @@ components:
454512
- min_length
455513
properties:
456514
min_length:
457-
type: string
515+
type: string

test/openapi3/test-server-pet.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ module.exports = function (options) {
2020
var app = express();
2121
app.use(bodyParser.json());
2222

23+
app.get('/pets', inputValidation.validate, function (req, res, next) {
24+
res.json({ result: 'OK' });
25+
});
2326
app.post('/pet', inputValidation.validate, function (req, res, next) {
2427
res.json({ result: 'OK' });
2528
});
@@ -45,4 +48,4 @@ module.exports = function (options) {
4548

4649
return Promise.resolve(app);
4750
});
48-
};
51+
};

0 commit comments

Comments
 (0)