diff --git a/README.md b/README.md index 2c861ee..505d5e3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # rupring -![](https://img.shields.io/badge/language-Rust-red) ![](https://img.shields.io/badge/version-0.10.0-brightgreen) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/myyrakle/rupring/blob/master/LICENSE) +![](https://img.shields.io/badge/language-Rust-red) ![](https://img.shields.io/badge/version-0.11.0-brightgreen) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/myyrakle/rupring/blob/master/LICENSE) Spring Comes to Rust ## Get Started required dependency list + ```toml -rupring = "0.9.1" +rupring = "0.11.0" serde = { version="1.0.193", features=["derive"] } ``` diff --git a/rupring/Cargo.toml b/rupring/Cargo.toml index 802e2e7..ce6d83a 100644 --- a/rupring/Cargo.toml +++ b/rupring/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rupring" -version = "0.10.0" +version = "0.11.0" edition = "2021" license = "MIT" authors = ["myyrakle "] @@ -14,7 +14,7 @@ homepage = "https://github.com/myyrakle/rupring/blob/master/README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rupring_macro={ version="0.8.2", path="../rupring_macro" } +rupring_macro={ version="0.11.0", path="../rupring_macro" } hyper = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] } http-body-util = "0.1.0" diff --git a/rupring/src/lib.rs b/rupring/src/lib.rs index 1418b4b..ed37830 100644 --- a/rupring/src/lib.rs +++ b/rupring/src/lib.rs @@ -445,8 +445,8 @@ impl RupringFactory { } } -/// RupringDoc derive macro -pub use rupring_macro::RupringDoc; +/// RupringDto derive macro +pub use rupring_macro::RupringDto; #[cfg(test)] mod test_proc_macro; diff --git a/rupring/src/swagger/mod.rs b/rupring/src/swagger/mod.rs index 9b1d5e7..befe10d 100644 --- a/rupring/src/swagger/mod.rs +++ b/rupring/src/swagger/mod.rs @@ -17,12 +17,12 @@ pub fn echo( } ``` -Using the RupringDoc derive macro, you can perform document definition for Request Parameter. +Using the RupringDto derive macro, you can perform document definition for Request Parameter. ```rust -use rupring::RupringDoc; +use rupring::RupringDto; use serde::{Deserialize, Serialize}; -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct CreateUserRequest { #[desc = "user name"] #[example = "foobar"] @@ -35,7 +35,7 @@ pub struct CreateUserRequest { pub password: String, } ``` -### RupringDoc attribute Details +### RupringDto attribute Details 1. `#[desc = ""]` or `#[description = ""]`: Description of the field. 2. `#[example = ""]`: Example value of the field. 3. `#[name = "id"]`: If the field name is different from the variable name, you can add this annotation. @@ -46,10 +46,10 @@ pub struct CreateUserRequest { Then, you can specify request information in the API through the params attribute as follows. ```rust -use rupring::RupringDoc; +use rupring::RupringDto; use serde::{Deserialize, Serialize}; -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct CreateUserRequest { #[desc = "user name"] #[example = "foobar"] @@ -73,12 +73,12 @@ pub fn create_user(request: rupring::Request, _: rupring::Response) -> rupring:: } ``` -Response documentation can also be defined through the RupringDoc macro and response attribute. +Response documentation can also be defined through the RupringDto macro and response attribute. ```rust -use rupring::RupringDoc; +use rupring::RupringDto; use serde::{Deserialize, Serialize}; -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct GetUserResponse { pub id: i32, pub username: String, @@ -96,10 +96,10 @@ pub fn get_user(request: rupring::Request, _: rupring::Response) -> rupring::Res If you want to activate BearerAuth for the API, activate the auth attribute as follows. (The default is BearerAuth. ```rust -use rupring::RupringDoc; +use rupring::RupringDto; use serde::{Deserialize, Serialize}; -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct GetUserResponse { pub id: i32, pub username: String, diff --git a/rupring_example/src/domains/users/dto.rs b/rupring_example/src/domains/users/dto.rs index f29ece1..98431ed 100644 --- a/rupring_example/src/domains/users/dto.rs +++ b/rupring_example/src/domains/users/dto.rs @@ -1,17 +1,17 @@ -use rupring::RupringDoc; +use rupring::RupringDto; use serde::{Deserialize, Serialize}; pub mod foo { - use rupring::RupringDoc; + use rupring::RupringDto; use serde::{Deserialize, Serialize}; - #[derive(Debug, Serialize, Deserialize, RupringDoc)] + #[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct Bar { pub a: i32, pub b: String, } } -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct CreateUserRequest { #[desc = "user name"] #[example = "foobar"] @@ -27,7 +27,7 @@ pub struct CreateUserRequest { #[derive(Debug, Serialize, Deserialize)] pub struct CreateUserResponse {} -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct UpdateUserRequest { #[serde(skip_serializing)] #[path_param = "id"] @@ -55,14 +55,14 @@ pub struct GetUserRequest { pub id: i32, } -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct GetUserResponse { pub id: i32, pub username: String, pub email: String, } -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct ListUsersRequest { #[query = "offset"] pub offset: i32, @@ -70,7 +70,7 @@ pub struct ListUsersRequest { pub limit: i32, } -#[derive(Debug, Serialize, Deserialize, RupringDoc)] +#[derive(Debug, Serialize, Deserialize, RupringDto)] pub struct ListUsersResponse { pub users: Vec, pub total: i32, diff --git a/rupring_macro/Cargo.toml b/rupring_macro/Cargo.toml index 77a6732..62ba021 100644 --- a/rupring_macro/Cargo.toml +++ b/rupring_macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rupring_macro" -version = "0.8.2" +version = "0.11.1" edition = "2021" description = "rupring macro" license = "MIT" diff --git a/rupring_macro/src/lib.rs b/rupring_macro/src/lib.rs index 1f78b66..943fe83 100644 --- a/rupring_macro/src/lib.rs +++ b/rupring_macro/src/lib.rs @@ -595,7 +595,7 @@ pub fn PatchMapping(attr: TokenStream, item: TokenStream) -> TokenStream { } /** -## What is RupringDoc? +## What is RupringDto? - This is a macro used to automatically generate Swagger documents. - It also provides functions such as Request Validation. @@ -611,7 +611,7 @@ pub fn PatchMapping(attr: TokenStream, item: TokenStream) -> TokenStream { 9. ignore: Ignore the field. */ #[proc_macro_derive( - RupringDoc, + RupringDto, attributes( example, description, @@ -625,7 +625,7 @@ pub fn PatchMapping(attr: TokenStream, item: TokenStream) -> TokenStream { ignore, ) )] -pub fn derive_rupring_doc(item: TokenStream) -> TokenStream { +pub fn derive_rupring_dto(item: TokenStream) -> TokenStream { let ast = syn::parse_macro_input!(item as syn::ItemStruct); let struct_name = parse::find_struct_name(&ast);