-
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.
Add openapi spec for generated blueprint
- Loading branch information
Showing
9 changed files
with
148 additions
and
51 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
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 |
---|---|---|
@@ -1,16 +1,25 @@ | ||
use axum::response::Json; | ||
use serde::{Deserialize, Serialize}; | ||
use payloads::*; | ||
|
||
/// A greeting to respond with to the requesting client | ||
#[derive(Deserialize, Serialize)] | ||
pub struct Greeting { | ||
/// Who do we say hello to? | ||
pub hello: String, | ||
} | ||
pub const OPENAPI_TAG: &str = "Greeting"; | ||
|
||
/// Responds with a [`Greeting`], encoded as JSON. | ||
pub async fn hello() -> Json<Greeting> { | ||
Json(Greeting { | ||
/// Responds with a [`HelloResponse`], encoded as JSON. | ||
#[utoipa::path(get, path = "/tasks", tag = OPENAPI_TAG, responses( | ||
(status = OK, description = "Hello there!", body = HelloResponse) | ||
))] | ||
pub async fn hello() -> Json<HelloResponse> { | ||
Json(HelloResponse { | ||
hello: String::from("world"), | ||
}) | ||
} | ||
|
||
mod payloads { | ||
/// A greeting to respond with to the requesting client | ||
#[derive(serde::Serialize)] | ||
#[derive(utoipa::ToSchema)] | ||
#[derive(Debug)] | ||
pub struct HelloResponse { | ||
/// Who do we say hello to? | ||
pub hello: String, | ||
} | ||
} |
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