You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -441,6 +441,57 @@ vespera::schema_type!(Schema from Model, name = "MemoSchema");
441
441
442
442
**Circular Reference Handling:** When schemas reference each other (e.g., User ↔ Memo), the macro automatically detects and handles circular references by inlining fields to prevent infinite recursion.
443
443
444
+
### Same-File Relation Adapters
445
+
446
+
For response DTOs that live in the same route file, `schema_type!` can now keep the handler code unchanged even when a SeaORM relation should be exposed through a custom local DTO.
-`schema_type!` looks for same-file DTOs named `{RelationNamePascal}In{ResponseBase}`
487
+
-`user` on `ArticleResponse` → `UserInArticle`
488
+
-`category` on `ArticleResponse` → `CategoryInArticle`
489
+
- It generates local compile adapters so `Option<Model>.into()` works unchanged in the handler
490
+
- Those adapters stay internal to Rust typing
491
+
- OpenAPI does **not** expose the generated adapter wrapper names; the spec still points at the original related schemas (`UserSchema`, `CategorySchema`)
492
+
493
+
Use this when you want route-local response DTOs for single-value relations (`HasOne` / `BelongsTo`) without rewriting the route construction logic.
494
+
444
495
### Multipart Mode
445
496
446
497
Generate `Multipart` structs from existing types using the `multipart` keyword:
Copy file name to clipboardExpand all lines: SKILL.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -397,6 +397,55 @@ vespera::schema_type!(Schema from Model, name = "MemoSchema");
397
397
398
398
**Required Logic:**`required` is determined **solely by nullability** (`Option<T>`). Fields with `#[serde(default)]` or `#[serde(skip_serializing_if)]` are still `required` unless they are `Option<T>`.
399
399
400
+
### Same-File Relation Adapters
401
+
402
+
When a route file defines a local response DTO for a relation, Vespera can preserve unchanged handler code while still generating the right OpenAPI.
0 commit comments