Skip to content

no-empty-model

-
@azure-tools/typespec-azure-resource-manager/no-response-body

ARM operation responses with status code 202 or 204 should not contain a response body. Operation responses with other success (2xx) status codes should contain a response body.

For 202 and 204 status codes (response body should be empty)

❌ Incorrect

op walk(): ArmNoContentResponse & {
@body body: string;
};
{
"responses": {
"204": {
"description": "There is no content to send for this request, but the headers may be useful. ",
"schema": {
"type": "string"
}
}
}
}

✅ Correct

op walk(): ArmAcceptedResponse;
{
"responses": {
"202": {
"description": "The request has been accepted for processing, but processing has not yet completed."
}
}
}

For other success (2xx) response status codes (response body should not be empty)

❌ Incorrect

op walk(): CreatedResponse;
{
"responses": {
"201": {
"description": "The request has succeeded and a new resource has been created as a result."
}
}
}

✅ Correct

op walk(): ArmCreatedResponse<{
name: string;
}>;
{
"responses": {
"201": {
"description": "Azure create operation completed successfully.",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": ["name"]
}
}
}
}