microsoft / microsoft/typespec

[Bug]: Visibility Classes do not inherit extension annotations.

Open
#8,236 1 comment 2 reactions 1 assignee Claimed by @witemple-msft View on GitHub
bug emitter:openapi3 triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

### Describe the bug

I'm working to create APIs that follow [AEP standards](https://aep.dev).

One of the requirements for this is that `resource` schemas get tagged with `x-aep-resource` extension.

This can be done simply:

```
@OpenAPI.extension("x-aep-resource", #{
singular: "widget",
plural: "widgets",
patterns: #[
"widget",
"widget/{widget_id}"
]
})
model Widget {
...
}
```

The issue is that visibility classes do not inherit from the base model this extension.

See below the playground link, and pay attention to the WidgetCreate and WidgetUpdate schemas.

### Reproduction

[[Playground Link](https://typespec.io/playground/?options=%7B%22linterRuleSet%22%3A%7B%22extends%22%3A%5B%22%40typespec%2Fhttp%2Fall%22%5D%7D%7D&c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZb3BlbmFwaSI7CgpAc2VydmljZSgjeyB0aXRsZTogIldpZGdldCBTxhoiIH0pCm5hbWVzcGFjZSBEZW1vxxo7Cgp1c2luZyBIdHRwO8cMUmVzdMRYT3BlbkFQSS5leHRlbnNpb24oIngtYWVwLXJlc291cmNlIiwgI3sKICDENnVsYXI6ICJ3xXkiLAogIHBsdXJhbMkUc8YVYXR0ZXJuczogI1sKICAgzTLJDi97xghfaWR9IgogIF0KfSkKbW9kZWwg5wDaxHdAdmlzaWJpbGl0eShMaWZlY3ljbGUuUmVhZCnEHmtleSBpZDogc3RyaW5nOwogIHdlaWdodDogaW50MzLEEWNvbG%2FkALZyZWQiIHwgImJsdWUiOwp9CgpAZXJyb3LHdEXEDMVzY29kZctAbWVzc2FnZcpkfQoKaW50ZXJm5AFo5gCr5wFqIOUBRmRz5AFe5QE9LsgJT3BlcmF0aW9uczzGMizGcT4gewp9Cg%3D%3D&e=%40typespec%2Fopenapi3&vs=%7B%7D)](https://typespec.io/playground/?options=%7B%22linterRuleSet%22%3A%7B%22extends%22%3A%5B%22%40typespec%2Fhttp%2Fall%22%5D%7D%7D&c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZb3BlbmFwaSI7CgpAc2VydmljZSgjeyB0aXRsZTogIldpZGdldCBTxhoiIH0pCm5hbWVzcGFjZSBEZW1vxxo7Cgp1c2luZyBIdHRwO8cMUmVzdMRYT3BlbkFQSS5leHRlbnNpb24oIngtYWVwLXJlc291cmNlIiwgI3sKICDENnVsYXI6ICJ3xXkiLAogIHBsdXJhbMkUc8YVYXR0ZXJuczogI1sKICAgzh7JDy97xghfaWR9IgogIF0KfSkKbW9kZWwg5wDbxHhAdmlzaWJpbGl0eShMaWZlY3ljbGUuUmVhZCnEHmtleSBpZDogc3RyaW5nOwogIHdlaWdodDogaW50MzLEEWNvbG%2FkALdyZWQiIHwgImJsdWUiOwp9CgpAZXJyb3LHdEXEDMVzY29kZctAbWVzc2FnZcpkxDpyb3V0ZSgiL%2BgA2ikKaW50ZXJm5AF85gC%2B5wF%2BIOUBWmRz5AFy5QFRLsgJT3BlcmF0aW9uczzGMizmAIQ%2BIHsKfQo%3D&e=%40typespec%2Fopenapi3&vs=%7B%7D)

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [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.