Skip to content

Missing Zod array introspection when generating OpenAPI spec. #102

@HamishWHC

Description

@HamishWHC

Simple example:

export const example = base.prefix("/example").router({
	example: base
		.route({ path: "/" })
		.output(
			z.object({
				body: z.object({
					items: z.array(z.string()),
				}),
			}),
		)
		.handler(() => {
			return {
				body: { items: [] },
			};
		}),
});

The above example generates the following OpenAPI schema for its output:

"application/json": {
    "schema": {
        "type": "object",
        "properties": { "items": { "type": "array" } },
        "required": ["items"]
    }
}

This is missing information about the elements of the array and seems to be a bug.

Thanks for your work on this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions