@Get('/tasks', { response: { type: 'json', status: 200 } }) puts the shape of the answer where the
rest of the endpoint is already described, instead of on the method. request and response are the
two halves of the same sentence, which is why it carries that name.
Every field is optional, and the defaults are the obvious ones: JSON, and 200 (or 302 for a
redirect, 204 for no content). A method decorator such as @JsonHttpResponse(201) still wins,
because it produces the response itself and the more specific statement should.
What a route declares about its answer.
@Get('/tasks', { response: { type: 'json', status: 200 } })puts the shape of the answer where the rest of the endpoint is already described, instead of on the method.requestandresponseare the two halves of the same sentence, which is why it carries that name.Every field is optional, and the defaults are the obvious ones: JSON, and
200(or302for a redirect,204for no content). A method decorator such as@JsonHttpResponse(201)still wins, because it produces the response itself and the more specific statement should.