microsoft / microsoft/typespec
Ability to decorate model expression
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
Currently we can add decorators on model declarations but can't decorate on model expressions which would be useful to add decorators for inline/anonymous models.
[playground](https://cadlplayground.z22.web.core.windows.net/prs/4849/?c=bW9kZWwgRm9vIHsNCiAgcHJvcDrGCyAgc3ViOiBzdHJpbmc7xBJ9xQbEI3PaJFtdySZEaWN0OiBSZWNvcmQ82DA%2BOw0KfQ0KDQovLyBkxCthdGUgbmFtZWQg5QCcDQpAQGRvYyhGb28sICJkb2N1bWVudCBmb3LkALYiKTvQPGlubGluZdE9LuUA2zp0eXBl30jHSMVBIGV4cHJlc3Npb24gaW5jbHVkaW5nIGFycmF50Fxzxl06OmluZGV4ZXJWYWx10WvFKcdtzj%2FlAS3fQshCxCzFRQ%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)
```
model Foo {
prop: {
sub: string;
};
props: {
sub: string;
}[];
propDict: Record<{
sub: string;
}>;
}
// decorate named model
@@doc(Foo, "document for Foo");
// decorate inline model
@@doc(Foo.prop::type, "document for Foo");
// decorate model expression including array
@@doc(Foo.props::type::indexerValue, "document for props");
@@doc(Foo.propDict::type::indexerValue, "document for propDict");
```
Contributor guide
Assessment
This issue has not been assessed yet.