Documentation
¶
Overview ¶
Package fixture mirrors auditor3's runs module for openapi reflector tests.
Index ¶
- Variables
- type BadTag
- type BadValue
- type Collections
- type Config
- type ConflictA
- type ConflictB
- type ContentEncodingProp
- type CreateRequest
- type DefaultParam
- type DefaultTag
- type DuplicateParam
- type EchoParam
- type EmbeddedAndNested
- type EmbeddedMap
- type EmbeddedSlice
- type EnumKey
- type EnumValue
- type Extras
- type Flags
- type FlagsRequest
- type FormatOnEmail
- type FormatOnInt
- type FormatOnString
- type FormatOnTime
- type FormatOnUUID
- type HiddenField
- type HiddenParam
- type HiddenResponse
- type Inner
- type JSONStampedRun
- type ListRequest
- type ListResponse
- type Meta
- type MissingDash
- type Mode
- type NestedBad
- type NestedEnumKey
- type NestedFile
- type NestedFileHolder
- type NestedParam
- type NestedParamOptional
- type NestedParamSlice
- type NestedQuery
- type Node
- type NullableStruct
- type OptionalBadKeys
- type OptionalParam
- type OptionalPointer
- type OptionalRequest
- type OptionalResponse
- type OptionalWideBound
- type Page
- type Pair
- type PairInput
- type Run
- type RunStatus
- type ShadowedGoName
- type Slug
- type StampedRun
- type StampedRuns
- type StringOption
- type StructParam
- type Tags
- type TextStampedRun
- type Tree
- type UnexportedEmbed
- type UpdateRequest
- type WideBound
Constants ¶
This section is empty.
Variables ¶
var Modes = enums.Set([]Mode{"a", "b"})
var RunStatuses = enums.Set([]RunStatus{PendingStatus, RunningStatus, CompletedStatus, FailedStatus, CancelledStatus})
Functions ¶
This section is empty.
Types ¶
type BadTag ¶
type BadTag struct {
Count int `json:"count" minimun:"0"`
}
BadTag has a typo in a constraint tag.
type BadValue ¶
type BadValue struct {
N int `json:"n" minimum:"abc"`
}
BadValue has a constraint huma cannot parse (huma panics, we return an error).
type Collections ¶
type Collections struct {
M map[string]int `json:"m"`
S []int `json:"s"`
OM map[string]int `json:"om,omitempty"`
OS []int `json:"os,omitempty"`
ZM map[string]int `json:"zm,omitzero"`
ZS []int `json:"zs,omitzero"`
PM *map[string]int `json:"pm"`
PS *[]int `json:"ps"`
POM *map[string]int `json:"pom,omitempty"`
POS *[]int `json:"pos,omitempty"`
NM map[string]int `json:"nm" nullable:"false"`
NS []int `json:"ns" nullable:"false"`
RM *map[string]int `json:"rm" required:"true"`
RS *[]int `json:"rs" required:"true"`
XM types.Optional[map[string]int] `json:"xm"`
XS types.Optional[[]int] `json:"xs"`
}
Collections pairs each map field with a slice field under the same nullability rule (plain, omitempty, omitzero, pointer, pointer with omitempty, nullable:"false", required pointer, types.Optional): the map must be as nullable as the slice.
type Config ¶
type Config struct {
Retries int `json:"retries" minimum:"0"`
Timeout *int `json:"timeout,omitempty"`
Notify types.Email `json:"notify,omitempty"`
}
Config is used in both directions (Run response and CreateRequest).
type ConflictA ¶
type ConflictA struct {
X int `json:"x"`
}
ConflictA and ConflictB declare the same JSON name under different Go names.
type ConflictB ¶
type ConflictB struct {
Y int `json:"x" maximum:"5"`
}
ConflictB declares "x" as Y. The structs that combine the two (ConflictA and ConflictB embedded side by side, where encoding/json drops "x" while huma publishes it; a direct field tagged json:"x" next to an embedded ConflictB, where encoding/json binds the direct field while huma's schema describes ConflictB.Y) are built with reflect.StructOf in checks_test, since go vet rejects the repeated json tag in a declared type.
type ContentEncodingProp ¶
type ContentEncodingProp struct {
Encoding string `json:"contentEncoding"`
}
ContentEncodingProp has a property name huma's Downgrade renames.
type CreateRequest ¶
type CreateRequest struct {
Name string `json:"name" required:"true" minLength:"1"`
Config Config `json:"config"`
}
CreateRequest requires exactly name.
type DefaultParam ¶
type DefaultParam struct {
Limit int `json:"-" query:"limit" default:"20"`
}
DefaultParam documents a default on a query parameter.
type DefaultTag ¶
type DefaultTag struct {
Limit int `json:"limit,omitempty" default:"20"`
}
DefaultTag documents a default, which only a response may.
type DuplicateParam ¶
type DuplicateParam struct {
A string `json:"-" header:"X-Trace"`
B string `json:"-" header:"x-trace"`
}
DuplicateParam declares the same header twice.
type EmbeddedAndNested ¶
type EmbeddedAndNested struct {
NestedQuery
Again NestedQuery `json:"again"`
}
EmbeddedAndNested embeds NestedQuery, so its q is a parameter, and also reaches it through a named field, where q is ignored.
type EmbeddedMap ¶
EmbeddedMap embeds a non-struct type: encoding/json sends key "Extras".
type EmbeddedSlice ¶
type EmbeddedSlice struct {
Tags
}
EmbeddedSlice embeds a non-struct type: encoding/json binds key "Tags".
type Flags ¶
type Flags struct {
Mode Mode `json:"mode"`
PMode *Mode `json:"pmode"`
OMode *Mode `json:"omode,omitempty"`
NMode Mode `json:"nmode" nullable:"true"`
PModes []*Mode `json:"pmodes"`
Choice *string `json:"choice" enum:"x,y"`
Small int32 `json:"small"`
Tiny uint8 `json:"tiny" maximum:"100"`
Big uint32 `json:"big"`
Count uint `json:"count"`
Wide int64 `json:"wide"`
}
Flags is a response covering pointer enums, nullable enums and sized ints.
type FlagsRequest ¶
type FlagsRequest struct {
Small int32 `json:"-" query:"small"`
Choice *string `json:"choice" enum:"a,b"`
Must *int `json:"must" required:"true"`
MustMode *Mode `json:"must_mode" required:"true"`
PMode *Mode `json:"pmode,omitempty"`
Levels []int16 `json:"levels"`
}
FlagsRequest covers the request direction of the same rules.
type FormatOnEmail ¶
FormatOnEmail sets a format on types.Email, a string with a format and a decoder of its own.
type FormatOnInt ¶
type FormatOnInt struct {
N int `json:"n" format:"int32"`
}
FormatOnInt sets a format on an integer, whose format the type sets.
type FormatOnString ¶
type FormatOnString struct {
Day string `json:"day" format:"date"`
Email *string `json:"email" format:"email"`
Slug Slug `json:"slug" format:"hostname"`
Hosts []string `json:"hosts" format:"hostname"`
Since types.Optional[string] `json:"since" format:"date"`
On string `json:"-" query:"on" format:"date"`
}
FormatOnString sets formats on strings, which are read as they are.
type FormatOnTime ¶
FormatOnTime sets format date on a time.Time, which encoding/json reads only as RFC 3339.
type FormatOnUUID ¶
FormatOnUUID sets a format on a uuid.UUID query parameter, which UnmarshalText reads.
type HiddenField ¶
type HiddenField struct {
Secret string `json:"secret" hidden:"true"`
}
HiddenField carries hidden:"true", which huma drops from the schema.
type HiddenParam ¶
type HiddenParam struct {
Q string `json:"-" query:"q" hidden:"true"`
}
HiddenParam hides a query parameter.
type HiddenResponse ¶
type HiddenResponse struct {
Name string `json:"name"`
Secret *Mode `json:"secret" hidden:"true"`
Meta *Meta `json:"meta,omitempty" hidden:"true"`
}
HiddenResponse hides fields in a response, which stays allowed.
type JSONStampedRun ¶
type JSONStampedRun struct {
Name string `json:"name"`
// contains filtered or unexported fields
}
JSONStampedRun is StampedRun writing itself with MarshalJSON.
func (JSONStampedRun) MarshalJSON ¶
func (r JSONStampedRun) MarshalJSON() ([]byte, error)
type ListRequest ¶
type ListRequest struct {
pagination.CursorRequest
ProjectID uuid.UUID `json:"-" query:"project_id"`
Status RunStatus `json:"-" query:"status"`
}
ListRequest has no body: every field is a parameter.
type ListResponse ¶
type ListResponse struct {
pagination.CursorResponse
Runs []Run `json:"runs"`
}
ListResponse embeds the cursor response.
type Meta ¶
type Meta struct {
Source string `json:"source"`
Labels map[string]string `json:"labels,omitempty"`
}
Meta is only used in responses.
type MissingDash ¶
type MissingDash struct {
Status RunStatus `query:"status"`
}
MissingDash has a query param that would also be a body property.
type NestedBad ¶
type NestedBad struct {
Items []UnexportedEmbed `json:"items"`
}
NestedBad reaches UnexportedEmbed through a slice.
type NestedEnumKey ¶
type NestedEnumKey struct {
Counts types.Optional[[]map[RunStatus]int] `json:"counts"`
ByName map[string]map[Mode]int `json:"by_name"`
Inner *EnumKey `json:"inner,omitempty"`
}
NestedEnumKey reaches a map keyed by an enum through an Optional of a slice, a map value and a nested struct.
type NestedFile ¶
type NestedFile struct {
Upload NestedFileHolder `json:"upload"`
}
NestedFile reaches NestedFileHolder through a named field.
type NestedFileHolder ¶
type NestedFileHolder struct {
File *multipart.FileHeader `json:"-" form:"file"`
}
NestedFileHolder holds a file field: read only when a request type embeds it.
type NestedParam ¶
type NestedParam struct {
N NestedQuery `json:"n"`
}
NestedParam reaches NestedQuery through a named field.
type NestedParamOptional ¶
type NestedParamOptional struct {
N types.Optional[NestedQuery] `json:"n"`
}
NestedParamOptional reaches NestedQuery through an Optional's element.
type NestedParamSlice ¶
type NestedParamSlice struct {
Items []NestedQuery `json:"items"`
}
NestedParamSlice reaches NestedQuery through a slice element.
type NestedQuery ¶
NestedQuery holds a query parameter: read only when a request type embeds it.
type Node ¶
type Node struct {
Name string `json:"name" required:"true"`
Label *string `json:"label,omitempty"`
Children []Node `json:"children,omitempty"`
}
Node is recursive and used in both directions (request root and Tree).
type NullableStruct ¶
type NullableStruct struct {
Meta Meta `json:"meta" nullable:"true"`
}
NullableStruct puts nullable on a struct reference.
type OptionalBadKeys ¶
type OptionalBadKeys struct {
Item types.Optional[UnexportedEmbed] `json:"item"`
}
OptionalBadKeys reaches UnexportedEmbed through types.Optional.
type OptionalParam ¶
OptionalParam puts types.Optional on a query parameter.
type OptionalPointer ¶
OptionalPointer takes types.Optional by pointer, which the lint rejects.
type OptionalRequest ¶
type OptionalRequest struct {
Name types.Optional[string] `json:"name" minLength:"1" doc:"Display name"`
Mode types.Optional[Mode] `json:"mode" enum:"a"`
Meta types.Optional[Meta] `json:"meta"`
Tags types.Optional[[]string] `json:"tags"`
Small types.Optional[int32] `json:"small"`
Must types.Optional[string] `json:"must" required:"true"`
}
OptionalRequest is a PATCH body of types.Optional fields.
type OptionalResponse ¶
type OptionalResponse struct {
Name types.Optional[string] `json:"name"`
Mode types.Optional[Mode] `json:"mode,omitzero"`
Meta types.Optional[Meta] `json:"meta,omitempty"`
}
OptionalResponse uses types.Optional in a response.
type OptionalWideBound ¶
OptionalWideBound sets a maximum the Optional's int8 cannot hold.
type Page ¶
type Page[T any] struct { Items []T `json:"items"` }
Page is a generic response wrapper.
type Pair ¶
type Pair struct {
V *int `json:"v,omitempty"`
}
Pair is used in both directions, so its request variant is PairInput.
type PairInput ¶
type PairInput struct {
W int `json:"w"`
}
PairInput collides with Pair's request variant name.
type Run ¶
type Run struct {
ID uuid.UUID `json:"id"`
Status RunStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
Metadata *Meta `json:"metadata,omitempty"`
Tags []string `json:"tags"`
Score *float64 `json:"score,omitempty"`
Config Config `json:"config"`
}
Run is the main response type.
type ShadowedGoName ¶
ShadowedGoName has a promoted field whose Go name is shadowed: huma drops a_id, encoding/json binds it.
type StampedRun ¶
type StampedRun struct {
Name string `json:"name"`
// contains filtered or unexported fields
}
StampedRun embeds an unexported struct: huma skips it, encoding/json sends created_at.
type StampedRuns ¶
type StampedRuns struct {
Runs map[string]StampedRun `json:"runs"`
}
StampedRuns reaches StampedRun through a map field.
type StringOption ¶
type StringOption struct {
N int `json:"n,omitempty,string"`
}
StringOption encodes an integer as a JSON string.
type StructParam ¶
type StructParam struct {
Filter Meta `json:"-" query:"filter"`
}
StructParam has a query param of struct type.
type TextStampedRun ¶
type TextStampedRun struct {
Name string `json:"name"`
// contains filtered or unexported fields
}
TextStampedRun is StampedRun writing itself with MarshalText.
func (TextStampedRun) MarshalText ¶
func (r TextStampedRun) MarshalText() ([]byte, error)
type UnexportedEmbed ¶
type UnexportedEmbed struct {
Name string `json:"name"`
// contains filtered or unexported fields
}
UnexportedEmbed embeds an unexported struct: huma skips it, encoding/json promotes Level.
type UpdateRequest ¶
type UpdateRequest struct {
RunID uuid.UUID `json:"-" path:"id"`
MaxTotalRuns *int `json:"max_total_runs,omitempty" minimum:"0"`
CodeSnapshotID *uuid.UUID `json:"code_snapshot_id,omitempty"`
Status *RunStatus `json:"status,omitempty" enum:"failed,cancelled"`
FailureReason *string `json:"failure_reason,omitempty"`
}
UpdateRequest is a partial update: nothing is required in the body.
Directories
¶
| Path | Synopsis |
|---|---|
|
a
|
|
|
units
Package units collides by last path segment with fixture/b/units.
|
Package units collides by last path segment with fixture/b/units. |
|
b
|
|
|
units
Package units collides by last path segment with fixture/a/units.
|
Package units collides by last path segment with fixture/a/units. |
|
Package other holds a type whose name collides with fixture.Run, to prove package-qualified component names keep them apart.
|
Package other holds a type whose name collides with fixture.Run, to prove package-qualified component names keep them apart. |