no-response-body
@azure-tools/typespec-azure-resource-manager/no-response-bodyCheck that 202, 204 and DELETE 200 responses have no body, and other success (2xx) responses have a body except for HEAD and POST 200.
ARM success response bodies must match their HTTP status and operation:
202and204responses must have no body.DELETEresponses with status200must also have no body.- Other success responses should have a body, except for
HEADoperations andPOSTresponses with status200, which may be bodyless.
Response headers are allowed on bodyless responses. Explicit @body and @bodyRoot payloads, as well as ordinary response properties that form an implicit payload, count as response bodies.
Use the standard ARM operation and response templates. Customizing their Response argument does not exempt an operation from these requirements.
Impact
Section titled “Impact”- Area: API, SDK
- Unexpected bodies on empty success responses make the API contract inconsistent and can lead clients to discard returned data.
- This rule is already enabled in the ARM ruleset. It also checks customized
DELETEresponses; remove a200or204payload rather than relying on the operation template’s default response.
DELETE responses
Section titled “DELETE responses”The synchronous delete template returns bodyless 200 and 204 responses by default. Keep those defaults instead of adding a payload.
❌ Incorrect
Section titled “❌ Incorrect”@armProviderNamespacenamespace Microsoft.Contoso;
model Widget is ProxyResource<{}> { ...ResourceNameParameter<Widget>;}
@armResourceOperationsinterface Widgets { delete is ArmResourceDeleteSync< Widget, Response = | (ArmDeletedResponse & { @body body: string; }) | ArmDeletedNoContentResponse >;}✅ Correct
Section titled “✅ Correct”@armProviderNamespacenamespace Microsoft.Contoso;
model Widget is ProxyResource<{}> { ...ResourceNameParameter<Widget>;}
@armResourceOperationsinterface Widgets { delete is ArmResourceDeleteSync<Widget>;}Each response is checked independently. A bodyless 200 response does not exempt a later 202 or 204 response from the empty-body requirement.
Suppression
Section titled “Suppression”Prefer correcting the response with standard templates. Suppression can be appropriate for an existing 202 response whose body must be retained for compatibility; do not suppress a body-bearing 204 response.
Place #suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "Existing 202 response body retained for compatibility." directly before the affected operation declaration, inside the interface when applicable.
LintDiff Equivalent
Section titled “LintDiff Equivalent”This rule covers the response-body policy of DeleteResponseBodyEmpty for DELETE responses with exact status 200 or 204. Standard delete defaults are compliant, but supported Response customizations can introduce a body and are checked as well.
The TypeSpec rule retains its warning severity and existing ARM enablement; the Swagger linter reports an error. It reports once per violating status on the authored operation, rather than once per response-schema occurrence. Its existing 202, non-DELETE 204, and other success-response checks are broader than this mapping.