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

Add implementation for utoipa-actix-web bindings #1158

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Oct 22, 2024

Implements wrappers for ServiceConfig, App, Scope of actix-web. This allows users to create App with collecting paths and schemas recursively without registering them to #[openapi(...)] attribute.

Example of new supported syntax.

 use actix_web::{get, App};
 use utoipa_actix_web::{scope, AppExt};

 #[derive(utoipa::ToSchema)]
 struct User {
     id: i32,
 }

 #[utoipa::path(responses((status = OK, body = User)))]
 #[get("/user")]
 async fn get_user() -> Json<User> {
     Json(User { id: 1 })
 }

 let (_, mut api) = App::new()
     .into_utoipa_app()
     .service(scope::scope("/api/v1").service(get_user))
     .split_for_parts();

Relates #283 Relates #662
Closes #121 Closes #657

Implements wrappers for `ServiceConfig`, `App`, `Scope` of actix-web.
This allows users to create `App` with collecting `paths` and `schemas`
recursively without registering them to `#[openapi(...)]` attribute.

Example of new supported syntax.
```rust
 use actix_web::{get, App};
 use utoipa_actix_web::{scope, AppExt};

 #[derive(utoipa::ToSchema)]
 struct User {
     id: i32,
 }

 #[utoipa::path(responses((status = OK, body = User)))]
 #[get("/user")]
 async fn get_user() -> Json<User> {
     Json(User { id: 1 })
 }

 let (_, mut api) = App::new()
     .into_utoipa_app()
     .service(scope::scope("/api/v1").service(get_user))
     .split_for_parts();
```

Relates #283 Relates #662
Closes #121 Closes #657
@juhaku juhaku force-pushed the feature-actix-web-service-config-scopes branch from 1efd7ed to d1812cb Compare October 22, 2024 19:26
@juhaku juhaku merged commit 2bfbee7 into master Oct 22, 2024
24 checks passed
@juhaku juhaku deleted the feature-actix-web-service-config-scopes branch October 22, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

Add ServiceConfig to avoid redundancy. Missing actix::web::scope support
1 participant