Metadata is extremely useful for documenting procedures. However so far as I can tell, it isn't possible to add metadata to a router. This makes it impossible to document tRPC routers as well as is possible with a standard rest API, as there is no way to add the equivalent of a description to a tag object.
Something like this:
const petRouter = t.meta({ description: "router description" }).router({
get: t.procedure.meta({ description: "procedure description" }).query(() => {
return "my pet";
})
});
Would help improve packages like https://github.com/dtinth/openapi-trpc or (selfishly) https://github.com/aidansunbury/trpc-ui
A hacky workaround I have been messing around with is to just add an empty procedure to the router, which just has to be parsed by whatever tool is being used to generate documentation.
const petRouter = t.router({
meta: t.procedure.meta({ description: "This procedure's metadata could be elevated to the route level" }).query(() => null),
get: t.procedure.meta({ description: "procedure description" }).query(() => {
return fakeData.user;
})
});
No response
Especially if it is something more people than just myself would use!
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too