You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(mock): avoid double-wrapping null branch for required nullable scalars
A required property typed as an OpenAPI 3.1 nullable union
(`type: [<scalar>, 'null']`) — the same shape OAS 3.0 `nullable: true` is
upgraded to by @scalar/openapi-parser — was wrapped with a `null` branch
twice in faker/MSW mocks:
faker.helpers.arrayElement([
faker.helpers.arrayElement([faker.string.alpha(), null]),
null,
])
The scalar getter (`getNullable`) and the object property layer each
detected the null union independently and each added a branch, pushing
`null` to ~75% instead of ~50%.
Let the scalar getter own the null branch: it now flags the returned
`MockDefinition` with `nullWrapped` when it has already wrapped the value,
and the object property layer skips its own wrap in that case. Boolean
(and number enum/const) stay bare in the scalar getter, so the object
layer still contributes their single null branch.
Closes#3484
0 commit comments