Closed helt closed 2 weeks ago
reuses test cases of prefixItems added in https://github.com/orval-labs/orval/issues/890
awesome I assigned this to you. Thanks for looking into it!
A similar issue was reported in kubb, but since kubb is deprecated, i was recommended to switch to orval. https://github.com/kubb-labs/kubb/issues/1018
Oh I didn't realize Kubb was depercated! Its one of the reasons @anymaniax moved this to an open source orval-labs from his personal project its too hard to maintain these kinds of projects by one person. So welcome aboard and we have other zod
labeled tickets open if you want to improve anything else in zod support as well!
Hey. I looked into the issue.
So far, it is half-way working. An issue I have currently is that min
and max
are added to my tuple
call. However, zod does not allow it to follow tuple()
calls. Any ideas how to get rid of it?.
More questions:
orval$ yarn run build && cd tests && yarn run generate && cd ..
really the quickest way to rerun the tests after changing the logic in pacakges/zod/index.ts
?consts
for? Are there edge cases I have to know about?Given a
const arrayWithPrefixItemsSchema: SchemaObject31 = {
type: "array",
prefixItems: [
{type: "string"},
{}
],
items:
{type: "number"},
}
According to openapi v3.1 spec, the goal of parsing prefixItems
is to generate something like:
z.tuple([z.string(), z.object()]).rest(z.number())
Awesome job @helt if you don't mind reviewing there are a few more open Zod issues that would be a huge help if you wanted to tackle them; https://github.com/orval-labs/orval/issues?q=is%3Aissue+is%3Aopen+label%3Azod
What are the steps to reproduce this issue?
What happens?
zod generator produces
zod.array()
, which is illegal syntax sinceerror TS2554: Expected 1-2 arguments, but got 0.
What were you expecting to happen?
Produce a typed tuple, similar to:
zod.tuple(zod.string(), zod.object())
Any logs, error output, etc?
Any other comments?
more issues pop up which are not my main concern, currently.
What versions are you using?