Skip to content

Commit

Permalink
Merge pull request #45 from ProbablyClem/feature/utoipa-v5
Browse files Browse the repository at this point in the history
V0.2.0 preparation / Utoipa v5 support
  • Loading branch information
DenuxPlays authored Oct 17, 2024
2 parents b7d8525 + b7e3d4e commit 7469f9d
Show file tree
Hide file tree
Showing 38 changed files with 821 additions and 911 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ max_line_length = 120
trim_trailing_whitespace = false

[{*.yml,*.yaml}]
indent_size = 2
indent_size = 2
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rust: [ "1.74.0", "stable", "nightly" ]
rust: [ "1.75.0", "stable", "nightly" ]
steps:
- uses: actions/checkout@v4
- name: install toolchain
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"

[workspace.package]
authors = ["ProbablyClem", "RxDiscovery", "DenuxPlays"]
version = "0.1.14"
version = "0.2.0"
edition = "2021"
keywords = ["utoipa", "openapi", "swagger", "path", "auto"]
description = "Rust Macros to automate the addition of Paths/Schemas to Utoipa crate, simulating Reflection during the compilation phase"
Expand All @@ -17,15 +17,15 @@ license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/ProbablyClem/utoipauto"
homepage = "https://github.com/ProbablyClem/utoipauto"
rust-version = "1.74.0"
rust-version = "1.75.0"

[workspace.dependencies]
# Core dependencies
utoipauto-core = { path = "utoipauto-core", version = "0.1" }
utoipauto-macro = { path = "utoipauto-macro", version = "0.1" }
utoipauto-core = { path = "utoipauto-core", version = "0.2" }
utoipauto-macro = { path = "utoipauto-macro", version = "0.2" }

# Utoipa
utoipa = { version = "4.2.3", features = ["preserve_path_order"] }
utoipa = { version = "5.0.0", features = ["preserve_path_order"] }

# Macro dependencies
quote = "1.0.36"
Expand Down
75 changes: 20 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,33 +95,6 @@ The paths receives a String which must respect this structure :

You can add several paths by separating them with a coma `","`.

## Support for generic schemas

We support generic schemas, but with a few drawbacks.
<br>
If you want to use generics, you have three ways to do it.

1. use the full path

```rust
#[aliases(GenericSchema = path::to::Generic<path::to::Schema>)]
```

2. Import where utoipauto lives

```rust
use path::to::schema;
```

3. use `generic_full_path` feature

Please keep in mind that this feature causes more build-time overhead.
Higher RAM usage, longer compile times and excessive disk usage (especially on larger projects) are the consequences.

```toml
utoipauto = { version = "*", feature = ["generic_full_path"] }
```

## Usage with workspaces

If you are using a workspace, you must specify the name of the crate in the path.
Expand Down Expand Up @@ -174,8 +147,8 @@ Here's an example of how to add all the methods and structs contained in the res
use utoipauto::utoipauto;

#[utoipauto(
paths = "./src/rest"
)]
paths = "./src/rest"
)]
#[derive(OpenApi)]
#[openapi(
tags(
Expand All @@ -195,8 +168,8 @@ Here's an example of how to add all methods and structs contained in the rest mo
use utoipauto::utoipauto;

#[utoipauto(
paths = "(./src/lib/rest from crate::rest)"
)]
paths = "(./src/lib/rest from crate::rest)"
)]
#[derive(OpenApi)]
#[openapi(
tags(
Expand All @@ -220,8 +193,8 @@ other_controller::get_users", and a schema "TestDTO".
use utoipauto::utoipauto;

#[utoipauto(
paths = "./src/rest/test_controller.rs,./src/rest/test2_controller.rs "
)]
paths = "./src/rest/test_controller.rs,./src/rest/test2_controller.rs "
)]
#[derive(OpenApi)]
#[openapi(
paths(
Expand Down Expand Up @@ -251,17 +224,17 @@ ex:

```rust
/// Get all pets from database
///
#[utoipa_ignore] //<============== this Macro
#[utoipa::path(
responses(
///
#[utoipa_ignore] //<============== this Macro
#[utoipa::path(
responses(
(status = 200, description = "List all Pets", body = [ListPetsDTO])
)
)]
#[get("/pets")]
async fn get_all_pets(req: HttpRequest, store: web::Data<AppState>) -> impl Responder {
// your CODE
}
)
)]
#[get("/pets")]
async fn get_all_pets(req: HttpRequest, store: web::Data<AppState>) -> impl Responder {
// your CODE
}

```

Expand All @@ -273,10 +246,10 @@ ex:

```rust
#[utoipa_ignore] //<============== this Macro
#[derive(ToSchema)]
struct ModelToIgnore {
// your CODE
}
#[derive(ToSchema)]
struct ModelToIgnore {
// your CODE
}

```

Expand Down Expand Up @@ -324,11 +297,3 @@ Contributions are welcomed, feel free to submit a PR or an issue.
## Inspiration

Inspired by [utoipa_auto_discovery](https://github.com/rxdiscovery/utoipa_auto_discovery)

```
```

```
```
123 changes: 54 additions & 69 deletions acceptance/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7469f9d

Please sign in to comment.