Skip to content

Commit 86ee60d

Browse files
authored
Fix severity of the PatchSkuProperty and PatchIdentityProperty rules to warning (Azure#580)
* Change severity of PatchSkuProperty and PatchIdentityProperty to warning * Generate change log
1 parent e88f022 commit 86ee60d

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft.azure/openapi-validator-rulesets",
5+
"comment": "Change severity of PatchSkuProperty and PatchIdentityProperty to warning",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft.azure/openapi-validator-rulesets"
10+
}

docs/patch-identity-property.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Category
44

5-
ARM Error
5+
ARM Warning
66

77
## Applies to
88

@@ -14,11 +14,11 @@ ARM OpenAPI(swagger) specs
1414

1515
## Output Message
1616

17-
The patch operation body parameter schema should contains property 'identity'.
17+
The patch operation body parameter schema should contain property 'identity' if the service allows it to be updated.
1818

1919
## Description
2020

21-
RP must implement PATCH for the 'identity' envelope property if it's defined in the resource model.
21+
RP should consider implementing Patch for the 'identity' envelope property if it's defined in the resource model. You may ignore this violation if your service does not allow updation of the identity property once it is set. In such a case the property must be marked with x-ms-mutability [create, read]
2222

2323
## CreatedAt
2424

docs/patch-sku-property.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Category
44

5-
ARM Error
5+
ARM Warning
66

77
## Applies to
88

@@ -14,11 +14,11 @@ ARM OpenAPI(swagger) specs
1414

1515
## Output Message
1616

17-
The patch operation body parameter schema should contain property 'sku'.
17+
The patch operation body parameter schema should contain property 'sku' if the service supports updation of the property.
1818

1919
## Description
2020

21-
RP must implement PATCH for the 'SKU' envelope property if it's defined in the resource model.
21+
RP should consider implementing Patch for the 'SKU' envelope property if it's defined in the resource model. You may ignore this violation if your service does not allow updation of the Sku property once it is set. In such a case the property must be marked with x-ms-mutability [create, read]
2222

2323
## CreatedAt
2424

docs/rules.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ Please refer to [patch-content-type.md](./patch-content-type.md) for details.
757757

758758
### PatchIdentityProperty
759759

760-
RP must implement PATCH for the 'identity' envelope property if it's defined in the resource model.
760+
RP should consider implementing Patch for the 'identity' envelope property if it's defined in the resource model. You may ignore this violation if your service does not allow updation of the identity property once it is set. In such a case the property must be marked with x-ms-mutability [create, read]
761761

762762
Please refer to [patch-identity-property.md](./patch-identity-property.md) for details.
763763

@@ -781,7 +781,7 @@ Please refer to [patch-response-codes.md](./patch-response-codes.md) for details
781781

782782
### PatchSkuProperty
783783

784-
RP must implement PATCH for the 'SKU' envelope property if it's defined in the resource model.
784+
RP should consider implementing Patch for the 'SKU' envelope property if it's defined in the resource model. You may ignore this violation if your service does not allow updation of the Sku property once it is set. In such a case the property must be marked with x-ms-mutability [create, read]
785785

786786
Please refer to [patch-sku-property.md](./patch-sku-property.md) for details.
787787

packages/rulesets/generated/spectral/az-arm.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,7 @@ const validatePatchBodyParamProperties = createRulesetFunction({
26212621
if (bodyParameter) {
26222622
const index = patchOp.parameters.findIndex((p) => p.in === "body");
26232623
if (_opts.should) {
2624-
const responseSchema = ((_d = (_c = patchOp.responses) === null || _c === void 0 ? void 0 : _c["200"]) === null || _d === void 0 ? void 0 : _d.schema) || ((_f = (_e = patchOp.responses) === null || _e === void 0 ? void 0 : _e["201"]) === null || _f === void 0 ? void 0 : _f.schema) || getGetOperationSchema(path.slice(0, -1), ctx);
2624+
const responseSchema = ((_d = (_c = patchOp.responses) === null || _c === void 0 ? void 0 : _c["200"]) === null || _d === void 0 ? void 0 : _d.schema) || ((_f = (_e = patchOp.responses) === null || _e === void 0 ? void 0 : _e["202"]) === null || _f === void 0 ? void 0 : _f.schema) || getGetOperationSchema(path.slice(0, -1), ctx);
26252625
_opts.should.forEach((p) => {
26262626
var _a, _b;
26272627
if (!((_a = getProperties(bodyParameter)) === null || _a === void 0 ? void 0 : _a[p]) && ((_b = getProperties(responseSchema)) === null || _b === void 0 ? void 0 : _b[p])) {
@@ -2951,9 +2951,9 @@ const ruleset = {
29512951
},
29522952
},
29532953
PatchSkuProperty: {
2954-
description: "RP must implement PATCH for the 'SKU' envelope property if it's defined in the resource model.",
2954+
description: "RP should consider implementing Patch for the 'SKU' envelope property if it's defined in the resource model and the service supports its updation.",
29552955
message: "{{error}}",
2956-
severity: "error",
2956+
severity: "warn",
29572957
resolved: true,
29582958
formats: [oas2],
29592959
given: ["$[paths,'x-ms-paths'].*.patch"],

packages/rulesets/src/spectral/az-arm.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,10 @@ const ruleset: any = {
400400
},
401401
// RPC Code: RPC-Patch-V1-09
402402
PatchSkuProperty: {
403-
description: "RP must implement PATCH for the 'SKU' envelope property if it's defined in the resource model.",
403+
description:
404+
"RP should consider implementing Patch for the 'SKU' envelope property if it's defined in the resource model and the service supports its updation.",
404405
message: "{{error}}",
405-
severity: "error",
406+
severity: "warn",
406407
resolved: true,
407408
formats: [oas2],
408409
given: ["$[paths,'x-ms-paths'].*.patch"],

packages/rulesets/src/spectral/functions/validate-patch-body-param-properties.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const validatePatchBodyParamProperties = createRulesetFunction<unknown, O
4242
const index = patchOp.parameters.findIndex((p: any) => p.in === "body")
4343
if (_opts.should) {
4444
const responseSchema =
45-
patchOp.responses?.["200"]?.schema || patchOp.responses?.["201"]?.schema || getGetOperationSchema(path.slice(0, -1), ctx)
45+
patchOp.responses?.["200"]?.schema || patchOp.responses?.["202"]?.schema || getGetOperationSchema(path.slice(0, -1), ctx)
4646
_opts.should.forEach((p: string) => {
4747
if (!getProperties(bodyParameter)?.[p] && getProperties(responseSchema)?.[p]) {
4848
errors.push({

0 commit comments

Comments
 (0)