Skip to content

Commit

Permalink
fix(msw): fix break msw when anyof included allof (#1635)
Browse files Browse the repository at this point in the history
* fix(msw): fix break msw when `anyOf` include `allOf`

* chore: add test case
  • Loading branch information
soartec-lab authored Sep 22, 2024
1 parent 398b667 commit f373039
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/mock/src/faker/getters/combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export const combineSchemasMock = ({
}

const isObjectBounds =
!combine || (combine.separator === 'oneOf' && separator === 'allOf');
!combine ||
(['oneOf', 'anyOf'].includes(combine.separator) && separator === 'allOf');

if (!index && isObjectBounds) {
if (
Expand Down
40 changes: 40 additions & 0 deletions tests/specifications/any-of.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,49 @@ paths:
responses:
'204':
description: Ok
/any-of-included-all-of-pet:
get:
summary: Gets anyOf included allOf pets
operationId: getAnyOfIncludedAllOfPets
responses:
'200':
description: Pet
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
components:
schemas:
A:
type: string
enum:
- A
Pet:
anyOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
Cat:
type: object
required:
- color
properties:
color:
type: string
Dog:
allOf:
- $ref: '#/components/schemas/DogType'
- $ref: '#/components/schemas/DogDetail'
DogType:
type: object
required:
- type
properties:
type:
type: string
DogDetail:
type: object
required:
- name
properties:
name:
type: string

0 comments on commit f373039

Please sign in to comment.