Documentation
¶
Overview ¶
Package builder_conformance asserts that the schema, parameters and responses builders agree.
Each of the three resolves Go types to spec constructs, and each carries its own copy of rules the others also need. Where they diverge, a fix verified on one of them reads as complete — which is how `swagger:type` on an alias came to work for a model field and a query parameter while silently dropping for a body parameter.
What is compared ¶
One Go shape reached from four FULL-SCHEMA positions, where no legitimate difference exists and the four must agree exactly:
- a model field (schema builder, the control)
- a body parameter (parameters builder)
- a response body (responses builder)
- an allOf member (schema builder, composition arm)
The first three converge on one field dispatch; the fourth is reached by buildNamedAllOf instead, which keeps its own copy of the classifier cascade.
SimpleSchema positions are deliberately excluded. A non-body parameter and a response header have a genuinely different legality surface — `type` is mandatory and restricted, `$ref` is forbidden — so they belong in a comparison with a declared projection, not in this one. That difference is the historical reason the builders grew separate paths at all.
Why the shapes are NOT nested ¶
Each subject is the field's type DIRECTLY. Nesting them inside a struct sends everything through the schema sub-builder by delegation, where the three agree trivially and the suite reports a comfortable all-clear. The divergences live in the hand-rolled short-circuits that fire when a parameter or response field is itself a named or alias type — `buildNamedField` and `buildFieldAlias` — so the subject has to be reached that way to be tested at all.
Index ¶
- func HandlerAnyV()
- func HandlerBasic()
- func HandlerBytes()
- func HandlerCodes()
- func HandlerEmails()
- func HandlerEnum()
- func HandlerErrAl()
- func HandlerErrN()
- func HandlerFmt()
- func HandlerFmtAl()
- func HandlerIface()
- func HandlerInline()
- func HandlerMapping()
- func HandlerPtr()
- func HandlerRaw()
- func HandlerRawN()
- func HandlerStamp()
- func HandlerStampN()
- func HandlerStruct()
- func HandlerTyp()
- func HandlerTypAl()
- type AllOfHost
- type BytesNamed
- type CodesNamed
- type EmailsNamed
- type EnumNamed
- type ErrAlias
- type FmtAlias
- type FmtNamed
- type ModelHost
- type ParamsAnyV
- type ParamsBasic
- type ParamsBytes
- type ParamsCodes
- type ParamsEmails
- type ParamsEnum
- type ParamsErrAl
- type ParamsErrN
- type ParamsFmt
- type ParamsFmtAl
- type ParamsIface
- type ParamsInline
- type ParamsMapping
- type ParamsPtr
- type ParamsRaw
- type ParamsRawN
- type ParamsStamp
- type ParamsStampN
- type ParamsStruct
- type ParamsTyp
- type ParamsTypAl
- type Plain
- type RawAlias
- type RespAnyV
- type RespBasic
- type RespBytes
- type RespCodes
- type RespEmails
- type RespEnum
- type RespErrAl
- type RespErrN
- type RespFmt
- type RespFmtAl
- type RespIface
- type RespInline
- type RespMapping
- type RespPtr
- type RespRaw
- type RespRawN
- type RespStamp
- type RespStampN
- type RespStruct
- type RespTyp
- type RespTypAl
- type Speaker
- type StampAlias
- type TypeAlias
- type TypeNamed
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandlerAnyV ¶
func HandlerAnyV()
HandlerAnyV binds the predeclared-any subject.
swagger:route POST /anyv conf confAnyV
Responses:
200: respAnyV
func HandlerBasic ¶
func HandlerBasic()
HandlerBasic binds the basic subject.
swagger:route POST /basic conf confBasic
Responses:
200: respBasic
func HandlerBytes ¶
func HandlerBytes()
HandlerBytes binds the byte-sequence subject.
swagger:route POST /bytes conf confBytes
Responses:
200: respBytes
func HandlerCodes ¶
func HandlerCodes()
HandlerCodes binds the codes subject.
swagger:route POST /codes conf confCodes
Responses:
200: respCodes
func HandlerEmails ¶
func HandlerEmails()
HandlerEmails binds the emails subject.
swagger:route POST /emails conf confEmails
Responses:
200: respEmails
func HandlerEnum ¶
func HandlerEnum()
HandlerEnum binds the enum subject.
swagger:route POST /enum conf confEnum
Responses:
200: respEnum
func HandlerErrAl ¶
func HandlerErrAl()
HandlerErrAl binds the aliased-error subject.
swagger:route POST /err-al conf confErrAl
Responses:
200: respErrAl
func HandlerErrN ¶
func HandlerErrN()
HandlerErrN binds the predeclared-error subject.
swagger:route POST /err-n conf confErrN
Responses:
200: respErrN
func HandlerFmt ¶
func HandlerFmt()
HandlerFmt binds the format subject.
swagger:route POST /fmt conf confFmt
Responses:
200: respFmt
func HandlerFmtAl ¶
func HandlerFmtAl()
HandlerFmtAl binds the alias-format subject.
swagger:route POST /fmt-al conf confFmtAl
Responses:
200: respFmtAl
func HandlerIface ¶
func HandlerIface()
HandlerIface binds the iface subject.
swagger:route POST /iface conf confIface
Responses:
200: respIface
func HandlerInline ¶
func HandlerInline()
HandlerInline binds the inline-slice subject.
swagger:route POST /inline conf confInline
Responses:
200: respInline
func HandlerMapping ¶
func HandlerMapping()
HandlerMapping binds the mapping subject.
swagger:route POST /mapping conf confMapping
Responses:
200: respMapping
func HandlerPtr ¶
func HandlerPtr()
HandlerPtr binds the ptr subject.
swagger:route POST /ptr conf confPtr
Responses:
200: respPtr
func HandlerRaw ¶
func HandlerRaw()
HandlerRaw binds the open-schema subject.
swagger:route POST /raw conf confRaw
Responses:
200: respRaw
func HandlerRawN ¶
func HandlerRawN()
HandlerRawN binds the named open-schema subject.
swagger:route POST /raw-n conf confRawN
Responses:
200: respRawN
func HandlerStamp ¶
func HandlerStamp()
HandlerStamp binds the stdlib-alias subject.
swagger:route POST /stamp conf confStamp
Responses:
200: respStamp
func HandlerStampN ¶
func HandlerStampN()
HandlerStampN binds the named stdlib time subject.
swagger:route POST /stamp-n conf confStampN
Responses:
200: respStampN
func HandlerStruct ¶
func HandlerStruct()
HandlerStruct binds the struct subject.
swagger:route POST /struct conf confStruct
Responses:
200: respStruct
func HandlerTyp ¶
func HandlerTyp()
HandlerTyp binds the override subject.
swagger:route POST /typ conf confTyp
Responses:
200: respTyp
func HandlerTypAl ¶
func HandlerTypAl()
HandlerTypAl binds the alias-override subject.
swagger:route POST /typ-al conf confTypAl
Responses:
200: respTypAl
Types ¶
type AllOfHost ¶
type AllOfHost struct {
// swagger:allOf
FmtNamed
// swagger:allOf
FmtAlias
// swagger:allOf
TypeNamed
// swagger:allOf
TypeAlias
// swagger:allOf
EnumNamed
// swagger:allOf
BytesNamed
// swagger:allOf
StampAlias
// swagger:allOf
RawAlias
// swagger:allOf
Plain
// swagger:allOf
Speaker
// swagger:allOf
EmailsNamed
// swagger:allOf
CodesNamed
// swagger:allOf
time.Time
// swagger:allOf
json.RawMessage
// swagger:allOf
ErrAlias
// Note is the composing struct's own field, which lands in the trailing member.
Note string `json:"note"`
}
AllOfHost reaches every EMBEDDABLE subject as an allOf MEMBER, one member per subject, in the same order ModelHost declares them.
A member of an allOf is a full schema describing one type, exactly as a model field is, so the two must agree. It is reached by a different arm than any of the other three positions — `buildNamedAllOf` rather than the field dispatch — and that arm consults its own subset of the classifiers.
One allOf rather than one host per subject, deliberately: members that resolve side by side also witness that no member's classifier leaks into its neighbours, which separate hosts could not show. The composing struct's own field lands in a trailing member, so member i is subject i.
Subjects absent here are the ones Go cannot embed under a usable name: a map, a slice of an inline struct, and the pointer/basic/predeclared arms, whose embedded field name would either collide with another member or be unexported.
swagger:model AllOfHost
type BytesNamed ¶
type BytesNamed []byte
BytesNamed is a byte sequence carrying the whole-schema format.
swagger:strfmt byte
type CodesNamed ¶
type CodesNamed [4]string
CodesNamed is the array flavour of the same divergence.
swagger:strfmt email
type EmailsNamed ¶
type EmailsNamed []string
EmailsNamed is a named STRING slice carrying a NON-special format.
This is the pinned divergence. The element-driven rule (see common.ApplyArrayLikeStrfmt) asks whether the ELEMENT makes the sequence string-like: `byte` and `rune` do, so a format describes the whole value; `string` does not, so the format describes each element. The schema builder applies that rule. The parameters and responses builders short-circuit on a local `strfmtFromDoc` helper that predates it and writes `Typed("string", format)` unconditionally, claiming the value IS one email when the Go type is a list of them.
swagger:strfmt email
type ErrAlias ¶
type ErrAlias = error
ErrAlias names the predeclared error through an alias.
The alias's own object is this name, not `error`, so an identity recognizer keyed on the object never fires here — only after the alias dissolves.
type FmtAlias ¶
type FmtAlias = string
FmtAlias carries the same format on an alias.
swagger:strfmt isbn
type ModelHost ¶
type ModelHost struct {
// Fmt is the named-format subject.
Fmt FmtNamed `json:"fmt"`
// FmtAl is the alias-format subject.
FmtAl FmtAlias `json:"fmtAl"`
// Typ is the named-override subject.
Typ TypeNamed `json:"typ"`
// TypAl is the alias-override subject.
TypAl TypeAlias `json:"typAl"`
// Enum is the enum subject.
Enum EnumNamed `json:"enum"`
// Bytes is the byte-sequence subject.
Bytes BytesNamed `json:"bytes"`
// Stamp is the stdlib-alias subject.
Stamp StampAlias `json:"stamp"`
// Raw is the open-schema subject.
Raw RawAlias `json:"raw"`
// Struct is the struct-arm subject.
Struct Plain `json:"struct"`
// Iface is the interface-arm subject.
Iface Speaker `json:"iface"`
// Mapping is the map-arm subject.
Mapping map[string]Plain `json:"mapping"`
// Inline is the slice arm with an inline element.
Inline []struct {
// Code is the inline element property.
Code string `json:"code"`
} `json:"inline"`
// Ptr is the pointer arm.
Ptr *Plain `json:"ptr"`
// Basic is the plain-basic arm.
Basic int32 `json:"basic"`
// Emails is the pinned slice+non-special-format divergence.
Emails EmailsNamed `json:"emails"`
// Codes is the array flavour of the same.
Codes CodesNamed `json:"codes"`
// StampN is the stdlib time reached as the named type.
StampN time.Time `json:"stampN"`
// RawN is the open-schema stdlib type reached as the named type.
RawN json.RawMessage `json:"rawN"`
// AnyV is the predeclared any.
AnyV any `json:"anyv"`
// ErrN is the predeclared error — no package, no declaration.
ErrN error `json:"errN"`
// ErrAl names the same through an alias.
ErrAl ErrAlias `json:"errAl"`
}
ModelHost reaches every subject as a MODEL FIELD — the schema builder's view, and the control for the other two.
swagger:model ModelHost
type ParamsAnyV ¶
type ParamsAnyV struct {
// in: body
Body any `json:"body"`
}
ParamsAnyV reaches the predeclared any as a body parameter.
swagger:parameters confAnyV
type ParamsBasic ¶
type ParamsBasic struct {
// in: body
Body int32 `json:"body"`
}
ParamsBasic reaches the basic subject as a body parameter.
swagger:parameters confBasic
type ParamsBytes ¶
type ParamsBytes struct {
// in: body
Body BytesNamed `json:"body"`
}
ParamsBytes reaches BytesNamed as a body parameter.
swagger:parameters confBytes
type ParamsCodes ¶
type ParamsCodes struct {
// in: body
Body CodesNamed `json:"body"`
}
ParamsCodes reaches the codes subject as a body parameter.
swagger:parameters confCodes
type ParamsEmails ¶
type ParamsEmails struct {
// in: body
Body EmailsNamed `json:"body"`
}
ParamsEmails reaches the emails subject as a body parameter.
swagger:parameters confEmails
type ParamsEnum ¶
type ParamsEnum struct {
// in: body
Body EnumNamed `json:"body"`
}
ParamsEnum reaches EnumNamed as a body parameter.
swagger:parameters confEnum
type ParamsErrAl ¶
type ParamsErrAl struct {
// Named for the subject, as above.
//
// in: body
Body ErrAlias `json:"errAl"`
}
ParamsErrAl reaches the aliased error as a body parameter.
swagger:parameters confErrAl
type ParamsErrN ¶
type ParamsErrN struct {
// The name is the subject's, not the usual "body": the diagnostic raised when this parameter is
// dropped has to be attributable to it.
//
// in: body
Body error `json:"errN"`
}
ParamsErrN reaches the predeclared error as a body parameter.
swagger:parameters confErrN
type ParamsFmt ¶
type ParamsFmt struct {
// in: body
Body FmtNamed `json:"body"`
}
ParamsFmt reaches FmtNamed as a body parameter.
swagger:parameters confFmt
type ParamsFmtAl ¶
type ParamsFmtAl struct {
// in: body
Body FmtAlias `json:"body"`
}
ParamsFmtAl reaches FmtAlias as a body parameter.
swagger:parameters confFmtAl
type ParamsIface ¶
type ParamsIface struct {
// in: body
Body Speaker `json:"body"`
}
ParamsIface reaches the iface subject as a body parameter.
swagger:parameters confIface
type ParamsInline ¶
type ParamsInline struct {
// in: body
Body []struct {
// Code is the inline element property.
Code string `json:"code"`
} `json:"body"`
}
ParamsInline reaches the inline-element slice as a body parameter.
swagger:parameters confInline
type ParamsMapping ¶
ParamsMapping reaches the mapping subject as a body parameter.
swagger:parameters confMapping
type ParamsPtr ¶
type ParamsPtr struct {
// in: body
Body *Plain `json:"body"`
}
ParamsPtr reaches the ptr subject as a body parameter.
swagger:parameters confPtr
type ParamsRaw ¶
type ParamsRaw struct {
// in: body
Body RawAlias `json:"body"`
}
ParamsRaw reaches RawAlias as a body parameter.
swagger:parameters confRaw
type ParamsRawN ¶
type ParamsRawN struct {
// in: body
Body json.RawMessage `json:"body"`
}
ParamsRawN reaches the named open-schema type as a body parameter.
swagger:parameters confRawN
type ParamsStamp ¶
type ParamsStamp struct {
// in: body
Body StampAlias `json:"body"`
}
ParamsStamp reaches StampAlias as a body parameter.
swagger:parameters confStamp
type ParamsStampN ¶
ParamsStampN reaches the named stdlib time as a body parameter.
swagger:parameters confStampN
type ParamsStruct ¶
type ParamsStruct struct {
// in: body
Body Plain `json:"body"`
}
ParamsStruct reaches the struct subject as a body parameter.
swagger:parameters confStruct
type ParamsTyp ¶
type ParamsTyp struct {
// in: body
Body TypeNamed `json:"body"`
}
ParamsTyp reaches TypeNamed as a body parameter.
swagger:parameters confTyp
type ParamsTypAl ¶
type ParamsTypAl struct {
// in: body
Body TypeAlias `json:"body"`
}
ParamsTypAl reaches TypeAlias as a body parameter.
swagger:parameters confTypAl
type Plain ¶
type Plain struct {
// Left is a plain property.
Left string `json:"left"`
}
Plain is a struct reached directly as a field.
type RawAlias ¶
type RawAlias = json.RawMessage
RawAlias is an alias to the open "any JSON" stdlib type.
type RespAnyV ¶
type RespAnyV struct {
// in: body
Body any `json:"body"`
}
RespAnyV reaches the predeclared any as a response body.
swagger:response respAnyV
type RespBasic ¶
type RespBasic struct {
// in: body
Body int32 `json:"body"`
}
RespBasic reaches the basic subject as a response body.
swagger:response respBasic
type RespBytes ¶
type RespBytes struct {
// in: body
Body BytesNamed `json:"body"`
}
RespBytes reaches BytesNamed as a response body.
swagger:response respBytes
type RespCodes ¶
type RespCodes struct {
// in: body
Body CodesNamed `json:"body"`
}
RespCodes reaches the codes subject as a response body.
swagger:response respCodes
type RespEmails ¶
type RespEmails struct {
// in: body
Body EmailsNamed `json:"body"`
}
RespEmails reaches the emails subject as a response body.
swagger:response respEmails
type RespEnum ¶
type RespEnum struct {
// in: body
Body EnumNamed `json:"body"`
}
RespEnum reaches EnumNamed as a response body.
swagger:response respEnum
type RespErrAl ¶
type RespErrAl struct {
// in: body
Body ErrAlias `json:"body"`
}
RespErrAl reaches the aliased error as a response body.
swagger:response respErrAl
type RespErrN ¶
type RespErrN struct {
// in: body
Body error `json:"body"`
}
RespErrN reaches the predeclared error as a response body.
swagger:response respErrN
type RespFmt ¶
type RespFmt struct {
// in: body
Body FmtNamed `json:"body"`
}
RespFmt reaches FmtNamed as a response body.
swagger:response respFmt
type RespFmtAl ¶
type RespFmtAl struct {
// in: body
Body FmtAlias `json:"body"`
}
RespFmtAl reaches FmtAlias as a response body.
swagger:response respFmtAl
type RespIface ¶
type RespIface struct {
// in: body
Body Speaker `json:"body"`
}
RespIface reaches the iface subject as a response body.
swagger:response respIface
type RespInline ¶
type RespInline struct {
// in: body
Body []struct {
// Code is the inline element property.
Code string `json:"code"`
} `json:"body"`
}
RespInline reaches the inline-element slice as a response body.
swagger:response respInline
type RespMapping ¶
RespMapping reaches the mapping subject as a response body.
swagger:response respMapping
type RespPtr ¶
type RespPtr struct {
// in: body
Body *Plain `json:"body"`
}
RespPtr reaches the ptr subject as a response body.
swagger:response respPtr
type RespRaw ¶
type RespRaw struct {
// in: body
Body RawAlias `json:"body"`
}
RespRaw reaches RawAlias as a response body.
swagger:response respRaw
type RespRawN ¶
type RespRawN struct {
// in: body
Body json.RawMessage `json:"body"`
}
RespRawN reaches the named open-schema type as a response body.
swagger:response respRawN
type RespStamp ¶
type RespStamp struct {
// in: body
Body StampAlias `json:"body"`
}
RespStamp reaches StampAlias as a response body.
swagger:response respStamp
type RespStampN ¶
RespStampN reaches the named stdlib time as a response body.
swagger:response respStampN
type RespStruct ¶
type RespStruct struct {
// in: body
Body Plain `json:"body"`
}
RespStruct reaches the struct subject as a response body.
swagger:response respStruct
type RespTyp ¶
type RespTyp struct {
// in: body
Body TypeNamed `json:"body"`
}
RespTyp reaches TypeNamed as a response body.
swagger:response respTyp
type RespTypAl ¶
type RespTypAl struct {
// in: body
Body TypeAlias `json:"body"`
}
RespTypAl reaches TypeAlias as a response body.
swagger:response respTypAl
type Speaker ¶
type Speaker interface {
// Say returns a word.
Say() string
}
Speaker is a non-empty interface reached directly as a field.