Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a decorator or other means to specify OpenAPI tag properties #2220

Open
mikekistler opened this issue Jul 28, 2023 · 5 comments
Open
Labels
design:needed A design request has been raised that needs a proposal emitter:openapi3 Issues for @typespec/openapi3 emitter
Milestone

Comments

@mikekistler
Copy link
Member

OpenAPI v2 and v3 support a global "tags" property that associates additional properties -- a description and link to external docs -- with a tag name.

https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/versions/3.0.3.md#tag-object

Many popular doc generators will display the information in these properties in the generated docs.

image

TypeSpec should provide a means to populate these properties for any tags used in the API definition.

@markcowl markcowl added the design:needed A design request has been raised that needs a proposal label Jul 31, 2023
@markcowl
Copy link
Contributor

How should we augment the tags decorator to allow additional metadata?

@markcowl markcowl added this to the Backlog milestone Jul 31, 2023
@markcowl markcowl added 📌 and removed needs-area labels Jul 31, 2023
@decarufe
Copy link

Is there a plan to implement this soon?

@bterlson
Copy link
Member

bterlson commented Feb 8, 2024

Proposal: add a new decorator to the OpenAPI library called tagMetadata. It MUST be applied to the service namespace, it is an error if it is applied to any other type. Multiple applications of tagMetadata merge like tag. The decorator takes a tag name and a model of additional properties, so for example:

@service
@tagMetadata("pet", { description: "Pets operations", externalDocs: { url: "https://example.com", description: "More info." } });
namespace PetStore;

We know we want to disambiguate data values from types via #{ ... } syntax, however OpenAPI is already rife with this ambiguity (e.g. with @extension and @info), so there doesn't seem to be much harm in continuing this trend for now.

@johanste
Copy link
Contributor

johanste commented Feb 8, 2024

I assume multiple instances will merge?

@bterlson
Copy link
Member

bterlson commented Feb 8, 2024

Yes, like @tag. Updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design:needed A design request has been raised that needs a proposal emitter:openapi3 Issues for @typespec/openapi3 emitter
Projects
None yet
Development

No branches or pull requests

6 participants