@azure-tools/typespec-azure-resource-manager 0.74.0-dev.10 → 0.74.0-dev.11
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
CHANGED
|
@@ -69,7 +69,7 @@ Available ruleSets:
|
|
|
69
69
|
| [`@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. |
|
|
70
70
|
| [`@azure-tools/typespec-azure-resource-manager/list-operation-missing-pageable`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/list-operation-missing-pageable) | ARM GET operations on list paths must define TypeSpec paging metadata. |
|
|
71
71
|
| [`@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. |
|
|
72
|
-
| [`@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
|
|
72
|
+
| [`@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 202, 204 and DELETE 200 responses have no body, and other success (2xx) responses have a body except for HEAD and POST 200. |
|
|
73
73
|
| [`@azure-tools/typespec-azure-resource-manager/no-query-in-post`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-query-in-post) | ARM POST operations must not declare query parameters other than api-version. |
|
|
74
74
|
| [`@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/missing-operations-endpoint) | Check for missing Operations interface. |
|
|
75
75
|
| [`@azure-tools/typespec-azure-resource-manager/patch-envelope`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/patch-envelope) | Patch envelope properties should match the resource properties. |
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* verify that 202
|
|
2
|
+
* verify that 202, 204 and DELETE 200 responses do not contain a response body.
|
|
3
3
|
* verify that success (2XX) responses other than 202 and 204 contain a response body.
|
|
4
4
|
*/
|
|
5
5
|
export declare const noResponseBodyRule: import("@typespec/compiler").LinterRuleDefinition<"no-response-body", {
|
|
6
6
|
readonly default: "The body of responses with success (2xx) status codes other than 202 and 204 should not be empty.";
|
|
7
|
+
readonly shouldBeEmpty200: "The body of 200 response for DELETE should be empty.";
|
|
7
8
|
readonly shouldBeEmpty202: "The body of 202 response should be empty.";
|
|
8
9
|
readonly shouldBeEmpty204: "The body of 204 response should be empty.";
|
|
9
10
|
}, Record<string, never>>;
|
|
@@ -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;;;;;yBAyD7B,CAAC"}
|
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
import { createRule, fileRef, isTemplateInstance } from "@typespec/compiler";
|
|
2
|
-
import { getHttpOperation
|
|
2
|
+
import { getHttpOperation } from "@typespec/http";
|
|
3
3
|
import { isTemplatedInterfaceOperation } from "./utils.js";
|
|
4
4
|
/**
|
|
5
|
-
* verify that 202
|
|
5
|
+
* verify that 202, 204 and DELETE 200 responses do not contain a response body.
|
|
6
6
|
* verify that success (2XX) responses other than 202 and 204 contain a response body.
|
|
7
7
|
*/
|
|
8
8
|
export const noResponseBodyRule = createRule({
|
|
9
9
|
name: "no-response-body",
|
|
10
10
|
docs: fileRef.fromPackageRoot("src/rules/no-response-body.md"),
|
|
11
|
-
description: "Check that
|
|
11
|
+
description: "Check that 202, 204 and DELETE 200 responses have no body, and other success (2xx) responses have a body except for HEAD and POST 200.",
|
|
12
12
|
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-response-body",
|
|
13
13
|
severity: "warning",
|
|
14
14
|
messages: {
|
|
15
15
|
default: `The body of responses with success (2xx) status codes other than 202 and 204 should not be empty.`,
|
|
16
|
+
shouldBeEmpty200: `The body of 200 response for DELETE should be empty.`,
|
|
16
17
|
shouldBeEmpty202: `The body of 202 response should be empty.`,
|
|
17
18
|
shouldBeEmpty204: `The body of 204 response should be empty.`,
|
|
18
19
|
},
|
|
19
20
|
create(context) {
|
|
20
21
|
return {
|
|
21
22
|
operation: (op) => {
|
|
23
|
+
if (isTemplateInstance(op) || isTemplatedInterfaceOperation(op))
|
|
24
|
+
return;
|
|
22
25
|
const [httpOperation] = getHttpOperation(context.program, op);
|
|
23
|
-
if (
|
|
24
|
-
isTemplatedInterfaceOperation(op) ||
|
|
25
|
-
httpOperation.verb === "head")
|
|
26
|
+
if (httpOperation.verb === "head")
|
|
26
27
|
return;
|
|
27
|
-
const responses =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const responses = httpOperation.responses;
|
|
29
|
+
const response = responses.find((v) => v.statusCodes !== 204 && v.statusCodes !== 202);
|
|
30
|
+
if (response &&
|
|
31
|
+
!response.responses.every((v) => v.body) &&
|
|
32
|
+
!(["delete", "post"].includes(httpOperation.verb) && response.statusCodes === 200)) {
|
|
33
|
+
context.reportDiagnostic({
|
|
34
|
+
target: op,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (httpOperation.verb === "delete" && hasResponseBodyForCode(200, responses)) {
|
|
32
38
|
context.reportDiagnostic({
|
|
33
39
|
target: op,
|
|
40
|
+
messageId: "shouldBeEmpty200",
|
|
34
41
|
});
|
|
35
42
|
}
|
|
36
|
-
if (hasResponseBodyForCode(202,
|
|
43
|
+
if (hasResponseBodyForCode(202, responses)) {
|
|
37
44
|
context.reportDiagnostic({
|
|
38
45
|
target: op,
|
|
39
46
|
messageId: "shouldBeEmpty202",
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
|
-
if (hasResponseBodyForCode(204,
|
|
49
|
+
if (hasResponseBodyForCode(204, responses)) {
|
|
43
50
|
context.reportDiagnostic({
|
|
44
51
|
target: op,
|
|
45
52
|
messageId: "shouldBeEmpty204",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-response-body.js","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAkB,MAAM,oBAAoB,CAAC;AAC7F,OAAO,
|
|
1
|
+
{"version":3,"file":"no-response-body.js","sourceRoot":"","sources":["../../../src/rules/no-response-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAkB,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAA8B,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;IAC3C,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,+BAA+B,CAAC;IAC9D,WAAW,EACT,wIAAwI;IAC1I,GAAG,EAAE,qGAAqG;IAC1G,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,mGAAmG;QAC5G,gBAAgB,EAAE,sDAAsD;QACxE,gBAAgB,EAAE,2CAA2C;QAC7D,gBAAgB,EAAE,2CAA2C;KAC9D;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,SAAS,EAAE,CAAC,EAAa,EAAE,EAAE;gBAC3B,IAAI,kBAA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AS,CAAC,EAAE,CAAC;oBAC3C,OAAO,CAAC,gBAAgB,CAAC;wBACvB,MAAM,EAAE,EAAE;wBACV,SAAS,EAAE,kBAAkB;qBAC9B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,sBAAsB,CAAC,UAAkB,EAAE,UAAmC;IACrF,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,UAAU,CAAC,CAAC;IACtE,OAAO,CAAC,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,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.74.0-dev.
|
|
3
|
+
"version": "0.74.0-dev.11",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec Azure Resource Manager library",
|
|
6
6
|
"homepage": "https://azure.github.io/typespec-azure",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"pluralize": "^8.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@azure-tools/typespec-azure-core": "^0.73.0 || >= 0.74.0-dev.
|
|
51
|
-
"@typespec/compiler": "^1.17.0",
|
|
50
|
+
"@azure-tools/typespec-azure-core": "^0.73.0 || >= 0.74.0-dev.5",
|
|
52
51
|
"@typespec/rest": "^0.87.0",
|
|
53
52
|
"@typespec/openapi": "^1.17.0",
|
|
54
53
|
"@typespec/versioning": "^0.87.0",
|
|
55
|
-
"@typespec/http": "^1.17.0"
|
|
54
|
+
"@typespec/http": "^1.17.0",
|
|
55
|
+
"@typespec/compiler": "^1.17.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@azure-tools/typespec-azure-core": "^0.73.0 || >= 0.74.0-dev.
|
|
58
|
+
"@azure-tools/typespec-azure-core": "^0.73.0 || >= 0.74.0-dev.5",
|
|
59
59
|
"@types/node": "^26.6.4",
|
|
60
60
|
"@types/pluralize": "^0.0.33",
|
|
61
61
|
"@vitest/coverage-v8": "^5.0.5",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"vitest": "^5.0.5",
|
|
66
66
|
"@typespec/compiler": "^1.17.0",
|
|
67
67
|
"@typespec/http": "^1.17.0",
|
|
68
|
-
"@typespec/library-linter": "^0.87.0",
|
|
69
68
|
"@typespec/rest": "^0.87.0",
|
|
69
|
+
"@typespec/library-linter": "^0.87.0",
|
|
70
70
|
"@typespec/tspd": "^0.77.1",
|
|
71
71
|
"@typespec/versioning": "^0.87.0",
|
|
72
72
|
"@typespec/openapi": "^1.17.0"
|