Skip to content

Commit 0c2cb21

Browse files
committed
feat: Added tests and review
1 parent 63690cf commit 0c2cb21

File tree

10 files changed

+148
-3
lines changed

10 files changed

+148
-3
lines changed

src/apitypes/rest/rest.operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ const createSingleOperationSpec = (
295295
return {
296296
...specBase,
297297
paths: {
298-
[path]: { ...pathData },
298+
[path]: pathData,
299299
},
300300
components: {
301301
...specBase.components,

test/document-group.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,18 @@ describe('Document Group test', () => {
4747
await runMergeOperationsCase('case1')
4848
})
4949

50-
test('should have properly merged documents with pathItems', async () => {
51-
await runMergeOperationsCase('case2')
50+
describe('PathItems tests', () => {
51+
test('should have properly merged documents', async () => {
52+
await runMergeOperationsCase('case2')
53+
})
54+
55+
test('should have properly merged documents and delete unused operations', async () => {
56+
await runMergeOperationsCase('case3')
57+
})
58+
59+
test('should have properly merged documents mixed formats (operation + pathItems operation)', async () => {
60+
await runMergeOperationsCase('case4')
61+
})
5262
})
5363

5464
async function runMergeOperationsCase(caseName: string): Promise<void> {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: "3.1.0"
2+
info:
3+
title: test
4+
version: 0.1.0
5+
paths:
6+
/path1:
7+
$ref: '#/components/pathItems/pathItem1'
8+
components:
9+
pathItems:
10+
pathItem1:
11+
get:
12+
responses:
13+
'200':
14+
description: response description main
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
openapi: "3.1.0"
2+
info:
3+
title: test
4+
version: 0.1.0
5+
paths:
6+
/path2:
7+
$ref: '#/components/pathItems/pathItem2'
8+
components:
9+
pathItems:
10+
pathItem2:
11+
post:
12+
responses:
13+
'200':
14+
description: response description main
15+
pathItem3:
16+
post:
17+
responses:
18+
'200':
19+
description: response description unused
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"packageId": "55",
3+
"apiType": "rest",
4+
"version": "v1",
5+
"files": [
6+
{
7+
"fileId": "1.yaml",
8+
"publish": true,
9+
"labels": [],
10+
"commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a1cd"
11+
},
12+
{
13+
"fileId": "2.yaml",
14+
"publish": true,
15+
"labels": [],
16+
"commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd"
17+
}
18+
]
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
openapi: 3.1.0
2+
info:
3+
title: manualGroup
4+
version: v1
5+
paths:
6+
/path1:
7+
$ref: '#/components/pathItems/pathItem1'
8+
/path2:
9+
$ref: '#/components/pathItems/pathItem2'
10+
components:
11+
pathItems:
12+
pathItem1:
13+
get:
14+
responses:
15+
'200':
16+
description: response description main
17+
pathItem2:
18+
post:
19+
responses:
20+
'200':
21+
description: response description main
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
openapi: "3.1.0"
2+
info:
3+
title: test
4+
version: 0.1.0
5+
paths:
6+
/path1:
7+
$ref: '#/components/pathItems/pathItem1'
8+
components:
9+
pathItems:
10+
pathItem1:
11+
get:
12+
responses:
13+
'200':
14+
description: response description main
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
openapi: "3.1.0"
2+
info:
3+
title: test
4+
version: 0.1.0
5+
paths:
6+
/path2:
7+
post:
8+
responses:
9+
'200':
10+
description: response description main
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"packageId": "55",
3+
"apiType": "rest",
4+
"version": "v1",
5+
"files": [
6+
{
7+
"fileId": "1.yaml",
8+
"publish": true,
9+
"labels": [],
10+
"commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a1cd"
11+
},
12+
{
13+
"fileId": "2.yaml",
14+
"publish": true,
15+
"labels": [],
16+
"commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd"
17+
}
18+
]
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
openapi: 3.1.0
2+
info:
3+
title: manualGroup
4+
version: v1
5+
paths:
6+
/path1:
7+
$ref: '#/components/pathItems/pathItem1'
8+
/path2:
9+
post:
10+
responses:
11+
'200':
12+
description: response description main
13+
components:
14+
pathItems:
15+
pathItem1:
16+
get:
17+
responses:
18+
'200':
19+
description: response description main

0 commit comments

Comments
 (0)