Skip to content

Commit

Permalink
Add support for new types (#10)
Browse files Browse the repository at this point in the history
* add support for new types

add support for:
- isize
- u8
- i8
- bigdecimal::BigDecimal (enabled by feature flag)

* Bump version patch to 0.18.1
  • Loading branch information
s-fabian authored Dec 25, 2023
1 parent d17f198 commit 1843a55
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
4 changes: 3 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oasgen-core"
version = "0.18.0"
version = "0.18.1"
edition = "2021"
authors = ["Kurt Wolf <[email protected]>"]
description = "Dependency of oasgen. Generates OpenAPI 3.0 spec based on Rust code. Works with actix-web, but architected to easily extend to other frameworks (or no framework)."
Expand Down Expand Up @@ -30,6 +30,7 @@ sqlx-core = { version = "0.7", optional = true }
tower-cookies = { version = "0.9.0", optional = true }
sid2 = { version = "0.4.0", optional = true }
serde_qs = { version = "0.12", optional = true }
bigdecimal = { version = "0.4.2", optional = true }

[features]
actix = ["actix-web", "serde_qs?/actix4"]
Expand All @@ -38,6 +39,7 @@ cookies = ["tower-cookies"]
qs = ["serde_qs"]
sid = ["sid2"]
axum = ["dep:axum", "serde_qs?/axum"]
bigdecimal = ["dep:bigdecimal"]

[dev-dependencies]
assert_matches = "1.5.0"
14 changes: 12 additions & 2 deletions core/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ mod time;
mod http;
#[cfg(feature = "sid")]
mod sid;
#[cfg(feature = "bigdecimal")]
mod bigdecimal;
mod tuple;

pub trait OaSchema {
Expand Down Expand Up @@ -84,12 +86,20 @@ impl OaSchema for () {
impl_oa_schema!(bool, Schema::new_bool());

impl_oa_schema!(usize, Schema::new_integer());
impl_oa_schema!(isize, Schema::new_integer());

impl_oa_schema!(u8, Schema::new_integer());
impl_oa_schema!(i8, Schema::new_integer());

impl_oa_schema!(u16, Schema::new_integer());
impl_oa_schema!(i16, Schema::new_integer());

impl_oa_schema!(u32, Schema::new_integer());
impl_oa_schema!(i32, Schema::new_integer());

impl_oa_schema!(u64, Schema::new_integer());
impl_oa_schema!(i64, Schema::new_integer());
impl_oa_schema!(u16, Schema::new_integer());
impl_oa_schema!(i16, Schema::new_integer());

impl_oa_schema!(f32, Schema::new_number());
impl_oa_schema!(f64, Schema::new_number());

Expand Down
3 changes: 3 additions & 0 deletions core/src/schema/bigdecimal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use crate::{impl_oa_schema, Schema};

impl_oa_schema!(::bigdecimal::BigDecimal, Schema::new_integer());
4 changes: 2 additions & 2 deletions macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oasgen-macro"
version = "0.18.0"
version = "0.18.1"
edition = "2021"
authors = ["Kurt Wolf <[email protected]>"]
description = "Dependency of oasgen. Generates OpenAPI 3.0 spec based on Rust code. Works with actix-web, but architected to easily extend to other frameworks (or no framework)."
Expand All @@ -18,7 +18,7 @@ proc-macro = true
syn = { version = "2", features = ["full"] }
quote = "1.0"
proc-macro2 = "1.0.64"
oasgen-core = { path = "../core" , version = "0.18.0"}
oasgen-core = { path = "../core" , version = "0.18.1"}
structmeta = "0.2.0"
serde_derive_internals = "0.29.0"

Expand Down
7 changes: 4 additions & 3 deletions oasgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oasgen"
version = "0.18.0"
version = "0.18.1"
edition = "2021"
authors = ["Kurt Wolf <[email protected]>"]
description = "Generates OpenAPI 3.0 spec based on Rust code. Works with axum, actix-web, or independent of a web framework."
Expand Down Expand Up @@ -45,8 +45,8 @@ futures = "0.3.28"
http = "0.2.9"
indexmap = "2"
openapiv3-extended = { version = "4" }
oasgen-core = { path = "../core", version = "0.18.0"}
oasgen-macro = { path = "../macro", version = "0.18.0"}
oasgen-core = { path = "../core", version = "0.18.1"}
oasgen-macro = { path = "../macro", version = "0.18.1"}
serde = { version = "1.0.171", features = ["derive"] }
serde_json = "1.0.100"
serde_yaml = "0.9.22"
Expand All @@ -69,6 +69,7 @@ cookies = ["tower-cookies", "oasgen-core/cookies"]
phonenumber = ["oasgen-core/phonenumber"]
sid = ["oasgen-core/sid"]
serde_qs = ["oasgen-core/qs"]
bigdecimal = ["oasgen-core/bigdecimal"]

[dev-dependencies]
trybuild = "1.0.81"
Expand Down

0 comments on commit 1843a55

Please sign in to comment.