Skip to content

Commit 091b3e8

Browse files
feat: add test for the specific case
1 parent 17ba7c6 commit 091b3e8

6 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Sample API
4+
version: 1.0.0
5+
paths:
6+
/users:
7+
get:
8+
operationId: getUsers
9+
summary: Get a list of users
10+
parameters:
11+
- $ref: parameters.yaml#/Param
12+
responses:
13+
'200':
14+
description: A list of users
15+
content:
16+
application/json:
17+
schema: {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Param:
2+
in: query
3+
required: true
4+
schema:
5+
$ref: schemas.yaml#/Schema
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apis:
2+
test-api:
3+
root: openapi.yaml
4+
5+
decorators:
6+
remove-unused-components: on
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Schema:
2+
type: string
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Sample API
4+
version: 1.0.0
5+
paths:
6+
/users:
7+
get:
8+
operationId: getUsers
9+
summary: Get a list of users
10+
parameters:
11+
- $ref: '#/components/parameters/Param'
12+
responses:
13+
'200':
14+
description: A list of users
15+
content:
16+
application/json:
17+
schema: {}
18+
components:
19+
schemas:
20+
Schema:
21+
type: string
22+
parameters:
23+
Param:
24+
in: query
25+
required: true
26+
schema:
27+
$ref: '#/components/schemas/Schema'
28+
29+
bundling openapi.yaml using configuration for api 'test-api'...
30+
📦 Created a bundle for openapi.yaml at stdout <test>ms.

tests/e2e/commands.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,16 @@ describe('E2E', () => {
672672
});
673673
});
674674

675+
describe('bundle with parameter, which has reference to schemas', () => {
676+
it('should correctly bundle the api and not remove components', async () => {
677+
const testPath = join(__dirname, `bundle/parameters-reference-to-schemas`);
678+
const args = getParams(indexEntryPoint, ['bundle', '--config=redocly.yaml']);
679+
680+
const result = getCommandOutput(args, { testPath });
681+
await expect(cleanupOutput(result)).toMatchFileSnapshot(join(testPath, 'snapshot.txt'));
682+
});
683+
});
684+
675685
describe('miscellaneous', () => {
676686
const folderPath = join(__dirname, 'miscellaneous');
677687

0 commit comments

Comments
 (0)