Skip to content

Commit 0f1f89d

Browse files
committed
feat: Review
1 parent c70196e commit 0f1f89d

File tree

8 files changed

+82
-6
lines changed

8 files changed

+82
-6
lines changed

test/builder.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,33 @@ describe('Editor scenarios', () => {
145145
})
146146
})
147147
})
148+
149+
describe('PathItems build', () => {
150+
const COMPONENTS_ITEM_1_PATH = ['components', 'pathItems', 'componentsPathItem1']
151+
test('should have separate operations with pathitems', async () => {
152+
const pkg = LocalRegistry.openPackage('builder/define-pathitems-via-reference-object-chain')
153+
const editor = await Editor.openProject(pkg.packageId, pkg)
154+
155+
await pkg.publish(pkg.packageId, { packageId: pkg.packageId })
156+
const result = await editor.run({
157+
version: 'v1',
158+
status: VERSION_STATUS.RELEASE,
159+
buildType: BUILD_TYPE.BUILD,
160+
})
161+
162+
const resultOperations = Array.from(result.operations.values())
163+
expect(resultOperations.length).toEqual(2)
164+
165+
const [postOperation, getOperation] = resultOperations
166+
// check that we have only path operation in componentsPathItem1 for path1-post
167+
expect(postOperation.operationId).toEqual('path1-post')
168+
expect(postOperation.data).toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'post'])
169+
expect(postOperation.data).not.toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'get'])
170+
171+
// check that we have only get operation in componentsPathItem1 for path1-get
172+
expect(getOperation.operationId).toEqual('path1-get')
173+
expect(getOperation.data).not.toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'post'])
174+
expect(getOperation.data).toHaveProperty([...COMPONENTS_ITEM_1_PATH, 'get'])
175+
})
176+
})
148177
})

test/merge/openapi/openapi.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,16 @@ describe('Merge openapi schemas', () => {
258258
})
259259

260260
test('Should throw on different methods content', async () => {
261-
// 1: [[../should-throw-on-different-methods/case1/1.yaml]]
262-
// 2: [[../should-throw-on-different-methods/case1/2.yaml]]
263-
const testId = 'should-throw-on-different-methods/case1'
261+
// 1: [[../should-throw-on-different-methods/should-throw-on-different-methods-in-path/1.yaml]]
262+
// 2: [[../should-throw-on-different-methods/should-throw-on-different-methods-in-path/2.yaml]]
263+
const testId = 'should-throw-on-different-methods/should-throw-on-different-methods-in-path'
264264
await expect(getTestData(testId)).rejects.toThrowError(/paths.\/path1/)
265265
})
266266

267267
test('Should throw on different pathItems methods content', async () => {
268-
// 1: [[../should-throw-on-different-methods/case2/1.yaml]]
269-
// 2: [[../should-throw-on-different-methods/case2/2.yaml]]
270-
const testId = 'should-throw-on-different-methods/case2'
268+
// 1: [[../should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/1.yaml]]
269+
// 2: [[../should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component/2.yaml]]
270+
const testId = 'should-throw-on-different-methods/should-throw-on-different-methods-in-pathItem-component'
271271
await expect(getTestData(testId)).rejects.toThrowError(/components.pathItems.path1/)
272272
})
273273

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Pet Store API
4+
version: 1.0.0
5+
paths:
6+
/path1:
7+
$ref: '#/components/pathItems/componentsPathItem'
8+
components:
9+
schemas:
10+
MySchema:
11+
type: object
12+
properties:
13+
message:
14+
type: string
15+
pathItems:
16+
componentsPathItem:
17+
$ref: '#/components/pathItems/componentsPathItem1'
18+
componentsPathItem1:
19+
post:
20+
responses:
21+
'200':
22+
description: Pet successfully added
23+
content:
24+
application/json:
25+
schema:
26+
$ref: '#/components/schemas/MySchema'
27+
get:
28+
responses:
29+
'200':
30+
description: Pet successfully added
31+
content:
32+
application/json:
33+
schema:
34+
$ref: '#/components/schemas/MySchema'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"packageId": "55",
3+
"apiType": "rest",
4+
"version": "v1",
5+
"files": [
6+
{
7+
"fileId": "1.yaml",
8+
"publish": true,
9+
"labels": [],
10+
"commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd"
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)