github.com/rzurga/go-swagger@v0.28.1-0.20211109195225-5d1f453ffa3a/examples/auto-configure/models/error.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 "github.com/go-openapi/validate" 15 ) 16 17 // Error error 18 // 19 // swagger:model error 20 type Error struct { 21 22 // code 23 Code int64 `json:"code,omitempty"` 24 25 // message 26 // Required: true 27 Message *string `json:"message"` 28 } 29 30 // Validate validates this error 31 func (m *Error) Validate(formats strfmt.Registry) error { 32 var res []error 33 34 if err := m.validateMessage(formats); err != nil { 35 res = append(res, err) 36 } 37 38 if len(res) > 0 { 39 return errors.CompositeValidationError(res...) 40 } 41 return nil 42 } 43 44 func (m *Error) validateMessage(formats strfmt.Registry) error { 45 46 if err := validate.Required("message", "body", m.Message); err != nil { 47 return err 48 } 49 50 return nil 51 } 52 53 // ContextValidate validates this error based on context it is used 54 func (m *Error) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 55 return nil 56 } 57 58 // MarshalBinary interface implementation 59 func (m *Error) MarshalBinary() ([]byte, error) { 60 if m == nil { 61 return nil, nil 62 } 63 return swag.WriteJSON(m) 64 } 65 66 // UnmarshalBinary interface implementation 67 func (m *Error) UnmarshalBinary(b []byte) error { 68 var res Error 69 if err := swag.ReadJSON(b, &res); err != nil { 70 return err 71 } 72 *m = res 73 return nil 74 }