in your script where you generate your specs you can now pass a object of the
schemas you want to be defined as components/schemas
in the output doc
import { generateOpenApiDocument } from "trpc-openapi";
import { z } from "zod";
const SomeSchema = z.object({
a: z.literal(69),
});
generateOpenApiDocument(appRouter, {
// ...
defs: {
SomeSchema,
},
});
which will be included in the response object definition like
{
"$ref": "#/components/schemas/SomeSchema"
}
and in the actual schemas list like
{
"components": {
"schemas": {
"SomeSchema": "..."
}
}
}