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
fix/support multiple tags per endpoint #82
Comments
Looking into the codebase, this change seems quite doable. The only user-facing change I forsee, is to rename the Would look a little something like this.
I'll submit a PR in a few. |
Hi @SeanCassiere, thanks for opening an issue. How would you feel about |
Hi @jlalmes, sounds good to me. Was just about to publish and put a PR 😄. In one of my commits I updated the examples (express and Nextjs) to use Arrays, shall I revert back to original or use |
Alternatively with could support: EDIT: I quite like the DX of |
To avoid making it a breaking change, In the future, you may want to consider only supporting tags, for the sake of sticking to the OpenAPI spec. Let me know your preference, I'll make the changes accordingly. |
Let's do this - leave your changes in the |
@jlalmes Got a Typescript question... is there a better way of doing this? type OpenApiMetaProps = {
enabled: boolean;
method: OpenApiMethod;
path: `/${string}`;
summary?: string;
description?: string;
protect?: boolean;
};
interface OpenApiMetaStringTag extends OpenApiMetaProps {
tag?: string;
}
interface OpenApiMetaArrayTag extends OpenApiMetaProps {
tags?: string[];
}
export type OpenApiMeta<TMeta = Record<string, any>> = TMeta & {
openapi?: OpenApiMetaStringTag | OpenApiMetaArrayTag;
}; EDIT: Meaning, is there a way of doing the types where it won't slow you down in the future? Or would something simpler like this work better? export type OpenApiMeta<TMeta = Record<string, any>> = TMeta & {
openapi?: {
enabled: boolean;
method: OpenApiMethod;
path: `/${string}`;
summary?: string;
description?: string;
protect?: boolean;
tag?: string;
tags?: string[];
};
}; |
I'd probably do something like this: export type OpenApiMeta<TMeta = Record<string, any>> = TMeta & {
openapi?: {
enabled: boolean;
method: OpenApiMethod;
path: `/${string}`;
summary?: string;
description?: string;
protect?: boolean;
} & ({ tag?: string } | { tags?: string[] });
}; |
Nice! thanks 👍🏼 |
Needed to make a small tweak to the types but now it works, and I've just made the commit. export type OpenApiMeta<TMeta = Record<string, any>> = TMeta & {
openapi?: {
enabled: boolean;
method: OpenApiMethod;
path: `/${string}`;
summary?: string;
description?: string;
protect?: boolean;
} & ({ tag?: string; tags?: never } | { tag?: never; tags?: string[] });
}; For the docs, I've currently just changed it like this. Thoughts on the wording? @jlalmes
|
Looks good to me! |
I was trying out the package and noticed that each endpoint is limited to a single tag.
Please see below.
Maybe this needs to change? Since tags are used to group operations together and a single one could be in two groups. Also, Swagger Docs on the OpenAPI Spec for 3.0.3, states that the tag field should container an Array of string tags. -> string[]
https://swagger.io/specification/#operation-object
The text was updated successfully, but these errors were encountered: