Skip to content

Commit 364b924

Browse files
tadeleshtadeleshCopilot
authored
Improve documentation for ARM library decorators, interfaces, and models (#4494)
## Summary Adds clear documentation to decorators, template interfaces, and models in the ARM library that were missing docs or had unclear/incorrect documentation. ### Changes **lib/decorators.tsp** - Fixed typo in @armLibraryNamespace - Added descriptions to @armResourceAction, @armResourceCreateOrUpdate, @armResourceRead, @armResourceUpdate, @armResourceDelete, @armResourceList - Expanded @armResourceCollectionAction description - Fixed @armProviderNameValue wrong description - Removed ghost @param tags from @armProviderNamespace and @armVirtualResource - Fixed @resourceBaseType param name to match implementation **lib/interfaces.tsp** - Fixed misleading doc on ResourceDeleteWithoutOkAsync **lib/models.tsp** - Improved docs for ResourceListCustomResult **lib/legacy-types/** - Fixed empty @doc --------- Co-authored-by: tadelesh <chenjieshi@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent aac448e commit 364b924

24 files changed

Lines changed: 529 additions & 136 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: internal
3+
packages:
4+
- "@azure-tools/typespec-azure-resource-manager"
5+
---
6+
7+
Update documentation.

packages/samples/common-types/openapi/v3/types.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
},
222222
"KeyVaultProperties": {
223223
"type": "object",
224+
"description": "Properties of a KeyVault",
224225
"properties": {
225226
"keyIdentifier": {
226227
"type": "string",

packages/samples/common-types/openapi/v4/types.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
},
224224
"KeyVaultProperties": {
225225
"type": "object",
226+
"description": "Properties of a KeyVault",
226227
"properties": {
227228
"keyIdentifier": {
228229
"type": "string",

packages/samples/common-types/openapi/v5/types.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
},
224224
"KeyVaultProperties": {
225225
"type": "object",
226+
"description": "Properties of a KeyVault",
226227
"properties": {
227228
"keyIdentifier": {
228229
"type": "string",

packages/samples/common-types/openapi/v6/types.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
},
202202
"KeyVaultProperties": {
203203
"type": "object",
204+
"description": "Properties of a KeyVault",
204205
"properties": {
205206
"keyIdentifier": {
206207
"type": "string",

packages/typespec-azure-resource-manager/README.md

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ the version of the Azure Resource Manager common-types to use for refs in emitte
117117

118118
#### `@armLibraryNamespace`
119119

120-
`@armLibraryNamespace` designates a namespace as containign Azure Resource Manager Provider information.
120+
`@armLibraryNamespace` designates a namespace as containing Azure Resource Manager Provider information.
121+
This is used for library namespaces that define reusable ARM resource types that can be shared
122+
across multiple provider specifications.
121123

122124
```typespec
123125
@Azure.ResourceManager.armLibraryNamespace
@@ -171,8 +173,9 @@ namespace Microsoft.ContosoService;
171173

172174
#### `@armProviderNameValue`
173175

174-
`@armResourceType` sets the value fo the decorated string
175-
property to the type of the Azure Resource Manager resource.
176+
`@armProviderNameValue` sets the provider namespace value on operations.
177+
It is used internally to inject the correct provider namespace path segment
178+
for resource operations in auto-generated routes.
176179

177180
```typespec
178181
@Azure.ResourceManager.armProviderNameValue
@@ -188,6 +191,11 @@ None
188191

189192
#### `@armResourceAction`
190193

194+
Marks the operation as a custom action on a specific Azure Resource Manager resource type.
195+
This decorator associates a POST action operation with its resource,
196+
identifying the semantics of the operation as a resource action over a specific resource for documentation,
197+
resource validation, and use by downstream emitters.
198+
191199
```typespec
192200
@Azure.ResourceManager.armResourceAction(resourceModel: Model, resourceName?: valueof string)
193201
```
@@ -224,7 +232,9 @@ Marks the operation as being a check existence (HEAD) operation
224232

225233
#### `@armResourceCollectionAction`
226234

227-
Marks the operation as being a collection action
235+
Marks the operation as being a collection action that is not associated with a specific resource instance.
236+
Collection actions are operations that act on a resource collection rather than a single resource,
237+
such as `checkNameAvailability` or provider-level actions.
228238

229239
```typespec
230240
@Azure.ResourceManager.armResourceCollectionAction
@@ -240,6 +250,10 @@ None
240250

241251
#### `@armResourceCreateOrUpdate`
242252

253+
Marks the operation as a create or update (PUT) operation for a specific Azure Resource Manager resource type.
254+
This decorator identifies the semantics of the operation as a CreateOrReplace lifecycle operation over a particular resource,
255+
for use in documentation, resource validation, and downstream emitters.
256+
243257
```typespec
244258
@Azure.ResourceManager.armResourceCreateOrUpdate(resourceModel: Model, resourceName?: valueof string)
245259
```
@@ -257,6 +271,10 @@ None
257271

258272
#### `@armResourceDelete`
259273

274+
Marks the operation as a delete (DELETE) operation for a specific Azure Resource Manager resource type.
275+
This decorator identifies the operation as a Delete lifecycle operation over the resource for us in documentation,
276+
resource validation, and downstream emitters.
277+
260278
```typespec
261279
@Azure.ResourceManager.armResourceDelete(resourceModel: Model, resourceName?: valueof string)
262280
```
@@ -274,6 +292,10 @@ None
274292

275293
#### `@armResourceList`
276294

295+
Marks the operation as a list (GET collection) operation for a specific Azure Resource Manager resource type.
296+
This decorator identifies the semantics of the operation as a collection list operation over a resource type and a particular scope for documentation,
297+
resource validation, and downstream emitters.
298+
277299
```typespec
278300
@Azure.ResourceManager.armResourceList(resourceModel: Model, resourceName?: valueof string)
279301
```
@@ -325,6 +347,10 @@ individually tagged
325347

326348
#### `@armResourceRead`
327349

350+
Marks the operation as a read (GET) operation for a specific Azure Resource Manager resource type.
351+
This decorator identifies the semantics of the operation as a Read lifecycle operation over a particular resource,
352+
for use in documentation, resource validation, and downstream emitters.
353+
328354
```typespec
329355
@Azure.ResourceManager.armResourceRead(resourceModel: Model, resourceName?: valueof string)
330356
```
@@ -342,6 +368,10 @@ individually tagged
342368

343369
#### `@armResourceUpdate`
344370

371+
Marks the operation as an update (PATCH) operation for a specific Azure Resource Manager resource type.
372+
This decorator identifies the operation as an Update lifecycle operation over the resource for use in documentation,
373+
resource validation, and downstream emitters.
374+
345375
```typespec
346376
@Azure.ResourceManager.armResourceUpdate(resourceModel: Model, resourceName?: valueof string)
347377
```
@@ -360,7 +390,8 @@ individually tagged
360390
#### `@armVirtualResource`
361391

362392
This decorator is used on Azure Resource Manager resources that are not based on
363-
Azure.ResourceManager common types.
393+
Azure.ResourceManager common types. It marks a model as an ARM virtual resource,
394+
which is useful for defining the scope of resources used only as parents for child resources, or scopes for extension resources.
364395

365396
```typespec
366397
@Azure.ResourceManager.armVirtualResource(provider?: valueof string)
@@ -450,10 +481,11 @@ None
450481

451482
#### `@resourceBaseType`
452483

453-
This decorator sets the base type of the given resource.
484+
This decorator sets the base type of the given resource, indicating where in the
485+
Azure Resource Manager hierarchy the resource is located.
454486

455487
```typespec
456-
@Azure.ResourceManager.resourceBaseType(baseTypeIt: "Tenant" | "Subscription" | "ResourceGroup" | "Location" | "Extension")
488+
@Azure.ResourceManager.resourceBaseType(baseType: "Tenant" | "Subscription" | "ResourceGroup" | "Location" | "Extension")
457489
```
458490

459491
##### Target
@@ -462,9 +494,9 @@ This decorator sets the base type of the given resource.
462494

463495
##### Parameters
464496

465-
| Name | Type | Description |
466-
| ---------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
467-
| baseTypeIt | `"Tenant" \| "Subscription" \| "ResourceGroup" \| "Location" \| "Extension"` | The built-in parent of the resource, this can be "Tenant", "Subscription", "ResourceGroup", "Location", or "Extension" |
497+
| Name | Type | Description |
498+
| -------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
499+
| baseType | `"Tenant" \| "Subscription" \| "ResourceGroup" \| "Location" \| "Extension"` | The built-in parent of the resource, this can be "Tenant", "Subscription", "ResourceGroup", "Location", or "Extension" |
468500

469501
#### `@resourceGroupResource`
470502

packages/typespec-azure-resource-manager/generated-defs/Azure.ResourceManager.ts

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ export interface ResourceOperationOptions {
1818
}
1919

2020
/**
21-
* Marks the operation as being a collection action
21+
* Marks the operation as being a collection action that is not associated with a specific resource instance.
22+
* Collection actions are operations that act on a resource collection rather than a single resource,
23+
* such as `checkNameAvailability` or provider-level actions.
2224
*/
2325
export type ArmResourceCollectionActionDecorator = (
2426
context: DecoratorContext,
2527
target: Operation,
2628
) => DecoratorValidatorCallbacks | void;
2729

2830
/**
29-
* `@armResourceType` sets the value fo the decorated string
30-
* property to the type of the Azure Resource Manager resource.
31-
*
32-
* @param resource The resource to get the type of
31+
* `@armProviderNameValue` sets the provider namespace value on operations.
32+
* It is used internally to inject the correct provider namespace path segment
33+
* for resource operations in auto-generated routes.
3334
*/
3435
export type ArmProviderNameValueDecorator = (
3536
context: DecoratorContext,
@@ -70,7 +71,6 @@ export type IdentifiersDecorator = (
7071
* namespace Microsoft.ContosoService;
7172
* ```
7273
* @param providerNamespace Provider namespace
73-
* @param libraryNamespaces a library namespace containing types for this namespace
7474
*/
7575
export type ArmProviderNamespaceDecorator = (
7676
context: DecoratorContext,
@@ -91,7 +91,9 @@ export type UseLibraryNamespaceDecorator = (
9191
) => DecoratorValidatorCallbacks | void;
9292

9393
/**
94-
* `@armLibraryNamespace` designates a namespace as containign Azure Resource Manager Provider information.
94+
* `@armLibraryNamespace` designates a namespace as containing Azure Resource Manager Provider information.
95+
* This is used for library namespaces that define reusable ARM resource types that can be shared
96+
* across multiple provider specifications.
9597
*
9698
* @example
9799
* ```typespec
@@ -189,8 +191,10 @@ export type ExtensionResourceDecorator = (
189191
) => DecoratorValidatorCallbacks | void;
190192

191193
/**
192-
*
193-
*
194+
* Marks the operation as a custom action on a specific Azure Resource Manager resource type.
195+
* This decorator associates a POST action operation with its resource,
196+
* identifying the semantics of the operation as a resource action over a specific resource for documentation,
197+
* resource validation, and use by downstream emitters.
194198
*
195199
* @param resourceModel Resource model
196200
* @param resourceName Optional. The name of the resource. If not provided, the name of the resource model will be used.
@@ -203,8 +207,9 @@ export type ArmResourceActionDecorator = (
203207
) => DecoratorValidatorCallbacks | void;
204208

205209
/**
206-
*
207-
*
210+
* Marks the operation as a create or update (PUT) operation for a specific Azure Resource Manager resource type.
211+
* This decorator identifies the semantics of the operation as a CreateOrReplace lifecycle operation over a particular resource,
212+
* for use in documentation, resource validation, and downstream emitters.
208213
*
209214
* @param resourceModel Resource model
210215
* @param resourceName Optional. The name of the resource. If not provided, the name of the resource model will be used.
@@ -217,8 +222,9 @@ export type ArmResourceCreateOrUpdateDecorator = (
217222
) => DecoratorValidatorCallbacks | void;
218223

219224
/**
220-
*
221-
*
225+
* Marks the operation as a read (GET) operation for a specific Azure Resource Manager resource type.
226+
* This decorator identifies the semantics of the operation as a Read lifecycle operation over a particular resource,
227+
* for use in documentation, resource validation, and downstream emitters.
222228
*
223229
* @param resourceModel Resource model
224230
* @param resourceName Optional. The name of the resource. If not provided, the name of the resource model will be used.
@@ -231,8 +237,9 @@ export type ArmResourceReadDecorator = (
231237
) => DecoratorValidatorCallbacks | void;
232238

233239
/**
234-
*
235-
*
240+
* Marks the operation as an update (PATCH) operation for a specific Azure Resource Manager resource type.
241+
* This decorator identifies the operation as an Update lifecycle operation over the resource for use in documentation,
242+
* resource validation, and downstream emitters.
236243
*
237244
* @param resourceModel Resource model
238245
* @param resourceName Optional. The name of the resource. If not provided, the name of the resource model will be used.
@@ -245,8 +252,9 @@ export type ArmResourceUpdateDecorator = (
245252
) => DecoratorValidatorCallbacks | void;
246253

247254
/**
248-
*
249-
*
255+
* Marks the operation as a delete (DELETE) operation for a specific Azure Resource Manager resource type.
256+
* This decorator identifies the operation as a Delete lifecycle operation over the resource for us in documentation,
257+
* resource validation, and downstream emitters.
250258
*
251259
* @param resourceModel Resource model
252260
* @param resourceName Optional. The name of the resource. If not provided, the name of the resource model will be used.
@@ -259,8 +267,9 @@ export type ArmResourceDeleteDecorator = (
259267
) => DecoratorValidatorCallbacks | void;
260268

261269
/**
262-
*
263-
*
270+
* Marks the operation as a list (GET collection) operation for a specific Azure Resource Manager resource type.
271+
* This decorator identifies the semantics of the operation as a collection list operation over a resource type and a particular scope for documentation,
272+
* resource validation, and downstream emitters.
264273
*
265274
* @param resourceModel Resource model
266275
* @param resourceName Optional. The name of the resource. If not provided, the name of the resource model will be used.
@@ -326,9 +335,9 @@ export type ArmCommonTypesVersionDecorator = (
326335

327336
/**
328337
* This decorator is used on Azure Resource Manager resources that are not based on
329-
* Azure.ResourceManager common types.
338+
* Azure.ResourceManager common types. It marks a model as an ARM virtual resource,
339+
* which is useful for defining the scope of resources used only as parents for child resources, or scopes for extension resources.
330340
*
331-
* @param propertiesType : The type of the resource properties.
332341
* @param provider Optional. The resource provider namespace for the virtual resource.
333342
*/
334343
export type ArmVirtualResourceDecorator = (
@@ -338,14 +347,15 @@ export type ArmVirtualResourceDecorator = (
338347
) => DecoratorValidatorCallbacks | void;
339348

340349
/**
341-
* This decorator sets the base type of the given resource.
350+
* This decorator sets the base type of the given resource, indicating where in the
351+
* Azure Resource Manager hierarchy the resource is located.
342352
*
343-
* @param baseTypeIt The built-in parent of the resource, this can be "Tenant", "Subscription", "ResourceGroup", "Location", or "Extension"
353+
* @param baseType The built-in parent of the resource, this can be "Tenant", "Subscription", "ResourceGroup", "Location", or "Extension"
344354
*/
345355
export type ResourceBaseTypeDecorator = (
346356
context: DecoratorContext,
347357
target: Model,
348-
baseTypeIt: Type,
358+
baseType: Type,
349359
) => DecoratorValidatorCallbacks | void;
350360

351361
export type AzureResourceManagerDecorators = {

packages/typespec-azure-resource-manager/lib/common-types/nsp-operations.tsp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ interface NspConfigurationOperations<
9292
ResourceParameter extends {} = NspConfigurationNameParameter<NspConfigurationKeyName>
9393
> {
9494
/**
95-
* @dev List the network security perimeter configurations to a resource
95+
* List the network security perimeter configurations to a resource
9696
* @template ParentResource the parent resource of the NspConfiguration
9797
* @template Resource Optional. The NspConfiguration resource being listed
9898
* @template BaseParameters Optional. Allows overriding the operation parameters
@@ -127,7 +127,7 @@ interface NspConfigurationOperations<
127127
>;
128128

129129
/**
130-
* @dev List the network security parameter configuration for a resource without pagination - this should only be used for legacy operations
130+
* List the network security parameter configuration for a resource without pagination - this should only be used for legacy operations
131131
* @template ParentResource the parent resource of the NspConfiguration
132132
* @template Resource Optional. The NspConfiguration resource being listed
133133
* @template BaseParameters Optional. Allows overriding the operation parameters
@@ -162,7 +162,7 @@ interface NspConfigurationOperations<
162162
>;
163163

164164
/**
165-
* @dev GET a network security perimeter configuration for a particular resource
165+
* GET a network security perimeter configuration for a particular resource
166166
* @template ParentResource the parent resource of the NspConfiguration
167167
* @template Resource the NspConfiguration resource being read
168168
* @template BaseParameters Optional. Allows overriding the operation parameters
@@ -196,7 +196,7 @@ interface NspConfigurationOperations<
196196
>;
197197

198198
/**
199-
* @dev Perform an action on a network security perimeter configuration for a particular resource
199+
* Perform an action on a network security perimeter configuration for a particular resource
200200
* @template ParentResource the parent resource of the NspConfiguration
201201
* @template Request The request body type
202202
* @template Response The success response for the read operation
@@ -238,7 +238,7 @@ interface NspConfigurationOperations<
238238
): Response | Error;
239239

240240
/**
241-
* @dev Perform an action on a network security perimeter configuration for a particular resource
241+
* Perform an action on a network security perimeter configuration for a particular resource
242242
* @template ParentResource the parent resource of the NspConfiguration
243243
* @template Request The request body type
244244
* @template Response The success response for the read operation

packages/typespec-azure-resource-manager/lib/common-types/types.tsp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ union createdByType {
344344
string,
345345
}
346346

347-
/** @dev Resource Identity Type */
348-
@doc("")
347+
/** Resource Identity Type */
349348
union ResourceIdentityType {
350349
SystemAssigned: "SystemAssigned",
351350
}
@@ -369,7 +368,7 @@ model Identity {
369368
type?: ResourceIdentityType;
370369
}
371370

372-
/** @dev Properties of a KeyVault */
371+
/** Properties of a KeyVault */
373372
model KeyVaultProperties {
374373
/** Key vault uri to access the encryption key. */
375374
keyIdentifier?: string;

0 commit comments

Comments
 (0)