Skip to content

fix arrays of union types#315

Open
clifton wants to merge 5 commits into
astahmer:mainfrom
clifton:ck/fix-union-types
Open

fix arrays of union types#315
clifton wants to merge 5 commits into
astahmer:mainfrom
clifton:ck/fix-union-types

Conversation

@clifton

@clifton clifton commented Nov 21, 2024

Copy link
Copy Markdown

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>>;

@vercel

vercel Bot commented Nov 21, 2024

Copy link
Copy Markdown

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

@AjayNathan

Copy link
Copy Markdown

@astahmer Any chance we could get this PR merged? We were using a custom deployed version on Vercel (https://gitpkg.vercel.app/clifton/openapi-zod-client/lib?union-arrays) that is no longer working due to payment issues. In the interim, we can publish a custom version to npm and use that, but in the long-term, we'd rather use the main package. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generating a array union when using anyOf

2 participants