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

[Bug]: In-consistant generated name for anonymous model caused breaking between m4 and tcgc #1717

Open
4 tasks done
MaryGao opened this issue Oct 22, 2024 · 1 comment
Open
4 tasks done
Labels
bug Something isn't working lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library

Comments

@MaryGao
Copy link
Member

MaryGao commented Oct 22, 2024

Describe the bug

This happened in common types but I believe this breaking would be a general issue for anonymous model when we migrate swagger to typespec. For case with below and here is the difference.

  • name given by M4 is AccessRulePropertiesSubscriptionsItem and the pattern is ${Modelname}${Propertyname}Item
  • name from tcgc is AccessRulePropertiesSubscription and the pattern is ${Modelname}${Singular(Propertyname)}

The common types in typespec is here.

model AccessRuleProperties {
  // ...

  /** Subscriptions for inbound rules */
  subscriptions?: {
    /** The fully qualified Azure resource ID of the subscription e.g. ('/subscriptions/00000000-0000-0000-0000-000000000000') */
    id?: Azure.Core.armResourceIdentifier;
  }[];
}

And relevant swagger definition is here.

"subscriptions": {
          "description": "Subscriptions for inbound rules",
          "type": "array",
          "items": {
            "description": "Subscription identifiers",
            "type": "object",
            "properties": {
              "id": {
                "description": "The fully qualified Azure resource ID of the subscription e.g. ('/subscriptions/00000000-0000-0000-0000-000000000000') ",
                "type": "string",
                "format": "arm-id"
              }
            }
          }
        },

Possible solutions

Reproduction

NA

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@MaryGao MaryGao added the bug Something isn't working label Oct 22, 2024
@tadelesh tadelesh added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Oct 22, 2024
@MaryGao MaryGao removed the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Oct 24, 2024
@MaryGao MaryGao added the lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library label Oct 24, 2024
@MaryGao
Copy link
Member Author

MaryGao commented Oct 24, 2024

@allenjzhang I'd like to clarify from typespec ARM side, do we have any preference on how to avoid this breaking? Since anonymous model is not recommanded to use, do we plan to not use any anonymous models in common types?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lib:azure-resource-manager Issues for @azure-tools/typespec-azure-core library
Projects
None yet
Development

No branches or pull requests

2 participants