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
Vespera automatically generates `multipart/form-data` content type in OpenAPI, and maps `FieldData<NamedTempFile>` to `{ "type": "string", "format": "binary" }`.
191
+
192
+
> **Note:**`axum` must be a direct dependency of your project (not just via vespera) because `TryFromMultipart` internally references `axum::extract::multipart::Multipart`.
193
+
194
+
#### Raw Multipart (Untyped)
195
+
196
+
For dynamic multipart handling where the fields aren't known at compile time, use axum's built-in `Multipart` extractor:
This generates a `multipart/form-data` request body with a generic `{ "type": "object" }` schema in OpenAPI, since the fields are not statically known.
213
+
165
214
### Error Handling
166
215
167
216
```rust
@@ -347,6 +396,30 @@ vespera::schema_type!(Schema from Model, name = "MemoSchema");
347
396
348
397
**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.
349
398
399
+
### Multipart Mode
400
+
401
+
Generate `TryFromMultipart` structs from existing types using the `multipart` keyword:
402
+
403
+
```rust
404
+
#[derive(TryFromMultipart, vespera::Schema)]
405
+
pubstructCreateUploadRequest {
406
+
pubname:String,
407
+
#[form_data(limit ="10MiB")]
408
+
pubfile:Option<FieldData<NamedTempFile>>,
409
+
pubdescription:Option<String>,
410
+
}
411
+
412
+
// Generates a TryFromMultipart struct (no serde derives), all fields Optional
| Field attrs |`#[serde(...)]` preserved |`#[form_data(...)]` preserved |
463
+
| Relation fields | Included (BelongsTo/HasOne) |**Skipped** (can't represent in forms) |
464
+
|`From` impl | Auto-generated |**Not generated**|
465
+
466
+
**OpenAPI rename alignment:** The schema parser reads `#[form_data(field_name = "...")]` and `#[try_from_multipart(rename_all = "...")]` as fallbacks when serde attrs are absent, ensuring OpenAPI field names match runtime multipart parsing.
0 commit comments