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" }`.
188
+
189
+
> **Note:**`axum` must be a direct dependency of your project (not just via vespera) because `TryFromMultipart` internally references `axum::extract::multipart::Multipart`.
190
+
165
191
### Error Handling
166
192
167
193
```rust
@@ -347,6 +373,30 @@ vespera::schema_type!(Schema from Model, name = "MemoSchema");
347
373
348
374
**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
375
376
+
### Multipart Mode
377
+
378
+
Generate `TryFromMultipart` structs from existing types using the `multipart` keyword:
379
+
380
+
```rust
381
+
#[derive(TryFromMultipart, vespera::Schema)]
382
+
pubstructCreateUploadRequest {
383
+
pubname:String,
384
+
#[form_data(limit ="10MiB")]
385
+
pubfile:Option<FieldData<NamedTempFile>>,
386
+
pubdescription:Option<String>,
387
+
}
388
+
389
+
// Generates a TryFromMultipart struct (no serde derives), all fields Optional
| Field attrs |`#[serde(...)]` preserved |`#[form_data(...)]` preserved |
462
+
| Relation fields | Included (BelongsTo/HasOne) |**Skipped** (can't represent in forms) |
463
+
|`From` impl | Auto-generated |**Not generated**|
464
+
465
+
**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