Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arm, remove special handling for ARM types #2749

Merged
merged 4 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
45 changes: 0 additions & 45 deletions typespec-extension/src/code-model-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,6 @@ export class CodeModelBuilder {
// deduplicate model name
const nameCount = new Map<string, number>();
const deduplicateName = (schema: Schema) => {
// skip models under "Azure.ResourceManager"
if (this.isArm() && schema.language.default?.namespace?.startsWith("Azure.ResourceManager")) {
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const name = schema.language.default.name;
// skip models under "com.azure.core."
if (name && !schema.language.java?.namespace?.startsWith("com.azure.core.")) {
Expand Down Expand Up @@ -2146,21 +2142,6 @@ export class CodeModelBuilder {

private processObjectSchema(type: Model, name: string): ObjectSchema {
const namespace = getNamespace(type);
if (
(this.isArm() &&
namespace?.startsWith("Azure.ResourceManager") &&
// there's ResourceListResult under Azure.ResourceManager namespace,
// which shouldn't be considered Resource schema parent
(name?.startsWith("TrackedResource") ||
name?.startsWith("ExtensionResource") ||
name?.startsWith("ProxyResource"))) ||
name === "ArmResource"
) {
const objectSchema = this.dummyResourceSchema(type, name, namespace);
this.codeModel.schemas.add(objectSchema);

return objectSchema;
}
const objectSchema = new ObjectScheme(name, this.getDoc(type), {
summary: this.getSummary(type),
language: {
Expand Down Expand Up @@ -2337,32 +2318,6 @@ export class CodeModelBuilder {
return type;
}

private dummyResourceSchema(type: Model, name?: string, namespace?: string): ObjectSchema {
const resourceModelName = name?.startsWith("TrackedResource") ? "Resource" : "ProxyResource";
const resource = this.dummyObjectSchema(type, resourceModelName, namespace);
const declaredProperties = walkPropertiesInherited(type);
for (const prop of declaredProperties) {
resource.addProperty(this.processModelProperty(prop));
}
return resource;
}

private dummyObjectSchema(type: Model, name: string, namespace?: string): ObjectSchema {
return new ObjectScheme(name, this.getDoc(type), {
summary: this.getSummary(type),
language: {
default: {
name: name,
namespace: namespace,
},
java: {
name: name,
namespace: getJavaNamespace(namespace),
},
},
});
}

private applyModelPropertyDecorators(prop: ModelProperty, nameHint: string, schema: Schema): Schema {
// if (schema instanceof StringSchema) {
// const decorators = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,62 @@
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.fluent.models.ChildResourceProperties",
"name" : "com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.models.ChildResourceUpdate",
"name" : "com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceProperties",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.implementation.models.ChildResourceListResult",
"name" : "com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceInner",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceInner",
"name" : "com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceProperties",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.fluent.models.TopLevelArmResourceProperties",
"name" : "com.cadl.armresourceprovider.models.ManagedServiceIdentity",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.models.TopLevelArmResourceUpdate",
"name" : "com.cadl.armresourceprovider.models.UserAssignedIdentity",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.models.TopLevelArmResourceUpdateProperties",
"name" : "com.cadl.armresourceprovider.fluent.models.ChildResourceProperties",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.implementation.models.TopLevelArmResourceListResult",
"name" : "com.cadl.armresourceprovider.models.ChildResourceUpdate",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceInner",
"name" : "com.cadl.armresourceprovider.implementation.models.ChildResourceListResult",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.fluent.models.CustomTemplateResourceProperties",
"name" : "com.cadl.armresourceprovider.models.TopLevelArmResourceUpdate",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.models.ManagedServiceIdentity",
"name" : "com.cadl.armresourceprovider.models.TopLevelArmResourceUpdateProperties",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
}, {
"name" : "com.cadl.armresourceprovider.models.UserAssignedIdentity",
"name" : "com.cadl.armresourceprovider.implementation.models.TopLevelArmResourceListResult",
"allDeclaredConstructors" : true,
"allDeclaredFields" : true,
"allDeclaredMethods" : true
Expand Down
Loading