error_response.go 1.6 KB

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