Skip to content

Commit f373039

Browse files
authored
fix(msw): fix break msw when anyof included allof (#1635)
* fix(msw): fix break msw when `anyOf` include `allOf` * chore: add test case
1 parent 398b667 commit f373039

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

packages/mock/src/faker/getters/combine.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export const combineSchemasMock = ({
117117
}
118118

119119
const isObjectBounds =
120-
!combine || (combine.separator === 'oneOf' && separator === 'allOf');
120+
!combine ||
121+
(['oneOf', 'anyOf'].includes(combine.separator) && separator === 'allOf');
121122

122123
if (!index && isObjectBounds) {
123124
if (

tests/specifications/any-of.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,49 @@ paths:
2222
responses:
2323
'204':
2424
description: Ok
25+
/any-of-included-all-of-pet:
26+
get:
27+
summary: Gets anyOf included allOf pets
28+
operationId: getAnyOfIncludedAllOfPets
29+
responses:
30+
'200':
31+
description: Pet
32+
content:
33+
application/json:
34+
schema:
35+
$ref: '#/components/schemas/Pet'
2536
components:
2637
schemas:
2738
A:
2839
type: string
2940
enum:
3041
- A
42+
Pet:
43+
anyOf:
44+
- $ref: '#/components/schemas/Cat'
45+
- $ref: '#/components/schemas/Dog'
46+
Cat:
47+
type: object
48+
required:
49+
- color
50+
properties:
51+
color:
52+
type: string
53+
Dog:
54+
allOf:
55+
- $ref: '#/components/schemas/DogType'
56+
- $ref: '#/components/schemas/DogDetail'
57+
DogType:
58+
type: object
59+
required:
60+
- type
61+
properties:
62+
type:
63+
type: string
64+
DogDetail:
65+
type: object
66+
required:
67+
- name
68+
properties:
69+
name:
70+
type: string

0 commit comments

Comments
 (0)