Documentation
¶
Overview ¶
Package decode is how apikit reads an op's input and checks its output, against the schemas huma generates from the Go types. It is internal to apikit: hosts and their ops never see huma's validator or the message rules.
It owns huma's process-wide configuration, set in init. apikit imports this package, so the settings are in place before any schema is generated.
Index ¶
- func CheckOutput(reg huma.Registry, t reflect.Type, out any) error
- func ExactlyOne(fields []string) []*huma.Schema
- func Input[In any](reg huma.Registry, raw []byte) (In, error)
- func InputTo[In any](reg huma.Registry, schema *huma.Schema, raw []byte) (In, error)
- func IsEmpty(t reflect.Type) bool
- func SchemaOf(reg huma.Registry, t reflect.Type) *huma.Schema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckOutput ¶
CheckOutput reports where out does not match the schema of type t: a nil slice encoded as null where the schema says list, an empty required field, an out-of-enum value. The op layer calls it in strict mode, so the OpenAPI built from the types cannot quietly lie about what an op returns.
func ExactlyOne ¶
ExactlyOne is the schema of a group of fields of which exactly one must be set, for an object's schema to carry in OneOf (or, for several groups, one per AllOf entry): a oneOf over each field being required. A JSON Schema reader sees the rule; apikit reads the group back from it, to say which fields to set.
func Input ¶
Input validates raw against In's schema and decodes it. Structural problems are invalid_request, with one violation per location; a field path is the caller's (`invitations[1].role`), with no transport prefix. An empty body is an empty object, so an op whose fields are all optional can be called with none.
func InputTo ¶
InputTo is Input against a schema given rather than reflected from In: an engine command's, built from what the engine describes at run time, with In a map of its args.
func SchemaOf ¶
SchemaOf is t's schema: a reference into reg for a named type, which reg registers under the type's name. The empty struct — an op with no input or no output — has no name to register under, so its schema is an inline empty object rather than a nameless entry: a reference to "#/components/schemas/" with no name would resolve to the whole map. Any other unnamed struct is refused at registration (apikit.Register), for the same reason.
Types ¶
This section is empty.