Azure / typespec-azure

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

[Bug]: Integer[int32] unions after conversion to autorest, generated enum has type number instead of int[int32] #919

Open Mohana-Krishna-N opened 5 months ago

Mohana-Krishna-N commented 5 months ago

Describe the bug

When we try to generated the autorest for the union with type int[int32] It generates the type: number

Reproduction

Sample model:

union PollingIntervalInSeconds {
  @doc("30 PollingIntervalInSeconds")
  Thirty: 30,

  @doc("60 PollingIntervalInSeconds")
  sixty: 60,

  @doc("90 PollingIntervalInSeconds")
  Ninety: 90,

  @doc("120 PollingIntervalInSeconds")
  OneTwenty: 120,

  int32,
}

Actual output:

      "pollingIntervalInSeconds": {
        "type": "number",
        "description": "Polling interval in seconds.",
        "default": 30,
        "enum": [
          30,
          60,
          90,
          120
        ],
        "x-ms-enum": {
          "name": "PollingIntervalInSeconds",
          "modelAsString": true,
      },

Expected output: Should have "type": "int", "format": "int32" as shown below.

      "pollingIntervalInSeconds": {
        "type": "int",
        "format": "int32",
        "description": "Polling interval in seconds.",
        "default": 30,
        "enum": [
          30,
          60,
          90,
          120
        ],
        "x-ms-enum": {
          "name": "PollingIntervalInSeconds",
          "modelAsString": true,
      },

Checklist

markcowl commented 5 months ago

link to new issue on literal type resolution