Skip to content

Commit

Permalink
fix(msw): ref in allOf expands the object (#1638)
Browse files Browse the repository at this point in the history
* fix(msw): `ref` in `allOf` expands the object

* chore(msw): add test case
  • Loading branch information
soartec-lab authored Sep 23, 2024
1 parent 6a5c453 commit a45b20f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/mock/src/faker/getters/combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
18 changes: 18 additions & 0 deletions tests/specifications/all-of.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -48,3 +64,5 @@ components:
properties:
tag:
type: string
PetRef:
$ref: '#/components/schemas/Pet'

0 comments on commit a45b20f

Please sign in to comment.