-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.gen.go
174 lines (148 loc) · 4.86 KB
/
types.gen.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Package api provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.11.1-0.20220912230023-4a1477f6a8ba DO NOT EDIT.
package api
import (
"encoding/json"
"fmt"
)
// ProblemDetails defines model for ProblemDetails.
type ProblemDetails struct {
// Detail A human-readable explanation specific to this occurrence of the problem.
Detail *string `json:"detail,omitempty"`
// Instance A URI reference that identifies the specific occurrence of the problem.
Instance *string `json:"instance,omitempty"`
// Status The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.
Status *int `json:"status,omitempty"`
// Title A short, human-readable summary of the problem type.
Title *string `json:"title,omitempty"`
// Type A URI reference [RFC3986] that identifies the problem type.
Type *string `json:"type,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
}
// Project defines model for Project.
type Project struct {
// Description Project description
Description *string `json:"description,omitempty"`
// Name Project name. Must be unique across all projects.
Name *string `json:"name,omitempty"`
}
// GetProjectParams defines parameters for GetProject.
type GetProjectParams struct {
// ProjectName The name of the project to retrieve.
ProjectName string `json:"projectName"`
}
// PostProjectJSONRequestBody defines body for PostProject for application/json ContentType.
type PostProjectJSONRequestBody = Project
// Getter for additional properties for ProblemDetails. Returns the specified
// element and whether it was found
func (a ProblemDetails) Get(fieldName string) (value interface{}, found bool) {
if a.AdditionalProperties != nil {
value, found = a.AdditionalProperties[fieldName]
}
return
}
// Setter for additional properties for ProblemDetails
func (a *ProblemDetails) Set(fieldName string, value interface{}) {
if a.AdditionalProperties == nil {
a.AdditionalProperties = make(map[string]interface{})
}
a.AdditionalProperties[fieldName] = value
}
// Override default JSON handling for ProblemDetails to handle AdditionalProperties
func (a *ProblemDetails) UnmarshalJSON(b []byte) error {
object := make(map[string]json.RawMessage)
err := json.Unmarshal(b, &object)
if err != nil {
return err
}
if raw, found := object["detail"]; found {
err = json.Unmarshal(raw, &a.Detail)
if err != nil {
return fmt.Errorf("error reading 'detail': %w", err)
}
delete(object, "detail")
}
if raw, found := object["instance"]; found {
err = json.Unmarshal(raw, &a.Instance)
if err != nil {
return fmt.Errorf("error reading 'instance': %w", err)
}
delete(object, "instance")
}
if raw, found := object["status"]; found {
err = json.Unmarshal(raw, &a.Status)
if err != nil {
return fmt.Errorf("error reading 'status': %w", err)
}
delete(object, "status")
}
if raw, found := object["title"]; found {
err = json.Unmarshal(raw, &a.Title)
if err != nil {
return fmt.Errorf("error reading 'title': %w", err)
}
delete(object, "title")
}
if raw, found := object["type"]; found {
err = json.Unmarshal(raw, &a.Type)
if err != nil {
return fmt.Errorf("error reading 'type': %w", err)
}
delete(object, "type")
}
if len(object) != 0 {
a.AdditionalProperties = make(map[string]interface{})
for fieldName, fieldBuf := range object {
var fieldVal interface{}
err := json.Unmarshal(fieldBuf, &fieldVal)
if err != nil {
return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err)
}
a.AdditionalProperties[fieldName] = fieldVal
}
}
return nil
}
// Override default JSON handling for ProblemDetails to handle AdditionalProperties
func (a ProblemDetails) MarshalJSON() ([]byte, error) {
var err error
object := make(map[string]json.RawMessage)
if a.Detail != nil {
object["detail"], err = json.Marshal(a.Detail)
if err != nil {
return nil, fmt.Errorf("error marshaling 'detail': %w", err)
}
}
if a.Instance != nil {
object["instance"], err = json.Marshal(a.Instance)
if err != nil {
return nil, fmt.Errorf("error marshaling 'instance': %w", err)
}
}
if a.Status != nil {
object["status"], err = json.Marshal(a.Status)
if err != nil {
return nil, fmt.Errorf("error marshaling 'status': %w", err)
}
}
if a.Title != nil {
object["title"], err = json.Marshal(a.Title)
if err != nil {
return nil, fmt.Errorf("error marshaling 'title': %w", err)
}
}
if a.Type != nil {
object["type"], err = json.Marshal(a.Type)
if err != nil {
return nil, fmt.Errorf("error marshaling 'type': %w", err)
}
}
for fieldName, field := range a.AdditionalProperties {
object[fieldName], err = json.Marshal(field)
if err != nil {
return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err)
}
}
return json.Marshal(object)
}