typescript-rest-swagger
typescript-rest-swagger copied to clipboard
How can I describe request body?
Hello.
How can I achieve the following:
requestBody:
description: Optional description in *Markdown*
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
(https://swagger.io/docs/specification/describing-request-body/)
I've seen @BodyOptions but not sure if it's the right way.
Any suggestions? Thank you.
Any updated about this question?
Just pass it to your parameters of your function
type Cat = {
breed: string;
age: number;
}
@Example<object>({
message: "ok",
})
@POST
@Tags("Cat API")
@Path("/add")
@Response<{ message: string }>(200, "Success adding cat")
@Consumes("application/json")
@Accept("application/json")
public mainFilters(body: Cat): object {
return {
message: "ok",
};
}