Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
14 stars 40 forks source link

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

Open MaryGao opened 1 week ago

MaryGao commented 1 week ago

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.

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

MaryGao commented 1 week ago

@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?

markcowl commented 2 days ago

Moved to TCGC - if anaonymous models are used, changes in naming are always possible.

MaryGao commented 2 days ago

@markcowl Since anaonymous models are not a good practice do we have a plan in common types to not using it?