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.2k stars 337 forks source link

Mocks (for MSW) are wrongly generated with deeply nested objects #1692

Open Hypenate opened 2 weeks ago

Hypenate commented 2 weeks ago

What are the steps to reproduce this issue?

YAML Path

  '/api/tenants/{tenantId}':
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TenantComposite'

YAML Schema

    TenantComposite:
      allOf:
        - $ref: '#/components/schemas/Tenant'

    TenantComposite:
      allOf:
        - $ref: '#/components/schemas/Tenant'

    Tenant:
      allOf:
        - $ref: '#/components/schemas/TenantLight'

What happens?

In the .msw file, it generates the following: export const getGetApiTenantsTenantIdResponseMock = (): TenantCompositeDto => ({...enabled: faker.datatype.boolean(),

What were you expecting to happen?

In the .msw file, it generated the following: export const getGetApiTenantsTenantIdResponseMock = (): TenantCompositeDto => ({enabled: faker.datatype.boolean(),

What versions are you using?

7.2.0

Hypenate commented 2 weeks ago

Maybe related to #1635