@azure-tools/typespec-azure-resource-manager 0.49.0-dev.3 → 0.49.0-dev.5
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-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/lib/common-types/customer-managed-keys.tsp +1 -6
- package/lib/common-types/network-security-perimeter.tsp +3 -3
- package/lib/common-types/private-links.tsp +3 -8
- package/lib/common-types/types.tsp +14 -4
- 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,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,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,GAAG,IAAI,CAAC,CAA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CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -37,11 +37,7 @@ model KeyEncryptionKeyIdentity {
|
|
|
37
37
|
identityType?: KeyEncryptionKeyIdentityType;
|
|
38
38
|
|
|
39
39
|
/** User assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity. */
|
|
40
|
-
userAssignedIdentityResourceId?: Azure.Core.armResourceIdentifier
|
|
41
|
-
{
|
|
42
|
-
type: "Microsoft.ManagedIdentity/userAssignedIdentities";
|
|
43
|
-
}
|
|
44
|
-
]>;
|
|
40
|
+
userAssignedIdentityResourceId?: Azure.Core.armResourceIdentifier;
|
|
45
41
|
|
|
46
42
|
/** application client identity to use for accessing key encryption key Url in a different tenant. Ex: f83c6b1b-4d34-47e4-bb34-9d83df58b540 */
|
|
47
43
|
@added(Versions.v5)
|
|
@@ -70,6 +66,5 @@ model Encryption {
|
|
|
70
66
|
|
|
71
67
|
/** All Customer-managed key encryption properties for the resource. */
|
|
72
68
|
@added(Versions.v4)
|
|
73
|
-
@removed(Versions.v5)
|
|
74
69
|
customerManagedKeyEncryption?: CustomerManagedKeyEncryption;
|
|
75
70
|
}
|
|
@@ -245,12 +245,12 @@ model NetworkSecurityPerimeterConfigurationListResult {
|
|
|
245
245
|
* @template Segment The resource type name for network security perimeter configuration (default is networkSecurityPerimeterConfigurations)
|
|
246
246
|
*/
|
|
247
247
|
@added(Versions.v5)
|
|
248
|
-
model NetworkSecurityPerimeterConfigurationNameParameter
|
|
248
|
+
model NetworkSecurityPerimeterConfigurationNameParameter {
|
|
249
249
|
/** The name for a network security perimeter configuration */
|
|
250
250
|
@path
|
|
251
251
|
@minLength(1)
|
|
252
252
|
@maxLength(512)
|
|
253
|
-
@TypeSpec.Rest.segment(
|
|
253
|
+
@TypeSpec.Rest.segment("networkSecurityPerimeterConfigurations")
|
|
254
254
|
@key("networkSecurityPerimeterConfigurationName")
|
|
255
|
-
|
|
255
|
+
networkSecurityPerimeterConfigurationName: string;
|
|
256
256
|
}
|
|
@@ -11,11 +11,7 @@ model PrivateEndpoint {
|
|
|
11
11
|
/** The resource identifier for private endpoint */
|
|
12
12
|
@visibility("read")
|
|
13
13
|
@typeChangedFrom(CommonTypes.Versions.v4, string)
|
|
14
|
-
id?: Azure.Core.armResourceIdentifier
|
|
15
|
-
{
|
|
16
|
-
type: "Microsoft.Network/privateEndpoints";
|
|
17
|
-
}
|
|
18
|
-
]>;
|
|
14
|
+
id?: Azure.Core.armResourceIdentifier;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
/** A private link resource. */
|
|
@@ -131,13 +127,12 @@ union PrivateEndpointServiceConnectionStatus {
|
|
|
131
127
|
|
|
132
128
|
/**
|
|
133
129
|
* The name of the private endpoint connection associated with the Azure resource.
|
|
134
|
-
* @template Segment The resource type name for private endpoint connections (default is privateEndpointConnections)
|
|
135
130
|
*/
|
|
136
|
-
model PrivateEndpointConnectionParameter
|
|
131
|
+
model PrivateEndpointConnectionParameter {
|
|
137
132
|
/** The name of the private endpoint connection associated with the Azure resource. */
|
|
138
133
|
@path
|
|
139
|
-
@TypeSpec.Rest.segment(Segment)
|
|
140
134
|
@key("privateEndpointConnectionName")
|
|
135
|
+
@TypeSpec.Rest.segment("privateEndpointConnections")
|
|
141
136
|
name: string;
|
|
142
137
|
}
|
|
143
138
|
|
|
@@ -73,6 +73,7 @@ model ResourceModelWithAllowedPropertySet extends TrackedResource {
|
|
|
73
73
|
/** The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention.
|
|
74
74
|
* Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19),
|
|
75
75
|
* If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. */
|
|
76
|
+
@visibility("read")
|
|
76
77
|
eTag?: string;
|
|
77
78
|
|
|
78
79
|
@typeChangedFrom(Versions.v6, Identity)
|
|
@@ -142,7 +143,6 @@ model Operation {
|
|
|
142
143
|
isDataAction?: boolean;
|
|
143
144
|
|
|
144
145
|
/** Localized display information for this particular operation. */
|
|
145
|
-
@visibility("read")
|
|
146
146
|
display?: OperationDisplay;
|
|
147
147
|
|
|
148
148
|
/**
|
|
@@ -154,6 +154,7 @@ model Operation {
|
|
|
154
154
|
/**
|
|
155
155
|
Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.
|
|
156
156
|
*/
|
|
157
|
+
@visibility("read")
|
|
157
158
|
actionType?: ActionType;
|
|
158
159
|
}
|
|
159
160
|
|
|
@@ -189,7 +190,8 @@ model OperationDisplay {
|
|
|
189
190
|
*/
|
|
190
191
|
model OperationStatusResult {
|
|
191
192
|
/** Fully qualified ID for the async operation. */
|
|
192
|
-
|
|
193
|
+
@typeChangedFrom(Versions.v5, string)
|
|
194
|
+
id?: armResourceIdentifier;
|
|
193
195
|
|
|
194
196
|
/** Name of the async operation. */
|
|
195
197
|
name?: string;
|
|
@@ -213,6 +215,12 @@ model OperationStatusResult {
|
|
|
213
215
|
|
|
214
216
|
/** If present, details of the operation error. */
|
|
215
217
|
error?: ErrorDetail;
|
|
218
|
+
|
|
219
|
+
/** Fully qualified ID of the resource against which the original async operation was started. */
|
|
220
|
+
@visibility("read")
|
|
221
|
+
@format("arm-id")
|
|
222
|
+
@added(Versions.v5)
|
|
223
|
+
resourceId?: string;
|
|
216
224
|
}
|
|
217
225
|
|
|
218
226
|
/**
|
|
@@ -549,7 +557,7 @@ model ScopeParameter {
|
|
|
549
557
|
}
|
|
550
558
|
|
|
551
559
|
/**
|
|
552
|
-
* The default
|
|
560
|
+
* The default TenantIdParameter type.
|
|
553
561
|
*/
|
|
554
562
|
@added(Versions.v4)
|
|
555
563
|
model TenantIdParameter {
|
|
@@ -563,6 +571,7 @@ model TenantIdParameter {
|
|
|
563
571
|
* The default ARM If-Match header type.
|
|
564
572
|
*/
|
|
565
573
|
@added(Versions.v4)
|
|
574
|
+
@friendlyName("If-Match")
|
|
566
575
|
model IfMatchHeader {
|
|
567
576
|
/** The If-Match header that makes a request conditional. */
|
|
568
577
|
@header("If-Match")
|
|
@@ -570,9 +579,10 @@ model IfMatchHeader {
|
|
|
570
579
|
}
|
|
571
580
|
|
|
572
581
|
/**
|
|
573
|
-
* The default ARM If-Match header type.
|
|
582
|
+
* The default ARM If-None-Match header type.
|
|
574
583
|
*/
|
|
575
584
|
@added(Versions.v4)
|
|
585
|
+
@friendlyName("If-None-Match")
|
|
576
586
|
model IfNoneMatchHeader {
|
|
577
587
|
/** The If-None-Match header that makes a request conditional. */
|
|
578
588
|
@header("If-None-Match")
|
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.5",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec Azure Resource Manager library",
|
|
6
6
|
"homepage": "https://azure.github.io/typespec-azure",
|