Documentation ¶
Index ¶
- type Content
- type ContentType
- type EnumVariant
- type Field
- type GenericVariant
- type JSON
- type Kind
- type NilSemantic
- type Operation
- type Parameter
- type PathPart
- type PrimitiveType
- type Request
- type Response
- type ResponseInfo
- type StatusResponse
- type SumJSON
- type SumJSONType
- type SumSpec
- type SumSpecMap
- type Tag
- type Type
- func Alias(name string, to *Type) *Type
- func Array(item *Type, sem NilSemantic, schema *oas.Schema) *Type
- func Generic(name string, of *Type, v GenericVariant) *Type
- func Interface(name string) *Type
- func Pointer(typ *Type, sem NilSemantic) *Type
- func Primitive(typ PrimitiveType, schema *oas.Schema) *Type
- func Stream() *Type
- func (t *Type) AddMethod(name string)
- func (t Type) CanGeneric() bool
- func (t *Type) EncodeFn() string
- func (t *Type) Equal(target *Type) bool
- func (t *Type) Format() bool
- func (t Type) FromString() string
- func (t *Type) Go() string
- func (t *Type) Implement(i *Type)
- func (t *Type) Is(vs ...Kind) bool
- func (t *Type) IsAlias() bool
- func (t *Type) IsArray() bool
- func (t *Type) IsEnum() bool
- func (t *Type) IsFloat() bool
- func (t *Type) IsGeneric() bool
- func (t *Type) IsInteger() bool
- func (t *Type) IsInterface() bool
- func (t *Type) IsNumeric() bool
- func (t *Type) IsPointer() bool
- func (t *Type) IsPrimitive() bool
- func (t *Type) IsStream() bool
- func (t *Type) IsStruct() bool
- func (t *Type) IsSum() bool
- func (t *Type) JSON() JSON
- func (t *Type) ListImplementations() []*Type
- func (t *Type) Methods() []string
- func (t *Type) MustField(name string) *Field
- func (t *Type) NeedValidation() bool
- func (t *Type) Pointer(sem NilSemantic) *Type
- func (t *Type) RecursiveTo(target *Type) bool
- func (t Type) String() string
- func (t Type) ToString() string
- func (t *Type) Unimplement(i *Type)
- type TypeDiscriminator
- type Validators
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Content ¶
type Content struct { ContentType ContentType Type *Type }
type ContentType ¶
type ContentType string
ContentType of body.
const ( // ContentTypeJSON is ContentType for json. ContentTypeJSON ContentType = "application/json" // ContentTypeOctetStream is ContentType for binary. ContentTypeOctetStream ContentType = "application/octet-stream" )
func (ContentType) EncodedDataTypeGo ¶
func (t ContentType) EncodedDataTypeGo() string
func (ContentType) JSON ¶
func (t ContentType) JSON() bool
func (ContentType) Name ¶
func (t ContentType) Name() string
func (ContentType) OctetStream ¶
func (t ContentType) OctetStream() bool
type EnumVariant ¶
type EnumVariant struct { Name string Value interface{} }
func (*EnumVariant) ValueGo ¶
func (v *EnumVariant) ValueGo() string
type GenericVariant ¶
func (GenericVariant) Any ¶
func (v GenericVariant) Any() bool
func (GenericVariant) Name ¶
func (v GenericVariant) Name() string
func (GenericVariant) NullableOptional ¶
func (v GenericVariant) NullableOptional() bool
func (GenericVariant) OnlyNullable ¶
func (v GenericVariant) OnlyNullable() bool
func (GenericVariant) OnlyOptional ¶
func (v GenericVariant) OnlyOptional() bool
type JSON ¶
type JSON struct {
// contains filtered or unexported fields
}
JSON specifies json encoding and decoding for Type.
func (JSON) Fn ¶
Fn returns jx.Encoder or jx.Decoder method name.
If blank, value cannot be encoded with single method call.
func (JSON) Format ¶
Format returns format name for handling json encoding or decoding.
Mostly used for encoding or decoding of string formats, like `json.EncodeUUID`, where UUID is Format.
type NilSemantic ¶
type NilSemantic string
NilSemantic specifies nil value semantics.
const ( NilInvalid NilSemantic = "invalid" // nil is invalid NilOptional NilSemantic = "optional" // nil is "no value" NilNull NilSemantic = "null" // nil is null )
Possible nil value semantics.
func (NilSemantic) Invalid ¶
func (n NilSemantic) Invalid() bool
func (NilSemantic) Null ¶
func (n NilSemantic) Null() bool
func (NilSemantic) Optional ¶
func (n NilSemantic) Optional() bool
type Operation ¶
type Operation struct { Name string PathParts []*PathPart Params []*Parameter Request *Request Response *Response Spec *oas.Operation }
func (*Operation) CookieParams ¶
func (*Operation) HeaderParams ¶
func (*Operation) ListResponseTypes ¶
func (op *Operation) ListResponseTypes() []ResponseInfo
func (*Operation) PathParams ¶
func (*Operation) QueryParams ¶
type PrimitiveType ¶
type PrimitiveType int
const ( String PrimitiveType = iota ByteSlice Int Int8 Int16 Int32 Int64 Uint Uint8 Uint16 Uint32 Uint64 Float32 Float64 Time Duration UUID IP URL Bool )
func (PrimitiveType) String ¶
func (p PrimitiveType) String() string
type Request ¶
type Request struct { Type *Type Contents map[ContentType]*Type Spec *oas.RequestBody }
type Response ¶
type Response struct { Type *Type StatusCode map[int]*StatusResponse Default *StatusResponse }
type ResponseInfo ¶
type ResponseInfo struct { Type *Type StatusCode int Default bool ContentType ContentType NoContent bool }
type StatusResponse ¶
type StatusResponse struct { Wrapped bool NoContent *Type Contents map[ContentType]*Type Spec *oas.Response }
func (StatusResponse) ResponseInfo ¶
func (s StatusResponse) ResponseInfo() []ResponseInfo
type SumJSON ¶
type SumJSON struct {
Type SumJSONType
}
SumJSON specifies rules for parsing sum types in json.
func (SumJSON) Discriminator ¶
func (SumJSON) TypeDiscriminator ¶
type SumJSONType ¶
type SumJSONType byte
const ( SumJSONPrimitive SumJSONType = iota SumJSONFields SumJSONDiscriminator SumJSONTypeDiscriminator )
type SumSpec ¶
type SumSpec struct { Unique []*Field // Discriminator is field name of sum type discriminator. Discriminator string // Mapping is discriminator value -> variant mapping. Mapping []SumSpecMap // TypeDiscriminator denotes to distinguish variants by type. TypeDiscriminator bool }
SumSpec for KindSum.
type SumSpecMap ¶
type Type ¶
type Type struct { Doc string // documentation Kind Kind // kind Name string // only for struct, alias, interface, enum Primitive PrimitiveType // only for primitive, enum AliasTo *Type // only for alias PointerTo *Type // only for pointer SumOf []*Type // only for sum SumSpec SumSpec // only for sum Item *Type // only for array EnumVariants []*EnumVariant // only for enum Fields []*Field // only for struct Implements map[*Type]struct{} // only for struct, alias, enum Implementations map[*Type]struct{} // only for interface InterfaceMethods map[string]struct{} // only for interface Schema *oas.Schema // for all kinds except pointer, interface. Can be nil. NilSemantic NilSemantic // only for pointer GenericOf *Type // only for generic GenericVariant GenericVariant // only for generic Validators Validators }
func Pointer ¶
func Pointer(typ *Type, sem NilSemantic) *Type
func (Type) CanGeneric ¶
CanGeneric reports whether Type can be boxed to KindGeneric.
func (*Type) Format ¶
Format denotes whether custom formatting for Type is required while encoding or decoding.
TODO(ernado): can we use t.JSON here?
func (Type) FromString ¶
func (*Type) IsInterface ¶
func (*Type) IsPrimitive ¶
func (*Type) ListImplementations ¶
func (*Type) NeedValidation ¶
func (*Type) Pointer ¶
func (t *Type) Pointer(sem NilSemantic) *Type
func (*Type) RecursiveTo ¶
func (*Type) Unimplement ¶
type TypeDiscriminator ¶
type TypeDiscriminator struct { Kind Kind Primitive PrimitiveType }
func (TypeDiscriminator) Less ¶
func (t TypeDiscriminator) Less(other TypeDiscriminator) bool
func (*TypeDiscriminator) Set ¶
func (t *TypeDiscriminator) Set(s *Type)