Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SchemaProcessor ¶
type SchemaProcessor struct{}
SchemaProcessor handles OpenAPI schema generation with flexible multipart form support
Supported tags for multipart form control:
Field-level tags:
- `upload:"file|binary"` - Force field to be treated as binary file upload
- `upload:"text"` - Force field to be treated as text input in multipart form
- `format:"binary"` - Mark field as binary (same as upload:"file")
- `mime:"type"` - Specify MIME type (binary if not text/json/xml)
- `required:"true"` - Mark field as required
- `optional:"true"` - Mark field as optional (overrides auto-detection)
- `doc:"description"` - Field description for OpenAPI
Body-level tags:
- `contentType:"multipart/form-data"` - Force multipart form (overrides auto-detection)
- `contentType:"application/json"` - Force JSON (disables auto-detection)
Auto-detection rules (when no explicit contentType is set):
- Explicit upload/format tags take precedence
- MIME type tags indicating non-text content
- Common file field names (file, upload, attachment, image, etc.) with string/[]byte types
- []byte fields are always treated as binary in multipart forms
Examples:
type FileUpload struct {
Body struct {
File string `json:"file" format:"binary"` // Binary file
Document string `json:"doc" upload:"file"` // Binary file
Description string `json:"desc" upload:"text"` // Text field
Avatar string `json:"avatar" mime:"image/png"` // Binary by MIME
Resume []byte `json:"resume"` // Auto-detected binary
Optional string `json:"tags" optional:"true"` // Optional field
} `contentType:"multipart/form-data"` // Explicit multipart
}
func NewSchemaProcessor ¶
func NewSchemaProcessor() *SchemaProcessor
NewSchemaProcessor creates a new schema processor
func (*SchemaProcessor) ProcessOperation ¶
func (p *SchemaProcessor) ProcessOperation(operation *huma.Operation, api huma.API, inputType, outputType reflect.Type, deps []*core.DependencyCore) error
ProcessOperation processes an operation like huma.Register does
Click to show internal directories.
Click to hide internal directories.