Remove requirement of input and output types
Would you entertain something like this? We have a pretty large tRPC backend that is inferring output types right now, and some of the openapi inputs require no input so this change seems nicer then having to provide z.void() in those situations. Seeing that tRPC doesn't require an input I don't think the openapi add on should either.
Merging something like this would allow a user to skip the input and output completely if their endpoint took no input and they did not want to type the output for openapi. Understanding they would lose doc support and zod protection of their outputs.
We are doing this here rather then providing z.any() in our output as we want to keep the inferred types for the tRPC api, when we open this up for a basic REST api though we are not as concerned with forcing our outputs to be a specific format.
Hmm, I don't think this behavior by default makes sense. Maybe we could add it behind an UNSAFE_ flag.
export const openApiDocument = generateOpenApiDocument(appRouter, {
title: 'tRPC OpenAPI',
version: '1.0.0',
baseUrl: 'http://localhost:3000',
UNSAFE_ignoreInvalidParsers: true, /* 👈 */
});
@jlalmes That makes sense, though this may simply not be needed at all. I realized I can set my procedure output to z.any() and trpc will keep the inferred type from my method for all my internal use. Maybe it is best for folks that don't want to type openapi outputs that they need to manually do this.