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
Describe the bug
We are attempting to modify the behavior of openapi-zod-client in pull request 258, with the expectation of correctly handling schemas within the allOf array that only contain the required field.
The goal is to generate the correct type annotations for required fields and the corresponding Zod schema, like https://editor.swagger.io/ does(It can even automatically eliminate properties that cannot be resolved or located, show in the pic: abc).
However, after testing, it has been observed that the current code is not yet able to fully address this issue.
and more of that, pull request 258 didn't take types generating into account. which should be supplemented.
Minimal reproduction
A simplified schema definition to reproduce this is like:
@C-ra-ZY Thanks for finding the flaw in handling the .passthrough() for empty objects, but I don't this the proposed fix is a valid solution as it should not remove any required fields from the user spec.
allOf takes an array of object definitions that are validated independently but together compose a single object.
The visual doc in https://editor.swagger.io/ has a misleading feature that it tries to merge allOf objects as I mentioned in issue 257 and it actually fails to display required but unknown property(that seems just a bug)
A better fix might be to have an ad hoc case handling of required only objects by removing the z.object({}) part and generating z.object({ name: z.unknown() }) directly?
Describe the bug

We are attempting to modify the behavior of openapi-zod-client in pull request 258, with the expectation of correctly handling schemas within the allOf array that only contain the required field.
The goal is to generate the correct type annotations for required fields and the corresponding Zod schema, like https://editor.swagger.io/ does(It can even automatically eliminate properties that cannot be resolved or located, show in the pic: abc).
However, after testing, it has been observed that the current code is not yet able to fully address this issue.

and more of that, pull request 258 didn't take types generating into account. which should be supplemented.
Minimal reproduction
A simplified schema definition to reproduce this is like:
The generated client code:
but the code will trigger an error:


and the schema fail to require correctly property(even when delete the unnecessary .passthrough()):
Expected behavior
we can generate types and schemas correctly like https://editor.swagger.io/.
Additional context
guys can easily check issue reproduction at https://github.com/C-ra-ZY/openapi-zod-client/tree/test-on-first-fix
run
and see the generated test.client.ts
The text was updated successfully, but these errors were encountered: