adonis-autoswagger icon indicating copy to clipboard operation
adonis-autoswagger copied to clipboard

Add computed value in annotations

Open sikelio opened this issue 1 year ago • 3 comments

Hi ! Amazing addon lib !

I would like to know if it's possible to add the possibility of getting @computed()? In my case i have the following:

/**
 * @all
 * @summary Returns a list of all users
 * @responseBody <200> - <User[]> - List of users
 */
async all({ response }: HttpContext) {}

My model User has some computed values like:

@computed()
get followingCount(): number {
  return this.followings ? this.followings.length : 0;
}

@computed()
get followerCount(): number {
  return this.followers ? this.followers.length : 0;
}

@computed()
get likesReceived(): number {
  return this._likesReceived === null ? 0 : this._likesReceived;
}

But they didn't appear :'(

image

sikelio avatar Sep 02 '24 18:09 sikelio

Hum, seems like a regression as it used to work in the past.

MuaDDuB avatar Sep 06 '24 16:09 MuaDDuB

Ok, my bad, just put a public before your get and it will be parsed.

image

MuaDDuB avatar Sep 06 '24 19:09 MuaDDuB

I think I could add an additional clause checking for "get ", since it's always public

ad-on-is avatar Sep 06 '24 19:09 ad-on-is