@azure-tools/typespec-azure-resource-manager 0.49.0-dev.2 → 0.49.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/rules/no-empty-model.js +2 -2
- package/dist/src/rules/no-empty-model.js.map +1 -1
- package/dist/src/rules/no-response-body.d.ts +5 -2
- package/dist/src/rules/no-response-body.d.ts.map +1 -1
- package/dist/src/rules/no-response-body.js +30 -7
- package/dist/src/rules/no-response-body.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Available ruleSets:
|
|
|
51
51
|
| `@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation` | Tenant and Extension resources should not define a list by subscription operation. |
|
|
52
52
|
| [`@azure-tools/typespec-azure-resource-manager/lro-location-header`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/lro-location-header) | A 202 response should include a Location response header. |
|
|
53
53
|
| [`@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/missing-x-ms-identifiers) | Array properties should describe their identifying properties with x-ms-identifiers. Decorate the property with @OpenAPI.extension("x-ms-identifiers", [id-prop]) where "id-prop" is a list of the names of identifying properties in the item type. |
|
|
54
|
-
| `@azure-tools/typespec-azure-resource-manager/no-response-body`
|
|
54
|
+
| [`@azure-tools/typespec-azure-resource-manager/no-response-body`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-response-body) | Check that the body is empty for 202 and 204 responses, and not empty for other success (2xx) responses. |
|
|
55
55
|
| `@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint` | Check for missing Operations interface. |
|
|
56
56
|
| `@azure-tools/typespec-azure-resource-manager/patch-envelope` | Patch envelope properties should match the resource properties. |
|
|
57
57
|
| `@azure-tools/typespec-azure-resource-manager/arm-resource-patch` | Validate ARM PATCH operations. |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRule } from "@typespec/compiler";
|
|
1
|
+
import { createRule, isRecordModelType } from "@typespec/compiler";
|
|
2
2
|
export const noEmptyModel = createRule({
|
|
3
3
|
name: "no-empty-model",
|
|
4
4
|
severity: "warning",
|
|
@@ -11,7 +11,7 @@ export const noEmptyModel = createRule({
|
|
|
11
11
|
create(context) {
|
|
12
12
|
return {
|
|
13
13
|
model: (model) => {
|
|
14
|
-
if (model.properties.size === 0) {
|
|
14
|
+
if (model.properties.size === 0 && !isRecordModelType(context.program, model)) {
|
|
15
15
|
context.reportDiagnostic({
|
|
16
16
|
code: "no-empty-model",
|
|
17
17
|
target: model,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-empty-model.js","sourceRoot":"","sources":["../../../src/rules/no-empty-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAS,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"no-empty-model.js","sourceRoot":"","sources":["../../../src/rules/no-empty-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAS,MAAM,oBAAoB,CAAC;AAE1E,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;IACrC,IAAI,EAAE,gBAAgB;IACtB,QAAQ,EAAE,SAAS;IACnB,WAAW,EACT,+KAA+K;IACjL,GAAG,EAAE,mGAAmG;IACxG,QAAQ,EAAE;QACR,OAAO,EAAE,wEAAwE;QACjF,OAAO,EACL,qKAAqK;KACxK;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,KAAK,EAAE,CAAC,KAAY,EAAE,EAAE;gBACtB,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;oBAC9E,OAAO,CAAC,gBAAgB,CAAC;wBACvB,IAAI,EAAE,gBAAgB;wBACtB,MAAM,EAAE,KAAK;qBACd,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* verify
|
|
2
|
+
* verify that 202 or 204 responses do not contain a response body.
|
|
3
|
+
* verify that success (2XX) responses other than 202 and 204 contain a response body.
|
|
3
4
|
*/
|
|
4
5
|
export declare const noResponseBodyRule: import("@typespec/compiler").LinterRuleDefinition<"no-response-body", {
|
|
5
|
-
readonly default: "The body of 202
|
|
6
|
+
readonly default: "The body of responses with success (2xx) status codes other than 202 and 204 should not be empty.";
|
|
7
|
+
readonly shouldBeEmpty202: "The body of 202 response should be empty.";
|
|
8
|
+
readonly shouldBeEmpty204: "The body of 204 response should be empty.";
|
|
6
9
|
}>;
|
|
7
10
|
//# sourceMappingURL=no-response-body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-response-body.d.ts","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-response-body.d.ts","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;EA+C7B,CAAC"}
|
|
@@ -1,30 +1,53 @@
|
|
|
1
1
|
import { createRule } from "@typespec/compiler";
|
|
2
|
-
import { getResponsesForOperation } from "@typespec/http";
|
|
2
|
+
import { getHttpOperation, getResponsesForOperation } from "@typespec/http";
|
|
3
3
|
import { isTemplatedInterfaceOperation } from "./utils.js";
|
|
4
4
|
/**
|
|
5
|
-
* verify
|
|
5
|
+
* verify that 202 or 204 responses do not contain a response body.
|
|
6
|
+
* verify that success (2XX) responses other than 202 and 204 contain a response body.
|
|
6
7
|
*/
|
|
7
8
|
export const noResponseBodyRule = createRule({
|
|
8
9
|
name: "no-response-body",
|
|
10
|
+
description: "Check that the body is empty for 202 and 204 responses, and not empty for other success (2xx) responses.",
|
|
11
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-response-body",
|
|
9
12
|
severity: "warning",
|
|
10
|
-
description: `The body of 202 response should be empty.`,
|
|
11
13
|
messages: {
|
|
12
|
-
default: `The body of 202
|
|
14
|
+
default: `The body of responses with success (2xx) status codes other than 202 and 204 should not be empty.`,
|
|
15
|
+
shouldBeEmpty202: `The body of 202 response should be empty.`,
|
|
16
|
+
shouldBeEmpty204: `The body of 204 response should be empty.`,
|
|
13
17
|
},
|
|
14
18
|
create(context) {
|
|
15
19
|
return {
|
|
16
20
|
operation: (op) => {
|
|
17
|
-
|
|
21
|
+
const [httpOperation] = getHttpOperation(context.program, op);
|
|
22
|
+
if (isTemplatedInterfaceOperation(op) || httpOperation.verb === "head")
|
|
18
23
|
return;
|
|
24
|
+
const responses = getResponsesForOperation(context.program, op)[0].find((v) => v.statusCodes !== 204 && v.statusCodes !== 202);
|
|
25
|
+
if (responses && !responses.responses.every((v) => v.body)) {
|
|
26
|
+
if (["delete", "post"].includes(httpOperation.verb) && responses.statusCodes === 200) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
context.reportDiagnostic({
|
|
30
|
+
target: op,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (hasResponseBodyForCode(202, getResponsesForOperation(context.program, op)[0])) {
|
|
34
|
+
context.reportDiagnostic({
|
|
35
|
+
target: op,
|
|
36
|
+
messageId: "shouldBeEmpty202",
|
|
37
|
+
});
|
|
19
38
|
}
|
|
20
|
-
|
|
21
|
-
if (responses && responses.responses.some((v) => v.body)) {
|
|
39
|
+
if (hasResponseBodyForCode(204, getResponsesForOperation(context.program, op)[0])) {
|
|
22
40
|
context.reportDiagnostic({
|
|
23
41
|
target: op,
|
|
42
|
+
messageId: "shouldBeEmpty204",
|
|
24
43
|
});
|
|
25
44
|
}
|
|
26
45
|
},
|
|
27
46
|
};
|
|
28
47
|
},
|
|
29
48
|
});
|
|
49
|
+
function hasResponseBodyForCode(statusCode, operations) {
|
|
50
|
+
const response = operations.find((v) => v.statusCodes === statusCode);
|
|
51
|
+
return !!(response && response.responses.some((v) => v.body));
|
|
52
|
+
}
|
|
30
53
|
//# sourceMappingURL=no-response-body.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-response-body.js","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"no-response-body.js","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAyB,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;IAC3C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,0GAA0G;IAC5G,GAAG,EAAE,qGAAqG;IAC1G,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,mGAAmG;QAC5G,gBAAgB,EAAE,2CAA2C;QAC7D,gBAAgB,EAAE,2CAA2C;KAC9D;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,SAAS,EAAE,CAAC,EAAa,EAAE,EAAE;gBAC3B,MAAM,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBAC9D,IAAI,6BAA6B,CAAC,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,MAAM;oBAAE,OAAO;gBAE/E,MAAM,SAAS,GAAG,wBAAwB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CACrE,CAAC,CAAC,EAAE,E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C,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-azure-resource-manager",
|
|
3
|
-
"version": "0.49.0-dev.
|
|
3
|
+
"version": "0.49.0-dev.4",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec Azure Resource Manager library",
|
|
6
6
|
"homepage": "https://azure.github.io/typespec-azure",
|