microsoft / microsoft/typespec

Built in tags metadata

Open
#10,771 1 comment 0 reactions 0 assignees View on GitHub
feature lib:http triaged:core
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

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.