[Bug]: Integer[int32] unions after conversion to autorest, generated enum has type number instead of int[int32]
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
### 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:
``` tsp
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:
``` json
"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.
``` json
"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
- [X] Follow our [Code of Conduct](https://github.com/azure/typespec-azure/blob/main/CODE_OF_CONDUCT.md)
- [X] 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](https://github.com/Microsoft/TypeSpec/issues/new/choose)
- [X] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Research direction
Start with the minimal TypeSpec union reproduction in the issue and generate the autorest JSON to confirm the mismatch. Trace the conversion path that maps the int32 union member into the generated enum schema. Done means the output uses type "int" with format "int32" while preserving the documented enum values and x-ms-enum metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100