Documentation
¶
Index ¶
- func ApplyToOperation(op huma.Operation, handlers ...OperationHandler) huma.Operation
- func ApplyToOperationPtr(op *huma.Operation, handlers ...OperationHandler)
- func SetHidden(isHidden bool, override bool) func(o *huma.Operation)
- func SetSummary(summary string, override bool) func(o *huma.Operation)
- func UpdateGeneratedSummary(op *huma.Operation)
- type OperationHandler
- func AddBasePath(basePath string) OperationHandler
- func AddMiddlewares(middlewares ...func(huma.Context, func(huma.Context))) OperationHandler
- func AddSecurity(securityEntries ...map[string][]string) OperationHandler
- func AddTags(tags ...string) OperationHandler
- func AppendDescription(separator string, parts ...string) OperationHandler
- func GenerateOperationID(override bool) OperationHandler
- func GenerateSummary(override bool) OperationHandler
- func If(condition func(op *huma.Operation) bool, handlers ...OperationHandler) OperationHandler
- func SetBodyReadTimeout(timeout time.Duration, override bool) OperationHandler
- func SetDeprecated(deprecated bool, override bool) OperationHandler
- func SetDescription(description string, override bool) OperationHandler
- func SetExtensionsKey(key string, value any, override bool) OperationHandler
- func SetExternalDocs(externalDocs *huma.ExternalDocs, override bool) OperationHandler
- func SetMaxBodyBytes(n int64, override bool) OperationHandler
- func SetMetadataKey(key string, value any, override bool) OperationHandler
- func SetResponse(statusCode int, response *huma.Response, override bool) OperationHandler
- func SetSkipValidateBody(skipValidateBody bool, override bool) OperationHandler
- func SetSkipValidateParams(skipValidateParams bool, override bool) OperationHandler
- func UpdateOperationID(explicitOpIDBuilder func(*huma.Operation) string) OperationHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyToOperation ¶
func ApplyToOperation(op huma.Operation, handlers ...OperationHandler) huma.Operation
ApplyToOperation is a helper method to apply multiple OperationHandlers to an Operation, returning the modified Operation.
func ApplyToOperationPtr ¶
func ApplyToOperationPtr(op *huma.Operation, handlers ...OperationHandler)
ApplyToOperationPtr is a helper method to apply multiple OperationHandlers to an Operation pointer.
func SetHidden ¶
SetHidden sets the Hidden field of the operation to the given value. If `override` is false and the operation already has Hidden set to true, it will not be changed.
func SetSummary ¶
SetSummary creates an OperationHandler that sets the Summary field on the operation. If override is `false`, it will not override the existing summary. If summary is set, it also sets the metadata key metadata.KeyIsExplicitSummary to true to inform next handlers that summary was set explicitly and should not be re-generated
func UpdateGeneratedSummary ¶
UpdateGeneratedSummary creates an OperationHandler that re-generates the Summary field on the operation if it is not explicitly set.
Types ¶
type OperationHandler ¶
func AddBasePath ¶
func AddBasePath(basePath string) OperationHandler
AddBasePath creates an OperationHandler that sets the base path (path prefix) for the operation. It updates operation`s Path and metadata.KeyBasePath.
func AddMiddlewares ¶
func AddMiddlewares(middlewares ...func(huma.Context, func(huma.Context))) OperationHandler
AddMiddlewares creates an OperationHandler that appends the given middlewares to the operation's Middlewares field.
func AddSecurity ¶
func AddSecurity(securityEntries ...map[string][]string) OperationHandler
AddSecurity creates an OperationHandler that appends the given security entries to the operation's AddSecurity field.
func AddTags ¶
func AddTags(tags ...string) OperationHandler
AddTags creates an OperationHandler that appends the given tags to the operation's Tags field. If a tag is already present, it will not be duplicated.
func AppendDescription ¶
func AppendDescription(separator string, parts ...string) OperationHandler
AppendDescription creates an OperationHandler that appends provided `parts` to the Description field of an operation separating them with `separator`.
func GenerateOperationID ¶
func GenerateOperationID(override bool) OperationHandler
GenerateOperationID creates an OperationHandler that sets the OperationID for the operation in a way Huma does it by default. If override is `false`, it will not override existing OperationID. It's supposed to be used internally by the library, but you can use it in your registration pipeline with override == false to initialize explicitly provided operations with not specified OperationID.
func GenerateSummary ¶
func GenerateSummary(override bool) OperationHandler
GenerateSummary creates an OperationHandler that generates a summary for the operation in a way Huma does it by default. If override is `false`, it will not override existing Summary. It's supposed to be used internally by the library, but you can use it in your registration pipeline with override == false to initialize explicitly provided operations with not specified Summary.
func If ¶
func If( condition func(op *huma.Operation) bool, handlers ...OperationHandler, ) OperationHandler
If creates an OperationHandler that applies the given handlers if the condition is true. It's a helper method to avoid creating a separate OperationHandlers with condition checks.
func SetBodyReadTimeout ¶
func SetBodyReadTimeout(timeout time.Duration, override bool) OperationHandler
SetBodyReadTimeout creates an OperationHandler that sets operation`s BodyReadTimeout field. If override is `false`, it will not override existing non-zero value.
func SetDeprecated ¶
func SetDeprecated(deprecated bool, override bool) OperationHandler
SetDeprecated creates an OperationHandler that sets operation`s Deprecated field. If override is `false`, it will not override existing `true` value.
func SetDescription ¶
func SetDescription(description string, override bool) OperationHandler
SetDescription creates an OperationHandler that sets the Description field of an operation If override is `false`, it will not override the existing description.
func SetExtensionsKey ¶
func SetExtensionsKey(key string, value any, override bool) OperationHandler
SetExtensionsKey creates an OperationHandler that adds a key to the operation`s Extensions field. If override is `false`, it will not override existing key.
func SetExternalDocs ¶
func SetExternalDocs(externalDocs *huma.ExternalDocs, override bool) OperationHandler
SetExternalDocs returns an OperationHandler that sets ExternalDocs field of an operation. If override is `false` and the operation already has ExternalDocs, it will not be overridden.
func SetMaxBodyBytes ¶
func SetMaxBodyBytes(n int64, override bool) OperationHandler
SetMaxBodyBytes creates an OperationHandler that sets the operation's MaxBodyBytes field to the given value. If override is `false`, it will not override existing non-zero MaxBodyBytes.
func SetMetadataKey ¶
func SetMetadataKey(key string, value any, override bool) OperationHandler
SetMetadataKey creates an OperationHandler that sets the metadata key for the operation If override is `false`, it will not override the existing key.
func SetResponse ¶
func SetResponse(statusCode int, response *huma.Response, override bool) OperationHandler
func SetSkipValidateBody ¶
func SetSkipValidateBody(skipValidateBody bool, override bool) OperationHandler
SetSkipValidateBody creates an OperationHandler that sets the SkipValidateBody field on the operation. If override is `false`, it will not override the existing `true` value.
func SetSkipValidateParams ¶
func SetSkipValidateParams(skipValidateParams bool, override bool) OperationHandler
SetSkipValidateParams creates an OperationHandler that sets the SkipValidateParams field on the operation. If override is `false`, it will not override the existing `true` value.
func UpdateOperationID ¶
func UpdateOperationID( explicitOpIDBuilder func(*huma.Operation) string, ) OperationHandler
UpdateOperationID creates an OperationHandler that re-generates the OperationID field on the operation. It does not re-generates OperationID if it's empty If OperationID is not explicitly set, it generates it from the path (in the same way as huma does it by default). If OperationID is explicitly set, it will be updated by the provided `explicitOpIDBuilder`. If `explicitOpIDBuilder` is nil, the following approach will be used for operations with explicitly set OperationID: It will take metadata.KeyBasePath as a prefix for the OperationID, turning it into kebab-case and will append it to the metadata.KeyInitOperationID It's used internally by the library after registration of multiple base paths to make OperationID unique for different base paths and normally should not be used directly.
Source Files
¶
- add_base_path.go
- add_security.go
- add_tags.go
- append_description.go
- generate_operation_id.go
- generate_summary.go
- if.go
- middlewares.go
- operation_handler.go
- set_body_read_timeout.go
- set_deprecated.go
- set_description.go
- set_extensions_key.go
- set_external_docs.go
- set_hidden.go
- set_max_body_bytes.go
- set_metadata_key.go
- set_response.go
- set_skip_validate_body.go
- set_skip_validate_params.go
- set_summary.go
- update_generated_summary.go
- update_operation_id.go