Skip to content

Commit

Permalink
fix: use separate resolvers for each file in join (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKarpiuk authored Oct 13, 2023
1 parent c4ae8fa commit 4769ca5
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/dull-ducks-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@redocly/openapi-core': patch
'@redocly/cli': patch
---

Fixed an issue with nested refs in the `join` command.
1 change: 1 addition & 0 deletions __tests__/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ describe('E2E', () => {
'multiple-tags-in-same-files',
'references-in-parameters',
'ignore-decorators',
'multi-references-to-one-file',
];

test.each(testDirNames)('test: %s', (dir) => {
Expand Down
16 changes: 16 additions & 0 deletions __tests__/join/multi-references-to-one-file/bar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
openapi: 3.0.3
tags:
- name: CreateBar
description: Create a new Bar
paths:
/bar/:
post:
summary: Create a single bar
operationId: createBar
responses:
'200':
description: One single bar
content:
application/json:
schema:
$ref: './nested/Response.yaml'
25 changes: 25 additions & 0 deletions __tests__/join/multi-references-to-one-file/foo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
openapi: 3.0.3
info:
title: Sample API
description: My sample api
version: 0.0.1
license:
name: 'Internal'
url: 'https://mycompany.com/license'
tags:
- name: GetSingleFoo
description: Get a single foo
- name: Foo
description: All foo operations
paths:
/foo/{id}:
get:
summary: Returns a single foo
operationId: getFoo
responses:
'200':
description: One single Food
content:
application/json:
schema:
$ref: './nested/Response.yaml'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: object
properties:
x:
type: string
y:
type: string
14 changes: 14 additions & 0 deletions __tests__/join/multi-references-to-one-file/nested/Response.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type: object
required:
- id
- name
properties:
id:
type: string
format: uuid
name:
type: string
description:
type: string
subFoo:
$ref: './FooObject.yaml'
93 changes: 93 additions & 0 deletions __tests__/join/multi-references-to-one-file/snapshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`E2E join without options test: multi-references-to-one-file 1`] = `
openapi: 3.0.3
info:
title: Sample API
description: My sample api
version: 0.0.1
license:
name: Internal
url: https://mycompany.com/license
tags:
- name: GetSingleFoo
description: Get a single foo
x-displayName: GetSingleFoo
- name: Foo
description: All foo operations
x-displayName: Foo
- name: foo_other
x-displayName: other
- name: CreateBar
description: Create a new Bar
x-displayName: CreateBar
- name: bar_other
x-displayName: other
paths:
/foo/{id}:
get:
summary: Returns a single foo
operationId: getFoo
responses:
'200':
description: One single Food
content:
application/json:
schema:
$ref: '#/components/schemas/Response'
tags:
- foo_other
/bar/:
post:
summary: Create a single bar
operationId: createBar
responses:
'200':
description: One single bar
content:
application/json:
schema:
$ref: '#/components/schemas/Response'
tags:
- bar_other
components:
schemas:
FooObject:
type: object
properties:
x:
type: string
'y':
type: string
Response:
type: object
required:
- id
- name
properties:
id:
type: string
format: uuid
name:
type: string
description:
type: string
subFoo:
$ref: '#/components/schemas/FooObject'
x-tagGroups:
- name: foo
tags:
- GetSingleFoo
- Foo
- foo_other
description: My sample api
- name: bar
tags:
- CreateBar
- bar_other
openapi.yaml: join processed in <test>ms
`;
2 changes: 1 addition & 1 deletion packages/cli/src/commands/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function handleJoin(argv: JoinOptions, config: Config, packageVersi
bundleDocument({
document,
config: config.styleguide,
externalRefResolver,
externalRefResolver: new BaseResolver(config.resolve),
}).catch((e) => {
exitWithError(`${e.message}: ${blue(document.source.absoluteRef)}`);
})
Expand Down

1 comment on commit 4769ca5

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 75.9% 3999/5269
🟡 Branches 65.82% 2130/3236
🟡 Functions 67.92% 648/954
🟡 Lines 76.09% 3748/4926

Test suite run success

636 tests passing in 93 suites.

Report generated by 🧪jest coverage report action from 4769ca5

Please sign in to comment.