Skip to content

Commit

Permalink
feat: add bigdecimal support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilerd committed Jan 29, 2025
1 parent 2b80e7f commit c554aae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions gotcha_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ regex = "1.7.1"
serde_json = "1"
axum = {version = "0.7", default-features = false, features = ["form", "json", "query"]}
either = "1.13.0"
bigdecimal = "0.4"
18 changes: 18 additions & 0 deletions gotcha_core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::BTreeMap;

use axum::extract::{Json, Path, Query, Request, State};
use bigdecimal::BigDecimal;
use either::Either;
use oas::{MediaType, Parameter, ParameterIn, Referenceable, RequestBody, Schema};

Expand Down Expand Up @@ -122,6 +123,21 @@ impl<T: Schematic> Schematic for Vec<T> {
}
}


impl Schematic for BigDecimal {
fn name() -> &'static str {
"string"
}

fn required() -> bool {
true
}

fn type_() -> &'static str {
"string"
}
}

fn build_param(name: String, _in: ParameterIn, required: bool, schema: Schema, description: Option<String>) -> Parameter {
Parameter {
name,
Expand Down Expand Up @@ -248,3 +264,5 @@ impl ParameterProvider for Request {
Either::Left(vec![])
}
}


0 comments on commit c554aae

Please sign in to comment.