-
Notifications
You must be signed in to change notification settings - Fork 202
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
Paths are always assigned to a tag with their module path #978
Comments
Not sure do I understand the problem, but there is a way to provide custom tag for the operation with the following. #[utoipa::path(
tag = ...
)] Then the operations that has the same tag will be grouped together. Depending on which version of
Actually it is but the path must be
|
@juhaku I am pointing at your The
The following does not appear to be true. Everything I have is
|
In the next few days I can link an example using your todo app to demonstrate what I am talking about. |
Is there any news on this? I'm having the same issue (default module path tags I cannot get rid of, no matter if I'm using |
@theelderbeever Okay, thanks for pointing out. I assume there is a bug in the tags processing it should be investigated that what's the deal in the code. |
The default tag for paths is resolved from the module path of the handler or `OpenApi` if the type in question is a nested `OpenApi` document. This was supposed to be only the case when no additional tags are provided for the paths. However it was resolved in all cases and there was no way to "not to use" module path as a tag. This commit fixes this and the module path will be only used if there are no other tags defined. This commit also changes the old behavior where _`crate`_ was used as a tag in case there was no module path available. From now on if there is no module path there will be no default tag added to any of the paths. This will result the paths to be rendered under _`default`_ tag in a Swagger UI. Fixes #978
Yes it seems that the doc has not been updated since the behavior has been changed probably long ago. However it will generate allways pub struct regardless whether the handler fn itself is pub or not. The following code is possible to nest paths from sub module paths without exposing the module path to the derive macro. mod test_path {
#[allow(dead_code)]
#[utoipa::path(get, path = "/test")]
#[allow(unused)]
pub fn test_path() -> &'static str {
""
}
}
mod test_nest {
#[derive(utoipa::OpenApi)]
#[openapi(paths(test_path_nested))]
pub struct NestApi;
#[allow(dead_code)]
#[utoipa::path(get, path = "/test")]
#[allow(unused)]
fn test_path_nested() -> &'static str {
""
}
}
use test_nest::NestApi;
use test_path::__path_test_path;
#[derive(utoipa::OpenApi)]
#[openapi(
paths(test_path),
nest(
(path = "/api/nest", api = NestApi)
)
)]
struct ApiDoc; |
The default tag for paths is resolved from the module path of the handler or `OpenApi` if the type in question is a nested `OpenApi` document. This was supposed to be only the case when no additional tags are provided for the paths. However it was resolved in all cases and there was no way to "not to use" module path as a tag. This commit fixes this and the module path will be only used if there are no other tags defined. This commit also changes the old behavior where _`crate`_ was used as a tag in case there was no module path available. From now on if there is no module path there will be no default tag added to any of the paths. This will result the paths to be rendered under _`default`_ tag in a Swagger UI. Fixes #978
The default tag for paths is resolved from the module path of the handler or `OpenApi` if the type in question is a nested `OpenApi` document. This was supposed to be only the case when no additional tags are provided for the paths. However it was resolved in all cases and there was no way to "not to use" module path as a tag. This commit fixes this and the module path will be only used if there are no other tags defined. This commit also changes the old behavior where _`crate`_ was used as a tag in case there was no module path available. From now on if there is no module path there will be no default tag added to any of the paths. This will result the paths to be rendered under _`default`_ tag in a Swagger UI. Fixes #978
I am trying to use nesting of OpenApi doc structs because you can't register a path that isn't defined in the same module as the
utoipa::path
macro. However, with a nested api doc I keep getting a an extra tag header with the module location for each path. How can I get rid of that?Additionally, why isn't it possible to register a path in a separate module?
The text was updated successfully, but these errors were encountered: