From b6fc74dbce132dc1796b17681401100ad09e5719 Mon Sep 17 00:00:00 2001 From: soartec-lab Date: Mon, 23 Sep 2024 02:51:22 +0000 Subject: [PATCH 1/2] fix(msw): `ref` in `allOf` expands the object --- packages/mock/src/faker/getters/combine.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/mock/src/faker/getters/combine.ts b/packages/mock/src/faker/getters/combine.ts index 7af7cbe0f..f22aca93d 100644 --- a/packages/mock/src/faker/getters/combine.ts +++ b/packages/mock/src/faker/getters/combine.ts @@ -116,6 +116,14 @@ export const combineSchemasMock = ({ currentValue = `${currentValue ? `${currentValue},` : ''}${itemResolvedValue.value}`; } + if ( + resolvedValue.type === undefined && + currentValue && + separator === 'allOf' + ) { + currentValue = `...${currentValue}`; + } + const isObjectBounds = !combine || (['oneOf', 'anyOf'].includes(combine.separator) && separator === 'allOf'); From 641b50de86159547926d901a6d2855d7c74d216f Mon Sep 17 00:00:00 2001 From: soartec-lab Date: Mon, 23 Sep 2024 03:03:16 +0000 Subject: [PATCH 2/2] chore(msw): add test case --- tests/specifications/all-of.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/specifications/all-of.yaml b/tests/specifications/all-of.yaml index ff726cda2..bf3fd4c82 100644 --- a/tests/specifications/all-of.yaml +++ b/tests/specifications/all-of.yaml @@ -27,6 +27,22 @@ paths: - type: object required: - color + /rested-ref-in-all-of-pets: + get: + operationId: getNestedRefInAllOfPets + tags: + - pets + description: |- + Nested ref in allOf pets. + responses: + '200': + description: User + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/PetRef' + - $ref: '#/components/schemas/PetDetail' components: schemas: @@ -48,3 +64,5 @@ components: properties: tag: type: string + PetRef: + $ref: '#/components/schemas/Pet'