-
Notifications
You must be signed in to change notification settings - Fork 1
/
model_error.go
103 lines (83 loc) · 2.32 KB
/
model_error.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
FastAPI
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
API version: 0.1.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package goyeti
import (
"encoding/json"
"fmt"
)
// Error struct for Error
type Error struct {
ArrayOfMapmapOfStringAny *[]map[string]interface{}
String *string
}
// Unmarshal JSON data into any of the pointers in the struct
func (dst *Error) UnmarshalJSON(data []byte) error {
var err error
// try to unmarshal JSON data into ArrayOfMapmapOfStringAny
err = json.Unmarshal(data, &dst.ArrayOfMapmapOfStringAny)
if err == nil {
jsonArrayOfMapmapOfStringAny, _ := json.Marshal(dst.ArrayOfMapmapOfStringAny)
if string(jsonArrayOfMapmapOfStringAny) == "{}" { // empty struct
dst.ArrayOfMapmapOfStringAny = nil
} else {
return nil // data stored in dst.ArrayOfMapmapOfStringAny, return on the first match
}
} else {
dst.ArrayOfMapmapOfStringAny = nil
}
// try to unmarshal JSON data into String
err = json.Unmarshal(data, &dst.String)
if err == nil {
jsonString, _ := json.Marshal(dst.String)
if string(jsonString) == "{}" { // empty struct
dst.String = nil
} else {
return nil // data stored in dst.String, return on the first match
}
} else {
dst.String = nil
}
return fmt.Errorf("data failed to match schemas in anyOf(Error)")
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src Error) MarshalJSON() ([]byte, error) {
if src.ArrayOfMapmapOfStringAny != nil {
return json.Marshal(&src.ArrayOfMapmapOfStringAny)
}
if src.String != nil {
return json.Marshal(&src.String)
}
return nil, nil // no data in anyOf schemas
}
type NullableError struct {
value *Error
isSet bool
}
func (v NullableError) Get() *Error {
return v.value
}
func (v *NullableError) Set(val *Error) {
v.value = val
v.isSet = true
}
func (v NullableError) IsSet() bool {
return v.isSet
}
func (v *NullableError) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableError(val *Error) *NullableError {
return &NullableError{value: val, isSet: true}
}
func (v NullableError) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableError) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}