microsoft / microsoft/typespec
Built in tags metadata
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
We currently define `@tagMetadata` in openapi library to map to openapi meaning. However it could be beneficial to define tags as a more core typespec feature. Current `@tag` is a core decorator that just take a string. We could expand to allow enum member which would allow defining available tags as enum(s)
```ts
import "@typespec/openapi";
@tags
enum Tags {
/** Abc tag */
@summary("Abc")
@OpenAPI.externalDocs("")
// parent
// kind
tagA,
/** Abc tag */
@tagParent(Tags.tagA)
@tagKind("abc")
tagB,
}
@tag(Tags.tagA)
op a(): void;
```
[Playground Link](https://typespec.io/playground/?e=%40typespec%2Fopenapi3&c=aW1wb3J0ICJAdHlwZXNwZWMvb3BlbmFwaSI7CgpAdGFncwplbnVtIFRhZ3MgewogIC8qKiBBYmMgdGFnICovCiAgQHN1bW1hcnkoIkFiYyIpxBJPcGVuQVBJLmV4dGVybmFsRG9jcygixRwvLyBwYXJlbnTGDGtpbmQKIMRNQSwK1V50YWdQxTEo5ACDLsQqxWR0YWdLaW5kKCJhx3Z0YWdCLAp95gC2zC1vcCBhKCk6IHZvaWQ7&options=%7B%7D&vs=%7B%7D)
## Category as separate enums
```tsp
enum TagGroupA {
a,
b,
}
enum TagGroupB {
a,
b,
}
```
Contributor guide
Assessment
This issue has not been assessed yet.