Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chronus/changes/add-op-feature-2026-0-22-18-38-39.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Fix #3829 Allow `@feature` to apply to Operations
7 changes: 7 additions & 0 deletions .chronus/changes/add-op-feature-2026-0-22-18-39-10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-autorest"
---

Add Test for operation feature
7 changes: 7 additions & 0 deletions packages/typespec-autorest/test/arm/arm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ enum Features {
@Azure.ResourceManager.Legacy.feature(Features.FeatureB)
@armResourceOperations
interface Bars extends Azure.ResourceManager.TrackedResourceOperations<BarResource, BarResourceProperties> {}
@@Azure.ResourceManager.Legacy.feature(Bars.get, Features.FeatureA);
`,
["featureA", "featureB", "shared"],
{ preset: "azure" },
Expand All @@ -656,6 +657,12 @@ enum Features {
expect(aFile.definitions["FooResourceUpdate"]).toBeDefined();
expect(aFile.definitions["FooResourceUpdateProperties"]).toBeDefined();

expect(
aFile.paths[
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/barResources/{barResourceName}"
].get,
).toBeDefined();

expect(bFile.definitions).toBeDefined();
expect(bFile.definitions["BarResource"]).toBeDefined();
expect(bFile.definitions["BarResource"].properties["properties"].$ref).toBe(
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-azure-resource-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ Decorator to associate a feature with a model, interface, or namespace
##### Target

The target to associate the feature with
`Model | Interface | Namespace`
`Model | Operation | Interface | Namespace`

##### Parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export type FeatureOptionsDecorator = (
*/
export type FeatureDecorator = (
context: DecoratorContext,
target: Model | Interface | Namespace,
target: Model | Operation | Interface | Namespace,
featureName: EnumMember,
) => DecoratorValidatorCallbacks | void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ extern dec featureOptions(target: EnumMember, options: valueof ArmFeatureOptions
* @param target The target to associate the feature with
* @param featureName The feature to associate with the target
*/
extern dec feature(target: Model | Interface | Namespace, featureName: EnumMember);
extern dec feature(target: Model | Operation | Interface | Namespace, featureName: EnumMember);
6 changes: 4 additions & 2 deletions packages/typespec-azure-resource-manager/src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ export function resolveResourceBaseType(type?: string | undefined): ResourceBase
}

export const [getResourceFeature, setResourceFeature] = useStateMap<
Model | Interface | Namespace,
Model | Operation | Interface | Namespace,
EnumMember
>(ArmStateKeys.armFeature);

Expand Down Expand Up @@ -1363,6 +1363,8 @@ export function getFeature(program: Program, entity: Type): ArmFeatureOptions {
return getFeatureOptions(program, feature);
}
case "Operation": {
const opFeature = getResourceFeature(program, entity);
if (opFeature !== undefined) return getFeatureOptions(program, opFeature);
const opInterface = entity.interface;
if (opInterface !== undefined) {
return getFeature(program, opInterface);
Expand Down Expand Up @@ -1400,7 +1402,7 @@ export function getFeature(program: Program, entity: Type): ArmFeatureOptions {

export const $feature: FeatureDecorator = (
context: DecoratorContext,
entity: Model | Interface | Namespace,
entity: Model | Operation | Interface | Namespace,
featureName: EnumMember,
) => {
const { program } = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ Decorator to associate a feature with a model, interface, or namespace
#### Target

The target to associate the feature with
`Model | Interface | Namespace`
`Model | Operation | Interface | Namespace`

#### Parameters

Expand Down
Loading