microsoft / microsoft/typespec
AdditionalProperties property type should be based on the visibility rather than the usage
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
If an InputModel is only used for Output, all of its properties should be readonly.
The below anonymous model is only used for Output
https://github.com/microsoft/typespec/blob/fdefc060e7ee20ccee94143872baa1d7dd50176c/docs/samples/client/csharp/SampleService/main.tsp#L406C4-L411
```
op ListWithNextLink(): {
@pageItems
things: Thing[];
@nextLink next?: url;
};
```
The usage is correct in [tspCodeModel.json](https://github.com/microsoft/typespec/blob/fdefc060e7ee20ccee94143872baa1d7dd50176c/packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json#L2796-L2799)
But the generated SDK is not readonly, it should be IReadOnlyList
https://github.com/microsoft/typespec/blob/fdefc060e7ee20ccee94143872baa1d7dd50176c/docs/samples/client/csharp/SampleService/SampleClient/src/Generated/Models/ListWithNextLinkResponse.cs#L36
Contributor guide
Assessment
This issue has not been assessed yet.