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

Resource model envelope properties #5065

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pshao25
Copy link
Member

@pshao25 pshao25 commented Jan 27, 2025

  1. If the common type is not in v3-v6, set it to v3, otherwise we cannot extend the resource model from arm library.
  2. If the property in the resource model can be replaced by the envelop property from arm library, then use the envelope property, otherwise remain the same.

@@ -74,19 +74,6 @@ union ProvisioningState {
Scaling: "Scaling",
}

/**
Copy link
Member Author

Choose a reason for hiding this comment

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

Expected. We changed the behavior to setting common type version v3. so that we could leverage the models from arm library.

*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "For backward compatibility"
@visibility("read")
etag?: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to confirm if it could be replaced by EntityTagProperty, since in the EntityTagProperty, the name is eTag. Capital "T".

@@ -13,6 +13,7 @@ namespace Azure.ResourceManager.Authorization;
/**
* Deny Assignment
*/
@extensionResource
Copy link
Member Author

Choose a reason for hiding this comment

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

Expected. It is extension resource.

@@ -20,8 +20,7 @@ model ArrayDefault
...ResourceNameParameter<
Resource = ArrayDefault,
KeyName = "name",
SegmentName = "arraydefaults",
NamePattern = "^[a-zA-Z0-9-]{3,24}$"
SegmentName = "arraydefaults"
Copy link
Member Author

Choose a reason for hiding this comment

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

Default value for NamePattern is "^[a-zA-Z0-9-]{3,24}$"

else return `${generateSuppressionForDocumentRequired()}\n${kv}`;
else
return `${generateSuppressions([
getSuppresssionWithCode("@azure-tools/typespec-azure-core/documentation-required"),
Copy link
Member

Choose a reason for hiding this comment

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

consider to declare a const string "@azure-tools/typespec-azure-core/documentation-required" to avoid the duplicates

let capacityFound = false;

for (const property of schema.properties) {
if (property.serializedName === "name" && property.required && property.schema.type === "string") {
Copy link
Member

Choose a reason for hiding this comment

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

Wondering how we define the replacement.
Here we check if schema contains all properties of Sku, but what if there is more properties in schema, can we replace it with Sku?

And also, instead of hard-code all the property name and types, is it possible to get the defined schemas and compare them instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants