Closed roninjin10 closed 1 year ago
This seems to be an issue with zod-to-ts. It seems like it is only rendering descriptions on ZodObject
fields (https://github.com/sachinraja/zod-to-ts/blob/main/src/index.ts#L142-#L144).
@MatsDK looked into it and the issue is not zod-to-ts. We are expected to be passing in the description here
The description comes from a util method that merges inputs (TIL trpc can define and merge more than 1 input object) . The description never gets copied over. I put up a pr adding it here: https://github.com/sachinraja/trpc-playground/pull/38
Update: Actually my theory doesn't make sense because I only use 1 input so that should be getting copied over
I have time to continue to debug later this week
I created the printTypeForDocs
function to solve this problem. After testing, it seems like it is working. The createTypeAlias
is adding the description of the input above the the type declaration.
This change is not published yet (commit).
I don't know how we should handle multiple inputParser. What if there are multiple descriptions? Maybe something like #38 is necessary in that case.
ah yea good point about many. The code I wrote only the last one is available. The cleanest way to do it might be to hackily concat them together so make it look like
/ description 1 / propertyOnOne: string anotherPropertyOnOne: number / description 2 / propertyOnTwo: Date anotherPropertyOnTwo: boolean
Another option would be to make them a zod.union and see what zod prints
published in v1.0.3
, please open another issue if you want this for multiple input parsers
If I describe an input like this:
The address description shows up in the docs but not the object description. (see metadata endpoint)![image](https://user-images.githubusercontent.com/35039927/209195897-ca9e1973-7aae-445d-9333-9e7b1bfe0b86.png)