Skip to content

Commit 143e2c7

Browse files
authored
Merge pull request #69 from dev-five-git/refactor-2
Refactor 2
2 parents 5a314e7 + 5d4a621 commit 143e2c7

81 files changed

Lines changed: 18887 additions & 8364 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespera/Cargo.toml":"Patch","crates/vespera_macro/Cargo.toml":"Patch","crates/vespera_core/Cargo.toml":"Patch"},"note":"Support serde flatten","date":"2026-02-05T04:33:01.526326100Z"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"crates/vespera_core/Cargo.toml":"Patch","crates/vespera/Cargo.toml":"Patch","crates/vespera_macro/Cargo.toml":"Patch"},"note":"Support serde flatten, tagged, untagged","date":"2026-02-05T12:30:36.574038700Z"}

.claude/settings.local.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ lcov.info
33
coverage
44
build_rs_cov.profraw
55
.sisyphus/
6+
/docs
7+
.claude
8+
.DS_Store
9+
coverage-report

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vespera_core/src/schema.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ pub struct Schema {
183183
#[serde(skip_serializing_if = "Option::is_none")]
184184
pub not: Option<Box<SchemaRef>>,
185185

186+
/// Discriminator for polymorphic schemas (used with oneOf/anyOf/allOf)
187+
#[serde(skip_serializing_if = "Option::is_none")]
188+
pub discriminator: Option<Discriminator>,
189+
186190
/// Nullable flag
187191
#[serde(skip_serializing_if = "Option::is_none")]
188192
pub nullable: Option<bool>,
@@ -246,6 +250,7 @@ impl Schema {
246250
any_of: None,
247251
one_of: None,
248252
not: None,
253+
discriminator: None,
249254
nullable: None,
250255
read_only: None,
251256
write_only: None,
@@ -305,6 +310,20 @@ pub struct ExternalDocumentation {
305310
pub url: String,
306311
}
307312

313+
/// Discriminator object for polymorphism support (OpenAPI 3.0/3.1)
314+
///
315+
/// Used with `oneOf`, `anyOf`, `allOf` to aid in serialization, deserialization,
316+
/// and validation when request bodies or response payloads may be one of several types.
317+
#[derive(Debug, Clone, Serialize, Deserialize)]
318+
#[serde(rename_all = "camelCase")]
319+
pub struct Discriminator {
320+
/// The name of the property in the payload that will hold the discriminator value
321+
pub property_name: String,
322+
/// An object to hold mappings between payload values and schema names or references
323+
#[serde(skip_serializing_if = "Option::is_none")]
324+
pub mapping: Option<BTreeMap<String, String>>,
325+
}
326+
308327
/// OpenAPI Components (reusable components)
309328
#[derive(Debug, Clone, Serialize, Deserialize)]
310329
#[serde(rename_all = "camelCase")]

crates/vespera_macro/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ proc-macro2 = "1"
1717
vespera_core = { workspace = true }
1818
serde = { version = "1.0", features = ["derive"] }
1919
serde_json = "1.0"
20-
anyhow = "1.0"
2120

2221
[dev-dependencies]
2322
rstest = "0.26"

crates/vespera_macro/src/args.rs

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::http::is_http_method;
2+
13
pub struct RouteArgs {
24
pub method: Option<syn::Ident>,
35
pub path: Option<syn::LitStr>,
@@ -22,33 +24,26 @@ impl syn::parse::Parse for RouteArgs {
2224
// Try to parse as method identifier (get, post, etc.)
2325
let ident: syn::Ident = input.parse()?;
2426
let ident_str = ident.to_string().to_lowercase();
25-
match ident_str.as_str() {
26-
"get" | "post" | "put" | "patch" | "delete" | "head" | "options" => {
27-
method = Some(ident);
28-
}
29-
"path" => {
30-
input.parse::<syn::Token![=]>()?;
31-
let lit: syn::LitStr = input.parse()?;
32-
path = Some(lit);
33-
}
34-
"error_status" => {
35-
input.parse::<syn::Token![=]>()?;
36-
let array: syn::ExprArray = input.parse()?;
37-
error_status = Some(array);
38-
}
39-
"tags" => {
40-
input.parse::<syn::Token![=]>()?;
41-
let array: syn::ExprArray = input.parse()?;
42-
tags = Some(array);
43-
}
44-
"description" => {
45-
input.parse::<syn::Token![=]>()?;
46-
let lit: syn::LitStr = input.parse()?;
47-
description = Some(lit);
48-
}
49-
_ => {
50-
return Err(lookahead.error());
51-
}
27+
if is_http_method(&ident_str) {
28+
method = Some(ident);
29+
} else if ident_str == "path" {
30+
input.parse::<syn::Token![=]>()?;
31+
let lit: syn::LitStr = input.parse()?;
32+
path = Some(lit);
33+
} else if ident_str == "error_status" {
34+
input.parse::<syn::Token![=]>()?;
35+
let array: syn::ExprArray = input.parse()?;
36+
error_status = Some(array);
37+
} else if ident_str == "tags" {
38+
input.parse::<syn::Token![=]>()?;
39+
let array: syn::ExprArray = input.parse()?;
40+
tags = Some(array);
41+
} else if ident_str == "description" {
42+
input.parse::<syn::Token![=]>()?;
43+
let lit: syn::LitStr = input.parse()?;
44+
description = Some(lit);
45+
} else {
46+
return Err(lookahead.error());
5247
}
5348

5449
// Check if there's a comma
@@ -74,9 +69,10 @@ impl syn::parse::Parse for RouteArgs {
7469

7570
#[cfg(test)]
7671
mod tests {
77-
use super::*;
7872
use rstest::rstest;
7973

74+
use super::*;
75+
8076
#[rstest]
8177
// Method only
8278
#[case("get", true, Some("get"), None, None)]

0 commit comments

Comments
 (0)