Documentation ¶
Index ¶
- type ArrayWithNoValidate
- type EmbeddedTime
- type MapOfPrimitives
- type MapWithNoValidate
- type MyCustomArray
- type MyCustomArrayNullable
- type MyCustomMap
- type MyCustomMapNullable
- type MyExtCollection
- type MyInteger
- type MyInterfaceObject
- type MyOtherType
- type MyReaderObject
- type MyStreamer
- type MyString
- type MyTuple
- func (m *MyTuple) ContextValidate(ctx context.Context, formats strfmt.Registry) error
- func (m *MyTuple) MarshalBinary() ([]byte, error)
- func (m MyTuple) MarshalJSON() ([]byte, error)
- func (m *MyTuple) UnmarshalBinary(b []byte) error
- func (m *MyTuple) UnmarshalJSON(raw []byte) error
- func (m *MyTuple) Validate(formats strfmt.Registry) error
- type MyType
- type ObjectWithNoValidate
- type TupleWithNoValidate
- func (m *TupleWithNoValidate) ContextValidate(ctx context.Context, formats strfmt.Registry) error
- func (m *TupleWithNoValidate) MarshalBinary() ([]byte, error)
- func (m TupleWithNoValidate) MarshalJSON() ([]byte, error)
- func (m *TupleWithNoValidate) UnmarshalBinary(b []byte) error
- func (m *TupleWithNoValidate) UnmarshalJSON(raw []byte) error
- func (m *TupleWithNoValidate) Validate(formats strfmt.Registry) error
- type Zzz
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayWithNoValidate ¶
ArrayWithNoValidate A slice of NoValidateExternal external types.
If the "noValidation" hint is omitted in the definition above, this code won't build because `http.Request` has no `Validate` method.
swagger:model ArrayWithNoValidate
func (ArrayWithNoValidate) ContextValidate ¶
ContextValidate validates this array with no validate based on context it is used
type EmbeddedTime ¶
EmbeddedTime This type demonstrates how we can embed an external type and wraps the validation.
This is especially useful if you want to reuse some types from the standard library, such as `time.Time` or `json.RawMessage`.
swagger:model EmbeddedTime
func (EmbeddedTime) ContextValidate ¶
type MapOfPrimitives ¶
MapOfPrimitives A map of NoValidatePrimitive external types.
If the "noValidation" hint is omitted in the definition above, this code won't build because `time.Duration` has no `Validate` method.
swagger:model MapOfPrimitives
func (MapOfPrimitives) ContextValidate ¶
ContextValidate validates this map of primitives based on context it is used
type MapWithNoValidate ¶
MapWithNoValidate A map of NoValidateExternal external types.
If the "noValidation" hint is omitted in the definition above, this code won't build because `http.Request` has no `Validate` method.
swagger:model MapWithNoValidate
func (MapWithNoValidate) ContextValidate ¶
ContextValidate validates this map with no validate based on context it is used
type MyCustomArray ¶
type MyCustomArray []alternate.MyAlternateType
MyCustomArray This generate an array type in models, based on the external type.
[]alternate.MyAlternateType
The validation method of the external type is called by the generated array.
swagger:model MyCustomArray
func (MyCustomArray) ContextValidate ¶
ContextValidate validates this my custom array based on context it is used
type MyCustomArrayNullable ¶
type MyCustomArrayNullable []*alternate.MyAlternateType
MyCustomArrayNullable This generate an array type in models, based on the external type. Notice the impact of the nullable hint (equivalent to x-nullable at the type level), to produce a slice of pointers.
[]*alternate.MyAlternateType
swagger:model MyCustomArrayNullable
func (MyCustomArrayNullable) ContextValidate ¶
ContextValidate validates this my custom array nullable based on context it is used
type MyCustomMap ¶
type MyCustomMap map[string]map[string]alternate.MyAlternateType
MyCustomMap This generate a map type in models, based on the external type.
MyCustomMap map[string]map[string]alternate.MyAlternateType
The validation method of the external type is called by the generated map.
swagger:model MyCustomMap
func (MyCustomMap) ContextValidate ¶
ContextValidate validates this my custom map based on context it is used
type MyCustomMapNullable ¶
type MyCustomMapNullable map[string]map[string]*alternate.MyAlternateType
MyCustomMapNullable This generate a map type in models, based on the external type. Notice the impact of the x-nullable directive, to produce a map of pointers.
MapNullable map[string]map[string]*alternate.MyAlternateType
swagger:model MyCustomMapNullable
func (MyCustomMapNullable) ContextValidate ¶
ContextValidate validates this my custom map nullable based on context it is used
type MyExtCollection ¶
MyExtCollection This type demonstrates the import generation with name mangling
swagger:model MyExtCollection
func (MyExtCollection) ContextValidate ¶
ContextValidate validate this my ext collection based on the context it is used
type MyInteger ¶
type MyInteger int
MyInteger ...
func (MyInteger) ContextValidate ¶
ContextValidate MyInteger
type MyInterfaceObject ¶
type MyInterfaceObject struct { // iface1 Iface1 fred.MyAlternateInterface `json:"iface1,omitempty"` // Demonstrates the impact of the "interface" hint: no validation is called on iface2, // and no pointer is generated in spite of the "required" directive. // // The generated object validation checks for the "required" directive. // // Without the hint, the generator assumes a Validatable object, with pointer, which may // not build, depending on how the external type is defined. // // Required: true Iface2 fred.MyAlternateInterface `json:"iface2"` // Demonstrates the impact of the "noValidation" hint. // // Notice how we avoid the generation of a pointer on the required json.RawMessage (which is a []byte) // with the "nullable" hint. // // Notice that the "json" package is automatically deconflicted from other standard imports with a distinct alias. // // Required: true Iface3 jsonext.RawMessage `json:"iface3"` }
MyInterfaceObject This object demonstrates several ways to refer to an external interface.
The generated code behaves as it is an interface{}: no pointers are generated, and no valication is required.
swagger:model MyInterfaceObject
func (*MyInterfaceObject) ContextValidate ¶
ContextValidate validates this my interface object based on context it is used
func (*MyInterfaceObject) MarshalBinary ¶
func (m *MyInterfaceObject) MarshalBinary() ([]byte, error)
MarshalBinary interface implementation
func (*MyInterfaceObject) UnmarshalBinary ¶
func (m *MyInterfaceObject) UnmarshalBinary(b []byte) error
UnmarshalBinary interface implementation
type MyOtherType ¶
type MyOtherType struct{}
MyOtherType ...
func (MyOtherType) ContextValidate ¶
ContextValidate MyOtherType
type MyReaderObject ¶
type MyReaderObject struct { // reader1 // Format: binary Reader1 MyStreamer `json:"reader1,omitempty"` // In line definition of the external type. // // Notice that we have provided some information in the spec, so the generator // can infer we want it to be understood as an io.Reader, with no validation. // // Format: binary Reader2 alternate.MyAlternateStreamer `json:"reader2,omitempty"` // In line definition of the external type. // // Notice that we have provided some information in the spec, as a hint in the extension // rather than in the type definition. // // So this will be documented as an object, but the generated code knows this is a stream. // Reader3 fred.MyAlternateStreamer `json:"reader3,omitempty"` }
MyReaderObject This object demonstrates several ways to refer to an external interface (here assumed akin to io.Reader). MarshalBinary() methods are generated. No validation is expected on binary format.
swagger:model MyReaderObject
func (*MyReaderObject) ContextValidate ¶
ContextValidate validates this my reader object based on context it is used
func (*MyReaderObject) MarshalBinary ¶
func (m *MyReaderObject) MarshalBinary() ([]byte, error)
MarshalBinary interface implementation
func (*MyReaderObject) UnmarshalBinary ¶
func (m *MyReaderObject) UnmarshalBinary(b []byte) error
UnmarshalBinary interface implementation
type MyString ¶
type MyString string
MyString ...
func (MyString) ContextValidate ¶
ContextValidate MyInteger
type MyTuple ¶
type MyTuple struct { // p0 // Required: true P0 *MyType `json:"-"` // custom serializer // Second element of the tuple, defined as follows. // // P1 *fred.MyAlternateType `json:"-"` // custom serializer // // Required: true P1 *fred.MyAlternateType `json:"-"` // custom serializer // Additional items to a tuple, from an external type. // This defines the following field in the tuple // // MyTupleItems []map[string]fred.MyAlternateType // MyTupleItems []map[string]fred.MyAlternateType `json:"-"` }
MyTuple Demonstrates references to some external type in the context of a tuple.
Notice that "additionalItems" is not a construct that pass swagger validation, but is supported by go-swagger.
swagger:model MyTuple
func (*MyTuple) ContextValidate ¶
ContextValidate validate this my tuple based on the context it is used
func (*MyTuple) MarshalBinary ¶
MarshalBinary interface implementation
func (MyTuple) MarshalJSON ¶
MarshalJSON marshals this tuple type into a JSON array
func (*MyTuple) UnmarshalBinary ¶
UnmarshalBinary interface implementation
func (*MyTuple) UnmarshalJSON ¶
UnmarshalJSON unmarshals this tuple type from a JSON array
type MyType ¶
type MyType string
MyType is a type manually added to the models package (NOT GENERATED)
func (MyType) ContextValidate ¶
ContextValidate MyType
type ObjectWithNoValidate ¶
type ObjectWithNoValidate struct { // my mandatory request // Required: true MyMandatoryRequest *httpext.Request `json:"myMandatoryRequest"` // my request MyRequest httpext.Request `json:"myRequest,omitempty"` }
ObjectWithNoValidate A reference to the NoValidateExternal external type.
If the "noValidation" hint is omitted in the definition above, this code won't build because `http.Request` has no `Validate` method.
swagger:model ObjectWithNoValidate
func (*ObjectWithNoValidate) ContextValidate ¶
ContextValidate validates this object with no validate based on context it is used
func (*ObjectWithNoValidate) MarshalBinary ¶
func (m *ObjectWithNoValidate) MarshalBinary() ([]byte, error)
MarshalBinary interface implementation
func (*ObjectWithNoValidate) UnmarshalBinary ¶
func (m *ObjectWithNoValidate) UnmarshalBinary(b []byte) error
UnmarshalBinary interface implementation
type TupleWithNoValidate ¶
type TupleWithNoValidate struct { // p0 // Required: true P0 *httpext.Request `json:"-"` // custom serializer // p1 // Required: true P1 *httpext.Request `json:"-"` // custom serializer // tuple with no validate items TupleWithNoValidateItems []httpext.Request `json:"-"` }
TupleWithNoValidate A tuple of NoValidateExternal external types.
If the "noValidation" hint is omitted in the definition above, this code won't build because `http.Request` has no `Validate` method.
Notice that "additionalItems" is not a construct that pass swagger validation, but is supported by go-swagger.
swagger:model TupleWithNoValidate
func (*TupleWithNoValidate) ContextValidate ¶
ContextValidate validates this tuple with no validate based on context it is used
func (*TupleWithNoValidate) MarshalBinary ¶
func (m *TupleWithNoValidate) MarshalBinary() ([]byte, error)
MarshalBinary interface implementation
func (TupleWithNoValidate) MarshalJSON ¶
func (m TupleWithNoValidate) MarshalJSON() ([]byte, error)
MarshalJSON marshals this tuple type into a JSON array
func (*TupleWithNoValidate) UnmarshalBinary ¶
func (m *TupleWithNoValidate) UnmarshalBinary(b []byte) error
UnmarshalBinary interface implementation
func (*TupleWithNoValidate) UnmarshalJSON ¶
func (m *TupleWithNoValidate) UnmarshalJSON(raw []byte) error
UnmarshalJSON unmarshals this tuple type from a JSON array
type Zzz ¶
type Zzz struct { // This property defines an array of external types (in the same package). // // []MyOtherType // // The maxItems validation is generated and the external validation is called for every item. // // Max Items: 15 Beta []MyOtherType `json:"beta"` // A type is provided (integer), and the implementation is an external type in the same package. // // The maximum validation remains documentary and is ignored by the generated code. // // Maximum: 15 Delta MyInteger `json:"delta,omitempty"` // epsilon Epsilon []custom.MyAlternateType `json:"epsilon"` // Property defined as an external type from package "fred" // Gamma fred.MyAlternateInteger `json:"gamma,omitempty"` // meta Meta MyType `json:"meta,omitempty"` // This property defines an array of external types (in the same package). // // []MyOtherType // // The maxItems validation is generated and the external validation is called for every item. // // Max Items: 15 NullableBeta []*MyOtherType `json:"nullableBeta"` // A type is provided (integer), and the implementation is an external type in the same package. // // The maximum validation remains documentary and is ignored by the generated code. // // NullableDelta *MyInteger // // Maximum: 15 NullableDelta *MyInteger `json:"nullableDelta,omitempty"` // In this example, items are made nullable. // // NullableEpsilon []*custom.MyAlternateType `json:"nullableEpsilon"` // NullableEpsilon []*custom.MyAlternateType `json:"nullableEpsilon"` // Property defined as an external type from package "fred", with a nullable hint for the // external type. // // NullableGamma *fred.MyAlternateInteger `json:"nullableGamma,omitempty"` // NullableGamma *fred.MyAlternateInteger `json:"nullableGamma,omitempty"` // nullable meta NullableMeta MyType `json:"nullableMeta,omitempty"` // req beta // Required: true ReqBeta []MyOtherType `json:"reqBeta"` // req delta // Required: true ReqDelta *MyInteger `json:"reqDelta"` // req epsilon // Required: true ReqEpsilon []custom.MyAlternateType `json:"reqEpsilon"` // req gamma // Required: true ReqGamma *fred.MyAlternateInteger `json:"reqGamma"` // req meta // Required: true ReqMeta *MyType `json:"reqMeta"` }
Zzz This demonstrates variations in generated code, depending on how properties are declared.
Some properties are directly based on some external type and some other define collections (slices, maps) of these external types.
Notice the use of pointers for required properties, but not for slices or maps.
In addition, it demonstrates how pointer generation may be controlled with the nullable hint or the x-nullable extension.
type Zzz struct { Beta []MyOtherType `json:"beta"` Delta MyInteger `json:"delta,omitempty"` Epsilon []custom.MyAlternateType `json:"epsilon"` Gamma fred.MyAlternateInteger `json:"gamma,omitempty"` Meta MyType `json:"meta,omitempty"` NullableBeta []*MyOtherType `json:"nullableBeta"` NullableDelta *MyInteger `json:"nullableDelta,omitempty"` NullableEpsilon []*custom.MyAlternateType `json:"nullableEpsilon"` NullableGamma *fred.MyAlternateInteger `json:"nullableGamma,omitempty"` NullableMeta MyType `json:"nullableMeta,omitempty"` ReqBeta []MyOtherType `json:"reqBeta"` ReqDelta *MyInteger `json:"reqDelta"` ReqEpsilon []custom.MyAlternateType `json:"reqEpsilon"` ReqGamma *fred.MyAlternateInteger `json:"reqGamma"` ReqMeta *MyType `json:"reqMeta"` }
swagger:model Zzz
func (*Zzz) ContextValidate ¶
ContextValidate validate this zzz based on the context it is used
func (*Zzz) MarshalBinary ¶
MarshalBinary interface implementation
func (*Zzz) UnmarshalBinary ¶
UnmarshalBinary interface implementation
Source Files ¶
- array_with_no_validate.go
- embedded_time.go
- map_of_primitives.go
- map_with_no_validate.go
- my_custom_array.go
- my_custom_array_nullable.go
- my_custom_map.go
- my_custom_map_nullable.go
- my_ext_collection.go
- my_interface_object.go
- my_reader_object.go
- my_tuple.go
- my_type.go
- object_with_no_validate.go
- tuple_with_no_validate.go
- zzz.go