arm-resource-patch
@azure-tools/typespec-azure-resource-manager/arm-resource-patchValidate ARM PATCH operations. The request body of a PATCH must be a model with a subset of the resource properties. The PATCH body must not contain properties that do not exist on the resource. In addition, the rule validates that:
- All properties in the PATCH request body are optional (PATCH supports partial updates) or read-only (not included in requests).
- No PATCH request body property has a default value (a property absent from a PATCH request leaves the existing value unchanged; defaults are not applied).
- Every PATCH request body property maps back to a resource property that is updateable or readOnly.
- The
content-typeheader (when explicitly specified) isapplication/merge-patch+json(or the implicitapplication/json).
โ Incorrect
Section titled โโ Incorrectโmodel FooResource is TrackedResource<FooProperties> { ...ResourceNameParameter<FooResource>;}
model MyBadPatch { name?: string; ...Foundations.ArmTagsProperty; blah?: string; // does not exist on FooResource required: string; // not optional withDefault?: string = "x"; // has a default value}โ Correct
Section titled โโ Correctโmodel FooResource is TrackedResource<FooProperties> { ...ResourceNameParameter<FooResource>;}
model FooPatch { name?: string; ...Foundations.ArmTagsProperty; properties?: FooProperties;}