diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-09-23 17:16:23 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-09-23 17:16:23 +0200 |
| commit | e536cb326a67fffd511ead4a87655ca5ef98bf29 (patch) | |
| tree | 96deb4e27b25c1e82a5d8b2be01aed650521bfc7 /crates/rocie-server/src/api/get | |
| parent | chore(crates/rocies-client): Regenerate (diff) | |
| download | server-e536cb326a67fffd511ead4a87655ca5ef98bf29.zip | |
feat(crates/rocies-server): Don't make the newtype wrappers transparent in the openapi spec
This makes using the generated code significantly easier and type safer.
Diffstat (limited to 'crates/rocie-server/src/api/get')
| -rw-r--r-- | crates/rocie-server/src/api/get/inventory.rs | 6 | ||||
| -rw-r--r-- | crates/rocie-server/src/api/get/product.rs | 6 | ||||
| -rw-r--r-- | crates/rocie-server/src/api/get/unit.rs | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/crates/rocie-server/src/api/get/inventory.rs b/crates/rocie-server/src/api/get/inventory.rs index 3011430..d1ca436 100644 --- a/crates/rocie-server/src/api/get/inventory.rs +++ b/crates/rocie-server/src/api/get/inventory.rs @@ -2,7 +2,7 @@ use actix_web::{HttpResponse, Responder, Result, get, web}; use crate::{ app::App, - storage::sql::{product::ProductId, product_amount::ProductAmount}, + storage::sql::{product::{ProductId, ProductIdStub}, product_amount::ProductAmount}, }; /// Get the amount of an product @@ -33,11 +33,11 @@ use crate::{ #[get("/inventory/{id}")] pub(crate) async fn amount_by_id( app: web::Data<App>, - id: web::Path<ProductId>, + id: web::Path<ProductIdStub>, ) -> Result<impl Responder> { let id = id.into_inner(); - match ProductAmount::from_id(&app, id).await? { + match ProductAmount::from_id(&app, id.into()).await? { Some(product) => Ok(HttpResponse::Ok().json(product)), None => Ok(HttpResponse::NotFound().finish()), } diff --git a/crates/rocie-server/src/api/get/product.rs b/crates/rocie-server/src/api/get/product.rs index c496777..90cb8c8 100644 --- a/crates/rocie-server/src/api/get/product.rs +++ b/crates/rocie-server/src/api/get/product.rs @@ -2,7 +2,7 @@ use actix_web::{HttpResponse, Responder, Result, get, web}; use crate::{ app::App, - storage::sql::product::{Product, ProductId}, + storage::sql::product::{Product, ProductId, ProductIdStub}, }; /// Get Product by id @@ -19,11 +19,11 @@ use crate::{ #[get("/product/{id}")] pub(crate) async fn product_by_id( app: web::Data<App>, - id: web::Path<ProductId>, + id: web::Path<ProductIdStub>, ) -> Result<impl Responder> { let id = id.into_inner(); - match Product::from_id(&app, id).await? { + match Product::from_id(&app, id.into()).await? { Some(product) => Ok(HttpResponse::Ok().json(product)), None => Ok(HttpResponse::NotFound().finish()), } diff --git a/crates/rocie-server/src/api/get/unit.rs b/crates/rocie-server/src/api/get/unit.rs index d006818..4854ea3 100644 --- a/crates/rocie-server/src/api/get/unit.rs +++ b/crates/rocie-server/src/api/get/unit.rs @@ -1,6 +1,6 @@ use actix_web::{get, web, HttpResponse, Responder, Result}; -use crate::{app::App, storage::sql::unit::{Unit, UnitId}}; +use crate::{app::App, storage::sql::unit::{Unit, UnitId, UnitIdStub}}; /// Return all registered units #[utoipa::path( @@ -30,11 +30,11 @@ pub(crate) async fn units(app: web::Data<App>) -> Result<impl Responder> { #[get("/unit/{id}")] pub(crate) async fn unit_by_id( app: web::Data<App>, - id: web::Path<UnitId>, + id: web::Path<UnitIdStub>, ) -> Result<impl Responder> { let id = id.into_inner(); - match Unit::from_id(&app, id).await? { + match Unit::from_id(&app, id.into()).await? { Some(product) => Ok(HttpResponse::Ok().json(product)), None => Ok(HttpResponse::NotFound().finish()), } |
