tsoa icon indicating copy to clipboard operation
tsoa copied to clipboard

@ExampleRequestBody to to used like @Example for response

Open WORMSS opened this issue 3 years ago • 5 comments

Sorting

  • I'm submitting a ...

    • [ ] bug report
    • [x] feature request
    • [ ] support request
  • I confirm that I

    • [x] used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

@ExampleRquestBody<MyEndpointRequestBody>({
  "type": "a",
  "aProp": false
})
@ExampleRquestBody<MyEndpointRequestBody>({
  "type": "b",
  "bProp": true
})
@ExampleRquestBody<MyEndpointRequestBody>({
  "type": "c",
  "cProp": false
})
@Post('my-endpoint')
public async myEndpint(
  @Body() body: MyEndpointRequestBody,
  @Request() request: Request,
).... blar blar blar

Current Behavior

not possible to add example requests, only on response. which isn't helpful here.

Possible Solution

see expected

Steps to Reproduce

n/a

Context (Environment)

n/a

Detailed Description

@ExampleRequestBody to to used like @Example for response

Breaking change?

n/a

#180 requests this, and then after much confusion, it was closed, and asked to make a new issue, and as far as I can tell, it was never created.. so I have added it now..

WORMSS avatar Oct 08 '21 14:10 WORMSS

The combination of @param and @example jsdoc tags already covers this use case, yes? As described in this comment on #180

mrattner avatar Feb 23 '22 20:02 mrattner

Nope, not even close.

WORMSS avatar Feb 23 '22 21:02 WORMSS

for me it seems to work, if the example is written all in the same line e.g. @example body { "features": [ { "geometry": { "coordinates": [ [ [ 0 ] ] ], "type": "Polygon" }, "properties": { "value": 0 }, "type": "Feature" } ], "type": "FeatureCollection" } works,

@example body {
"features": [
{
"geometry":
{
"coordinates":
[ 
[ 
[ 
0
]
]
], 
"type": "Polygon"
}, 
"properties": { 
"value": 0 
}, 
"type": "Feature" 
} 
], 
"type": "FeatureCollection" 
}

does not

sjerratsch avatar Oct 13 '22 15:10 sjerratsch

@WORMSS I think you should remove the two empty checkboxes. These seem to generate that progress indicator which says that two of four tasks have been finished. This suggests that this issue is actively being worked on while it is not, judging from the activity in this thread.

slavistan avatar Dec 16 '22 11:12 slavistan

@slavistan once you have changed the text in .github/ folder, I would be happy too.

WORMSS avatar Dec 16 '22 15:12 WORMSS