Skip to content

Commit b6cceb6

Browse files
committed
Add a test for removing multiple matching responses
1 parent 0df6791 commit b6cceb6

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

test/expected/remove-responses.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Responses
4+
version: 1.0.0
5+
paths:
6+
/foo:
7+
get:
8+
responses:
9+
'200':
10+
description: OK
11+
/bar:
12+
post:
13+
responses:
14+
'201':
15+
description: Created
16+
/baa:
17+
post:
18+
responses:
19+
'201':
20+
description: Shouted

test/openapi/responses.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Responses
4+
version: 1.0.0
5+
paths:
6+
/foo:
7+
get:
8+
responses:
9+
'200':
10+
description: OK
11+
'500':
12+
description: oops
13+
/bar:
14+
post:
15+
responses:
16+
'201':
17+
description: Created
18+
'500':
19+
description: oops
20+
default:
21+
description: something
22+
/baa:
23+
post:
24+
responses:
25+
'201':
26+
description: Shouted
27+
'500':
28+
description: oops
29+
default:
30+
description: something

test/overlay.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,14 @@ test('overlay document with empty actions is a nop', () => {
103103
expect(result).toEqual(expectedOutput);
104104
});
105105

106+
test('remove all matching responses', () => {
107+
const openapiFile = "test/openapi/responses.yaml";
108+
const overlayFile = "test/overlays/remove-responses.yaml";
109+
const expectedFile = "test/expected/remove-responses.yaml";
110+
const expectedOutput = fs.readFileSync(expectedFile, 'utf8');
111+
112+
const result = overlayFiles(openapiFile, overlayFile);
113+
114+
expect(result).toEqual(expectedOutput);
115+
});
116+

test/overlays/remove-responses.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
overlay: 1.0.0
2+
info:
3+
title: Response code removal test
4+
version: 1.0.0
5+
6+
extends: response-codes.yaml
7+
8+
actions:
9+
- target: $.paths..responses['500']
10+
remove: true
11+
12+
- target: $.paths..responses['default']
13+
remove: true

0 commit comments

Comments
 (0)