-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from TheAwiteb/null-update-value
`UpdateTodoSchema` that supports null values for unchanged fields
- Loading branch information
Showing
4 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use entity::todo::Status as TodoStatus; | ||
use serde::{Deserialize, Serialize}; | ||
use utoipa::ToSchema; | ||
|
||
/// The schema used to update a todo, supports null values for unchanged fields | ||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] | ||
pub struct UpdateTodoSchema { | ||
/// The title of the todo, can be `null` to keep the original title | ||
#[schema(example = "Todo title")] | ||
pub title: Option<String>, | ||
/// The status of the todo, can be `null` to keep the original status | ||
#[schema(value_type = Option<String>, example = "completed")] | ||
pub status: Option<TodoStatus>, | ||
} | ||
|
||
impl Default for UpdateTodoSchema { | ||
fn default() -> Self { | ||
Self { | ||
title: Some("Todo title".to_string()), | ||
status: None, | ||
} | ||
} | ||
} |