express-jsdoc-swagger icon indicating copy to clipboard operation
express-jsdoc-swagger copied to clipboard

Adding Typescript Schema types into the comments

Open RadientBrain opened this issue 2 years ago • 3 comments

How to add a predefined type objects already defined in a Typescript file to render it for the POST body request via the comments? Similar feature is present in "gin-swagger" but that is for golang, I thought that kind of feature should also be added here. Any ideas on it? @kevinccbsg @wbw20 @ciprian1234 @meabed

Like below is the comment I want to write which should generate the type defined (here Activity is a Schema type object):

/**
* POST /activity/add
* @param {Activity} request.body.required - Activity type
**/

or just an additional line like this in the existing defined comments: @schema Activity activity_description

The Activity type is defined as follows:

export type Activity = {
    wakeup: string;
    goto: string;
    runfor: number;
}

So, at last it should generate the whole Activity Schema without me defining each and every detail of the type again into the comments.

RadientBrain avatar Mar 16 '23 17:03 RadientBrain

Has anyone figured out a way to work around this? I have types from a shared folder that aren't in a *.d.ts file. I was really hoping to just do as @RadientBrain suggested.

* @param {Activity} request.body.required - Activity type

baronnoraz avatar Jan 18 '24 16:01 baronnoraz

我也想要这个功能,但目测只能自己实现了

tvsj avatar Mar 06 '24 17:03 tvsj

这是一个很好的主动性!如果在实现这个功能时你需要任何帮助或遇到任何问题,随时向我们提问。我们在这里帮助你!

RadientBrain avatar Mar 06 '24 17:03 RadientBrain