Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
changeKind: breaking
packages:
- "@azure-tools/typespec-autorest"
---

- Remove deprecated `arm-resource-flattening` option

```diff lang=yaml title=tspconfig.yaml
options:
@azure-tools/typespec-autorest:
- arm-resource-flattening: true
```

```diff lang=tsp title=MyResource.tsp
+@@Azure.ClientGenerator.Core.Legacy.flattenProperty(MyResource.properties, "autorest");
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
changeKind: breaking
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

- Remove Private decorator `@Azure.ResourceManager.Private.conditionalClientFlatten`

```diff lang=tsp
@Azure.ResourceManager.Private.conditionalClientFlatten
```

```diff lang=tsp title=MyResource.tsp
[email protected]
```
6 changes: 0 additions & 6 deletions packages/typespec-autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,6 @@ Create read-only property schema for lro status

Determine whether and how to emit x-ms-long-running-operation-options for lro resolution

### `arm-resource-flattening`

**Type:** `boolean`

Back-compat flag. If true, continue to emit `x-ms-client-flatten` in for some of the ARM resource properties.

### `emit-common-types-schema`

**Type:** `"never" | "for-visibility-changes"`
Expand Down
10 changes: 0 additions & 10 deletions packages/typespec-autorest/src/emit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ export function resolveAutorestOptions(
NoTarget,
);
}
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (resolvedOptions["arm-resource-flattening"]) {
reportDeprecated(
program,
`arm-resource-flattening option is deprecated and will be removed in future versions. Instead use \`@@Azure.ClientGenerator.Core.Legacy.flattenProperty(<ResourceName>.properties, "autorest");\``,
NoTarget,
);
}

