Azure / Azure/typespec-azure

[Bug]: typespec-autorest - readonly is wrong added to some enum

Open
#2,042 9 comments 0 reactions 1 assignee Claimed by @markcowl View on GitHub
cli/psh design:needed emitter:autorest
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 22h
Merged PRs (30d)
156

Description

### Describe the bug

When generating swagger from tsp, the property **readonly** is wrong added to some enums.

Following is an example.

For union [RevocationStatus](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/codesigning/CodeSigning.Management/models.tsp#L93), we add the [readonly](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-09-30-preview/codeSigningAccount.json#L1297) property.

But for the unions in the same tsp files like [SkuName](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/codesigning/CodeSigning.Management/models.tsp#L107), we do not add readonly.

**Edit:
Include a newly discovered case: https://github.com/Azure/azure-rest-api-specs/blob/3feb9e396d38c4c0479126d3f697ff86a6ce8693/specification/azurelargeinstance/AzureLargeInstance.Management/models.tsp#L495**

### Reproduction

An example has been provided above

### 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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.