no-response-body
@azure-tools/typespec-azure-core/no-response-bodyEnsure that the body is set correctly for response types. Non-204 responses should have a body, and 204 responses should not have a body.
โ Incorrect
Section titled โโ IncorrectโNon-204 response without a body:
@route("/api/widgets/{name}")op readWidget(name: string): { @statusCode statusCode: 200;};Error response without a body:
@errormodel Error { @statusCode statusCode: 400;}
@route("/api/widgets/{name}")op readWidget(name: string): Error;204 response with a body:
@route("/api/widgets/{name}")op deleteWidget(name: string): { @statusCode statusCode: 204; @body body: Widget;};โ Correct
Section titled โโ CorrectโNon-204 response with a body:
@route("/api/widgets/{name}")op readWidget(name: string): { @statusCode statusCode: 200; @body body: Widget;};204 response without a body:
@route("/api/widgets/{name}")op deleteWidget(name: string): { @statusCode statusCode: 204;};