ad-on-is/adonis-autoswagger

Add computed value in annotations

sikelio opened this issue ยท 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

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

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

image

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