return {
outputFile: resolvedOptions["output-file"],
Expand All @@ -119,8 +111,6 @@ export function resolveAutorestOptions(
armTypesDir,
useReadOnlyStatusSchema: resolvedOptions["use-read-only-status-schema"],
emitLroOptions: resolvedOptions["emit-lro-options"],
// eslint-disable-next-line @typescript-eslint/no-deprecated
armResourceFlattening: resolvedOptions["arm-resource-flattening"],
emitCommonTypesSchema: resolvedOptions["emit-common-types-schema"],
xmlStrategy: resolvedOptions["xml-strategy"],
};
Expand Down
13 changes: 0 additions & 13 deletions packages/typespec-autorest/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ export interface AutorestEmitterOptions {
*/
"emit-lro-options"?: "none" | "final-state-only" | "all";

/**
* Back-compat flag. If true, continue to emit `x-ms-client-flatten` in for some of the
* ARM resource properties.
* @deprecated
*/
"arm-resource-flattening"?: boolean;
/**
* Determines whether and how to emit schemas for common-types
* @default "for-visibility-changes"
Expand Down Expand Up @@ -229,13 +223,6 @@ const EmitterOptionsSchema: JSONSchemaType<AutorestEmitterOptions> = {
description:
"Determine whether and how to emit x-ms-long-running-operation-options for lro resolution",
},
"arm-resource-flattening": {
type: "boolean",
nullable: true,
default: false,
description:
"Back-compat flag. If true, continue to emit `x-ms-client-flatten` in for some of the ARM resource properties.",
},
"emit-common-types-schema": {
type: "string",
enum: ["never", "for-visibility-changes"],
Expand Down
12 changes: 1 addition & 11 deletions packages/typespec-autorest/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
isArmExternalType,
isArmProviderNamespace,
isAzureResource,
isConditionallyFlattened,
} from "@azure-tools/typespec-azure-resource-manager";
import {
getClientNameOverride,
Expand Down Expand Up @@ -223,11 +222,6 @@ export interface AutorestDocumentEmitterOptions {
*/
readonly emitLroOptions?: "none" | "final-state-only" | "all";

/**
* readOnly property ARM resource flattening
*/
readonly armResourceFlattening?: boolean;

/**
* Determines whether and how to emit schema for arm common-types
* @default "for-visibility-only"
Expand Down Expand Up @@ -2150,11 +2144,7 @@ export async function getOpenAPIForService(
attachPropertyXml(prop, propSchema);
}

if (options.armResourceFlattening && isConditionallyFlattened(program, prop)) {
return { ...applyIntrinsicDecorators(prop, propSchema), "x-ms-client-flatten": true };
} else {
return applyIntrinsicDecorators(prop, propSchema);
}
return applyIntrinsicDecorators(prop, propSchema);
}

function attachExtensions(type: Type, emitObject: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ export type ResourceBaseParametersOfDecorator = (
propertyName: Model,
) => void;

/**
* Please DO NOT USE in RestAPI specs.
* Internal decorator that deprecated direct usage of `x-ms-client-flatten` OpenAPI extension.
* It will programatically enabled/disable client flattening with
*
* @flattenProperty with autorest
* emitter flags to maintain compatibility in swagger.
*/
export type ConditionalClientFlattenDecorator = (
context: DecoratorContext,
target: ModelProperty,
) => void;

/**
* Omit a property in the target model.
*
Expand Down Expand Up @@ -317,7 +304,6 @@ export type LegacyExtensionResourceOperationDecorator = (
export type AzureResourceManagerPrivateDecorators = {
resourceParameterBaseFor: ResourceParameterBaseForDecorator;
resourceBaseParametersOf: ResourceBaseParametersOfDecorator;
conditionalClientFlatten: ConditionalClientFlattenDecorator;
omitIfEmpty: OmitIfEmptyDecorator;
assignProviderNameValue: AssignProviderNameValueDecorator;
azureResourceBase: AzureResourceBaseDecorator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ using Azure.ResourceManager.CommonTypes.Private;

namespace Azure.ResourceManager.CommonTypes;

#suppress "deprecated" "https://github.com/Azure/typespec-azure/issues/2284"
@@Azure.ResourceManager.Private.conditionalClientFlatten(PrivateLinkResource.properties);
#suppress "deprecated" "https://github.com/Azure/typespec-azure/issues/2284"
@@Azure.ResourceManager.Private.conditionalClientFlatten(PrivateEndpointConnection.properties);

/** The private endpoint */
@@armCommonDefinition(PrivateEndpoint,
"PrivateEndpoint",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ model ResourceUpdateModel<
"Name" | "name" | "properties"
>>> {
/** The resource-specific properties for this resource. */
#suppress "deprecated" "https://github.com/Azure/typespec-azure/issues/2284"
@conditionalClientFlatten
properties?: ResourceUpdateModelProperties<Resource, Properties>;
}

Expand Down Expand Up @@ -184,8 +182,6 @@ model ProxyResourceUpdateModel<
Resource extends Foundations.SimpleResource,
Properties extends TypeSpec.Reflection.Model
> {
#suppress "deprecated" "https://github.com/Azure/typespec-azure/issues/2284"
@conditionalClientFlatten
properties?: ResourceUpdateModelProperties<Resource, Properties>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ model TrackedResourceWithOptionalLocation<
Properties extends {},
PropertiesOptional extends valueof boolean = true
> extends CommonTypes.Resource {
#suppress "deprecated" "https://github.com/Azure/typespec-azure/issues/2284"
@doc("The RP-specific properties for this resource.")
@conditionalClientFlatten
@armResourcePropertiesOptionality(PropertiesOptional)
properties?: Properties;

Expand Down
6 changes: 0 additions & 6 deletions packages/typespec-azure-resource-manager/lib/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ model ResourceNameParameter<
@Http.Private.includeInapplicableMetadataInPayload(false)
model TrackedResource<Properties extends {}, PropertiesOptional extends valueof boolean = true>
extends Foundations.TrackedResource {
#suppress "deprecated" "https://github.com/Azure/typespec-azure/issues/2284"
@doc("The resource-specific properties for this resource.")
@conditionalClientFlatten
@armResourcePropertiesOptionality(PropertiesOptional)
properties?: Properties;
}
Expand All @@ -91,9 +89,7 @@ model TrackedResource<Properties extends {}, PropertiesOptional extends valueof
@Http.Private.includeInapplicableMetadataInPayload(false)
model ProxyResource<Properties extends {}, PropertiesOptional extends valueof boolean = true>
extends Foundations.ProxyResource {
#suppress "deprecated" "https://github.com/Azure/typespec-azure/issues/2284"
@doc("The resource-specific properties for this resource.")
@conditionalClientFlatten
@armResourcePropertiesOptionality(PropertiesOptional)
properties?: Properties;
}
Expand Down Expand Up @@ -123,9 +119,7 @@ model ProxyResource<Properties extends {}, PropertiesOptional extends valueof bo
@Http.Private.includeInapplicableMetadataInPayload(false)
model ExtensionResource<Properties extends {}, PropertiesOptional extends valueof boolean = true>
extends Foundations.ExtensionResource {
#suppress "deprecated" "https://github.com/Azure/typespec-azure/issues/2284"
@doc("The resource-specific properties for this resource.")
@conditionalClientFlatten
@armResourcePropertiesOptionality(PropertiesOptional)
properties?: Properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ extern dec enforceConstraint(target: Operation | Model, sourceType: Model, const
*/
extern dec azureResourceBase(target: Model);

/**
* Please DO NOT USE in RestAPI specs.
* Internal decorator that deprecated direct usage of `x-ms-client-flatten` OpenAPI extension.
* It will programatically enabled/disable client flattening with @flattenProperty with autorest
* emitter flags to maintain compatibility in swagger.
*/
#deprecated "Use @Azure.ClientGenerator.Core.Legacy.flattenProperty instead."
extern dec conditionalClientFlatten(target: ModelProperty);

/**
* Marks the operation as being a collection action
* @param resourceType Resource
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-azure-resource-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export { $lib } from "./lib.js";
export { $linter } from "./linter.js";

export { getInlineAzureType } from "./commontypes.private.decorators.js";
export { isAzureResource, isConditionallyFlattened } from "./private.decorators.js";
export { isAzureResource } from "./private.decorators.js";

/** @internal */
export { $decorators } from "./tsp-index.js";
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import {
AzureResourceBaseDecorator,
AzureResourceManagerPrivateDecorators,
BuiltInResourceOperationDecorator,
ConditionalClientFlattenDecorator,
DefaultResourceKeySegmentNameDecorator,
EnforceConstraintDecorator,
ExtensionResourceOperationDecorator,
Expand Down Expand Up @@ -591,24 +590,6 @@ export function isAzureResource(program: Program, resourceType: Model): boolean
return isResourceBase ?? false;
}

/**
* Please DO NOT USE in RestAPI specs.
* Internal decorator that deprecated direct usage of `x-ms-client-flatten` OpenAPI extension.
* It will programatically enabled/disable client flattening with @flattenProperty with autorest
* emitter flags to maintain compatibility in swagger.
*/
const $conditionalClientFlatten: ConditionalClientFlattenDecorator = (
context: DecoratorContext,
entity: ModelProperty,
) => {
context.program.stateMap(ArmStateKeys.armConditionalClientFlatten).set(entity, true);
};

export function isConditionallyFlattened(program: Program, entity: ModelProperty): boolean {
const flatten = program.stateMap(ArmStateKeys.armConditionalClientFlatten).get(entity);
return flatten ?? false;
}

const $armRenameListByOperation: ArmRenameListByOperationDecorator = (
context: DecoratorContext,
entity: Operation,
Expand Down Expand Up @@ -952,7 +933,6 @@ export const $decorators = {
resourceParameterBaseFor: $resourceParameterBaseFor,
azureResourceBase: $azureResourceBase,
omitIfEmpty: $omitIfEmpty,
conditionalClientFlatten: $conditionalClientFlatten,
assignUniqueProviderNameValue: $assignUniqueProviderNameValue,
assignProviderNameValue: $assignProviderNameValue,
armUpdateProviderNamespace: $armUpdateProviderNamespace,
Expand Down
1 change: 0 additions & 1 deletion packages/typespec-azure-resource-manager/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const ArmStateKeys = {

// private.decorator.ts
azureResourceBase: azureResourceManagerCreateStateSymbol("azureResourceBase"),
armConditionalClientFlatten: azureResourceManagerCreateStateSymbol("armConditionalClientFlatten"),
renamePathParameters: azureResourceManagerCreateStateSymbol("renamePathParameters"),

// commontypes.private.decorators.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ Create read-only property schema for lro status

Determine whether and how to emit x-ms-long-running-operation-options for lro resolution

### `arm-resource-flattening`

**Type:** `boolean`

Back-compat flag. If true, continue to emit `x-ms-client-flatten` in for some of the ARM resource properties.

### `emit-common-types-schema`

**Type:** `"never" | "for-visibility-changes"`
Expand Down
Loading