forked from go-swagger/go-swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_reader_object.go
71 lines (59 loc) · 2.06 KB
/
my_reader_object.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/circl-dev/go-swagger/examples/external-types/fred"
alternate "github.com/circl-dev/go-swagger/examples/external-types/fred"
)
// 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
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"`
}
// Validate validates this my reader object
func (m *MyReaderObject) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this my reader object based on context it is used
func (m *MyReaderObject) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *MyReaderObject) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *MyReaderObject) UnmarshalBinary(b []byte) error {
var res MyReaderObject
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}