no-unsafe-patch-body-properties
@azure-tools/typespec-azure-resource-manager/no-unsafe-patch-body-propertiesARM PATCH body properties must not be required, have defaults, or be create-only.
ARM PATCH request body properties must be safe for partial updates. A property emitted in an ARM PATCH body must not be required, must not define a default value, and must not be create-only.
Impact
Section titled “Impact”- Area: API
PATCH describes partial updates. Required PATCH body properties, default-valued properties, and create-only properties can make partial updates ambiguous for service authors and SDKs, and can produce ARM OpenAPI that violates PATCH request-body guidance.
The rule checks the effective emitted PATCH payload. Properties omitted from the PATCH payload, such as never properties or create-only properties removed by the PATCH visibility transform, are not reported. A top-level emitted property named identity is skipped to match ARM PATCH identity envelope behavior.
❌ Incorrect
Section titled “❌ Incorrect”@armProviderNamespacenamespace Microsoft.Contoso;
model WidgetPatchBody { displayName: string; enabled?: boolean = false;
@visibility(Lifecycle.Create) createdBy?: string;}
@route("/widgets/{name}")@patchop update(@path name: string, @body body: WidgetPatchBody): void;✅ Correct
Section titled “✅ Correct”@armProviderNamespacenamespace Microsoft.Contoso;
model WidgetPatchBody { displayName?: string; enabled?: boolean;}
@route("/widgets/{name}")@patchop update(@path name: string, @body body: WidgetPatchBody): void;LintDiff Equivalent
Section titled “LintDiff Equivalent”This rule corresponds to the LintDiff rule PatchBodyParametersSchema.
Suppression
Section titled “Suppression”Do not suppress this rule for ordinary ARM resource PATCH operations. Fix the PATCH model so updateable properties are optional, do not carry defaults, and exclude create-only properties from the emitted PATCH payload.