diff --git a/.changeset/grumpy-rings-beam.md b/.changeset/grumpy-rings-beam.md new file mode 100644 index 0000000000..03d426ec75 --- /dev/null +++ b/.changeset/grumpy-rings-beam.md @@ -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. diff --git a/__tests__/join/prefix-components-with-info-prop/bar.yaml b/__tests__/join/prefix-components-with-info-prop/bar.yaml index a91982c434..17de9fb5a2 100644 --- a/__tests__/join/prefix-components-with-info-prop/bar.yaml +++ b/__tests__/join/prefix-components-with-info-prop/bar.yaml @@ -25,3 +25,6 @@ components: some-property: description: bar description type: string + another-property: + description: description + $ref: '#/components/schemas/some-property' diff --git a/__tests__/join/prefix-components-with-info-prop/foo.yaml b/__tests__/join/prefix-components-with-info-prop/foo.yaml index 4adf06a277..77bd13dda5 100644 --- a/__tests__/join/prefix-components-with-info-prop/foo.yaml +++ b/__tests__/join/prefix-components-with-info-prop/foo.yaml @@ -33,3 +33,6 @@ components: some-property: description: foo description type: string + another-property: + description: description + $ref: '#/components/schemas/some-property' diff --git a/__tests__/join/prefix-components-with-info-prop/snapshot.js b/__tests__/join/prefix-components-with-info-prop/snapshot.js index 7a09b00a4c..8fe789b46a 100644 --- a/__tests__/join/prefix-components-with-info-prop/snapshot.js +++ b/__tests__/join/prefix-components-with-info-prop/snapshot.js @@ -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: diff --git a/packages/cli/src/commands/join.ts b/packages/cli/src/commands/join.ts index 5bcdc42a95..2fba5a08da 100644 --- a/packages/cli/src/commands/join.ts +++ b/packages/cli/src/commands/join.ts @@ -801,7 +801,7 @@ async function validateApi( 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); } }