Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix for incorrect refs on join #1400

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/grumpy-rings-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@redocly/cli": patch
---

Fixed an issue where using the `--prefix-components-with-info-prop` option with the `join` command caused `$refs` to include duplicated prefixes.
3 changes: 3 additions & 0 deletions __tests__/join/prefix-components-with-info-prop/bar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ components:
some-property:
description: bar description
type: string
another-property:
description: description
$ref: '#/components/schemas/some-property'
3 changes: 3 additions & 0 deletions __tests__/join/prefix-components-with-info-prop/foo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ components:
some-property:
description: foo description
type: string
another-property:
description: description
$ref: '#/components/schemas/some-property'
6 changes: 6 additions & 0 deletions __tests__/join/prefix-components-with-info-prop/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ components:
Foo Example OpenAPI 3 definition foo._some-property:
description: foo description
type: string
Foo Example OpenAPI 3 definition foo._another-property:
description: description
$ref: '#/components/schemas/Foo Example OpenAPI 3 definition foo._some-property'
Bar Example OpenAPI 3 definition._some-property:
description: bar description
type: string
Bar Example OpenAPI 3 definition._another-property:
description: description
$ref: '#/components/schemas/Bar Example OpenAPI 3 definition._some-property'
x-tagGroups:
- name: Foo Example OpenAPI 3 definition foo.
tags:
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
apiFilename: string;
apiTitle?: string;
tags: Oas3Tag[];
potentialConflicts: any;

Check warning on line 54 in packages/cli/src/commands/join.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
tagsPrefix: string;
componentsPrefix: string | undefined;
};
Expand Down Expand Up @@ -183,7 +183,7 @@
}
}

const joinedDef: any = {};

Check warning on line 186 in packages/cli/src/commands/join.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
const potentialConflicts = {
tags: {},
paths: {},
Expand Down Expand Up @@ -306,7 +306,7 @@
}

function getIndexGroup(name: string): number {
return joinedDef[xTagGroups].findIndex((item: any) => item.name === name);

Check warning on line 309 in packages/cli/src/commands/join.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
}

function createXTagGroups(name: string) {
Expand All @@ -314,7 +314,7 @@
joinedDef[xTagGroups] = [];
}

if (!joinedDef[xTagGroups].some((g: any) => g.name === name)) {

Check warning on line 317 in packages/cli/src/commands/join.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
joinedDef[xTagGroups].push({ name, tags: [] });
}

Expand All @@ -340,7 +340,7 @@
joinedDef['servers'] = [];
}
for (const server of servers) {
if (!joinedDef.servers.some((s: any) => s.url === server.url)) {

Check warning on line 343 in packages/cli/src/commands/join.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
joinedDef.servers.push(server);
}
}
Expand Down Expand Up @@ -639,7 +639,7 @@
}

function addInfoSectionAndSpecVersion(
documents: any,

Check warning on line 642 in packages/cli/src/commands/join.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
prefixComponentsWithInfoProp: string | undefined
) {
const firstApi = documents[0];
Expand Down Expand Up @@ -801,7 +801,7 @@
function crawl(object: any, visitor: any) {
if (!isObject(object)) return;
for (const key of Object.keys(object)) {
visitor(object, key);
visitor(object[key], key);
crawl(object[key], visitor);
}
}
Expand Down
Loading