orval-labs / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
3.18k stars 336 forks source link

fix(msw): `ref` in `allOf` expands the object #1638

Closed soartec-lab closed 2 months ago

soartec-lab commented 2 months ago

Status

READY/WIP/HOLD

Description

fix #1119

Fixed a syntax error that occurred when using ref in an item referenced by allOf. The reference with ref is not necessarily an object, but there are few cases where allOf refers to an item other than an object, so this covers many cases.

Before

ref objects will cause an syntax error.

export const getGetNestedRefInAllOfPetsResponseMock = (): GetNestedRefInAllOfPets200 => ({{id: faker.number.int({min: undefined, max: undefined}), name: faker.word.sample()},tag: faker.word.sample()})

After

ref objects are expanded so no error occurs.

export const getGetNestedRefInAllOfPetsResponseMock = (): GetNestedRefInAllOfPets200 => ({...{id: faker.number.int({min: undefined, max: undefined}), name: faker.word.sample()},tag: faker.word.sample()})

Related PRs

none

Todos

Steps to Test or Reproduce

i added test case