openapi-zod-client icon indicating copy to clipboard operation
openapi-zod-client copied to clipboard

fix arrays of union types

Open clifton opened this issue 1 year ago • 1 comments

fixes #287

the following object

    const openApiDoc: OpenAPIObject = {
        openapi: "3.0.0",
        info: {
            version: "1.0.0",
            title: "Union array",
        },
        paths: {},
        components: {
            schemas: {
                Foo: {
                    type: "object",
                    properties: {
                        foo: { type: "integer", enum: [1, 2] },
                    },
                },
                Bar: {
                    type: "object",
                    properties: {
                        bar: { type: "string", enum: ["a", "b"] },
                    },
                },
                Union: {
                    type: "object",
                    properties: {
                        unionArray: {
                            items: {
                                anyOf: [{ $ref: "#/components/schemas/Foo" }, { $ref: "#/components/schemas/Bar" }],
                            },
                            type: "array",
                        },
                    },
                },
            },
        },
    };
expected:
unionArray: Array<Foo | Bar>;
received 
unionArray: Array<(Foo | Bar) | Array<Foo | Bar>>;

clifton avatar Nov 21 '24 02:11 clifton

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
openapi-zod-client-rim4 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 6:40pm

vercel[bot] avatar Nov 21 '24 02:11 vercel[bot]