microsoft / microsoft/typespec

withVisibility decorator is not working with extended model that has visibility decorator on properties

Open
#3,040 1 comment 2 reactions 0 assignees View on GitHub
bug triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

If I have a model `VisibilityModelCreateParameters` have `@withVisibility` decorator,
```
@withVisibility("create")
model VisibilityModelCreateParameters {
...VisibilityModel
}
```
and I have another model `SubResource` that extends from the `VisibilityModelCreateParameters`

```
model SubResource extends VisibilityModelCreateParameters {
@visibility("query")
prop2: int32;
}
```
It reports error like
```
error
@typespec/openapi/duplicate-type-name
Duplicate type name: 'SubResource'. Check @friendlyName decorators and overlap with types in TypeSpec or service namespace.
23:1
```

But if I change the prop2 visibility into "read", it's working, I have tried other visibility and found all other visibility like "create", "update", "delete" are not working.

See the [playground link](https://cadlplayground.z22.web.core.windows.net/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CgpAc2VydmljZQpuYW1lc3BhY2UgRGVtb1PGFjsKCm1vZGVsIFZpc2liaWxpdHlNxRB7CiAgQHbJFShMaWZlY3ljbGUuQ3JlYXRlKQogIGPFClByb3A6IHN0cmluZ1tdOwrZOVVwZMc5dcUKxjlpbnQzMsQ4fQoKCkB3aXRo6gCL03b1AK7GHVBhcmFtZXRlcnPlAL4uLi7PJ8RjxkBTdWJSZXNvdXJjZSBleHRlbmRz31TGVPYA2VF1ZXJ55ADYcHJvcDLnANM7Cgp9Cg%3D%3D&tspconfig=ZW1pdDoKICAtICJAdHlwZXNwZWMvb3BlbmFwaTMiCg%3D%3D&vs=%7B%7D) for more details.

I do know that `@withVisibility` decorator is defining a new model and filter out all the properties that applies the `@withVisibility` decorator specified, but I am thinking whether if it's expected to extend that behavior to that new model's sub models ?

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.