Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
rxdiscovery committed Jun 4, 2023
1 parent 5d6ba61 commit 3a67929
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "utoipa_auto_discovery"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
authors = ["RxDiscovery"]
rust-version = "1.69"
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,21 @@ import macro
use utoipa_auto_discovery::utoipa_auto_discovery;
```

then add the `#[utoipa_auto_discovery]` macro just before the `#[openapi]` macro.
then add the `#[utoipa_auto_discovery]` macro just before the #[derive(OpenApi)] and `#[openapi]` macros.

## important !!

Put `#[utoipa_auto_discovery]` before #[derive(OpenApi)] and `#[openapi]` macros.

```rust
#[utoipa_auto_discovery(paths = "MODULE_TREE::MODULE_NAME | MODULE_SRC_FILE_PATH; MODULE_TREE::MODULE_NAME | MODULE_SRC_FILE_PATH; ... ;")]
#[utoipa_auto_discovery(paths = "( MODULE_TREE::MODULE_NAME => MODULE_SRC_FILE_PATH ) ; ( MODULE_TREE::MODULE_NAME => MODULE_SRC_FILE_PATH ) ; ... ;")]
```

the paths receives a String which must respect this structure :

`"{MODULE_TREE_PATH} | {MODULE_SRC_FILE_PATH} ;"`
`" ( MODULE_TREE_PATH => MODULE_SRC_FILE_PATH ) ;"`

you can add several pairs (Module Path | Src Path ) by separating them with a semicolon ";".
you can add several pairs (Module Path => Src Path ) by separating them with a semicolon ";".

Here's an example of how to add all the methods contained in the test_controller and test2_controller modules.
you can also combine automatic and manual addition, as here we've added a method manually to the documentation "other_controller::get_users".
Expand All @@ -92,11 +96,10 @@ you can also combine automatic and manual addition, as here we've added a method
use utoipa_auto_discovery::utoipa_auto_discovery;

...

#[derive(OpenApi)]
#[utoipa_auto_discovery(
paths = "crate::rest::test_controller | ./src/rest/test_controller.rs ; crate::rest::test2_controller | ./src/rest/test2_controller.rs"
paths = "( crate::rest::test_controller => ./src/rest/test_controller.rs ) ; ( crate::rest::test2_controller => ./src/rest/test2_controller.rs )"
)]
#[derive(OpenApi)]
#[openapi(
paths(

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ pub fn utoipa_auto_discovery(
}

let mut is_ok: bool = false;
#[warn(clippy::needless_range_loop)]
for i in 0..attrs.len() {
if attrs[i].path().is_ident("openapi") {
is_ok = true;
Expand Down

0 comments on commit 3a67929

Please sign in to comment.