Azure / typespec-azure

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

[Bug]: Normalization on the x-ms-enum name if only value and description is specified #1479

Open allenjzhang opened 2 months ago

allenjzhang commented 2 months ago

Describe the bug

Should we normalize the name in the x-ms-enum so swagger & codegen could get correctly named entries?

union ManagedServiceIdentityType {
  /** No managed identity. */
  "None",
  "SystemAssigned, UserAssigned",   <---- contains space and coma
  string,
} 
      "x-ms-enum": {
        "name": "ManagedServiceIdentityType",
        "modelAsString": true,
        "values": [
          {
            "name": "None",
            "value": "None",
            "description": "No managed identity."
          },
          {
            "name": "SystemAssigned, UserAssigned",    <----- We should normalize the name here and not take as it is.
            "value": "SystemAssigned, UserAssigned",
            "description": "System and user assigned managed identity."
          }
        ]
      }

Reproduction

See code above

Checklist

markcowl commented 2 months ago

Why not use a named union in this case? Our automatically generated name is unlikely to be what we actually want to use in clients in many cases.

timotheeguerin commented 2 months ago

autorest was able to do something without values I don't think we need to be the ones inventing names here. Either the user provided one and we carry it over or we delegate teh logic to the other emitters