Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
tadelesh committed Jan 24, 2024
1 parent 9543e7f commit 733f3e5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,23 @@ export function generateArmResource(resource: TspArmResource): string {
definitions.push(`@parentResource(${resource.resourceParent.name})`);
}

if (!resource.baseModelName && !resource.propertiesPropertyRequired &&
if (
!resource.baseModelName &&
!resource.propertiesPropertyRequired &&
resource.propertiesPropertyVisibility.length === 2 &&
resource.propertiesPropertyVisibility.includes("read") &&
resource.propertiesPropertyVisibility.includes("create")) {
resource.propertiesPropertyVisibility.includes("create")
) {
definitions.push(`model ${resource.name} is ${resource.resourceKind}<${resource.propertiesModelName}> {`);

definitions = [...definitions, ...getModelPropertiesDeclarations(resource.properties)];
} else {
definitions.push(`#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "For backward compatibility"`);
definitions.push(`#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "For backward compatibility"`)
definitions.push(
`#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "For backward compatibility"`,
);
definitions.push(
`#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "For backward compatibility"`,
);
definitions.push(`@Azure.ResourceManager.Private.armResourceInternal(${resource.propertiesModelName})`);
definitions.push(`@includeInapplicableMetadataInPayload(false)`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,9 @@ export function transformTspArmResource(schema: ArmResourceSchema): TspArmResour
}

function getOtherProperties(schema: ArmResourceSchema, noCommonTypes: boolean): TypespecObjectProperty[] {
const knownProperties = [
"properties",
"id",
"name",
"type",
"systemData",
"location",
"tags"
];
const knownProperties = ["properties", "id", "name", "type", "systemData", "location", "tags"];
if (!noCommonTypes) {
knownProperties.push(...[
"identity",
"sku",
"eTag",
"plan"
])
knownProperties.push(...["identity", "sku", "eTag", "plan"]);
}
const otherProperties: TypespecObjectProperty[] = [];
for (const property of schema.properties ?? []) {
Expand Down
4 changes: 2 additions & 2 deletions packages/extensions/openapi-to-typespec/src/utils/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export function getRoutesImports(_program: TypespecProgram) {
const namespaces = new Set<string>();

modules.add(`import "@azure-tools/typespec-azure-core";`);
modules.add(`import "@typespec/rest";`)
modules.add(`import "./models.tsp";`)
modules.add(`import "@typespec/rest";`);
modules.add(`import "./models.tsp";`);

namespaces.add(`using TypeSpec.Rest;`);
namespaces.add(`using TypeSpec.Http;`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,7 @@ const _ArmCoreEnums = [
"CheckNameAvailabilityReason",
];

const _ArmCoreCustomEnums = [
"ManagedIdentityType",
"ManagedSystemIdentityType",
"SkuTier",
];
const _ArmCoreCustomEnums = ["ManagedIdentityType", "ManagedSystemIdentityType", "SkuTier"];

export function filterArmEnums(enums: TypespecEnum[]): TypespecEnum[] {
const filtered = [..._ArmCoreEnums];
Expand Down

0 comments on commit 733f3e5

Please sign in to comment.