-
Notifications
You must be signed in to change notification settings - Fork 2
/
visitor_gen.go
251 lines (188 loc) · 6.03 KB
/
visitor_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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
package openapi
// This file was automatically generated.
// DO NOT EDIT MANUALLY. All changes will be lost
import (
"context"
"github.com/pkg/errors"
)
var _ = context.Background
var _ = errors.Cause
var ErrVisitAbort = errors.New(`visit aborted (non-error)`)
type callbackVisitorCtxKey struct{}
type componentsVisitorCtxKey struct{}
type contactVisitorCtxKey struct{}
type discriminatorVisitorCtxKey struct{}
type encodingVisitorCtxKey struct{}
type exampleVisitorCtxKey struct{}
type externalDocumentationVisitorCtxKey struct{}
type headerVisitorCtxKey struct{}
type infoVisitorCtxKey struct{}
type licenseVisitorCtxKey struct{}
type linkVisitorCtxKey struct{}
type mediaTypeVisitorCtxKey struct{}
type oauthFlowVisitorCtxKey struct{}
type oauthFlowsVisitorCtxKey struct{}
type openapiVisitorCtxKey struct{}
type operationVisitorCtxKey struct{}
type parameterVisitorCtxKey struct{}
type pathItemVisitorCtxKey struct{}
type pathsVisitorCtxKey struct{}
type requestBodyVisitorCtxKey struct{}
type responseVisitorCtxKey struct{}
type responsesVisitorCtxKey struct{}
type schemaVisitorCtxKey struct{}
type securityRequirementVisitorCtxKey struct{}
type securitySchemeVisitorCtxKey struct{}
type serverVisitorCtxKey struct{}
type serverVariableVisitorCtxKey struct{}
type tagVisitorCtxKey struct{}
// Visit allows you to traverse through the OpenAPI structure
func Visit(ctx context.Context, handler, elem interface{}) error {
if v, ok := handler.(CallbackVisitor); ok {
ctx = context.WithValue(ctx, callbackVisitorCtxKey{}, v)
}
if v, ok := handler.(ComponentsVisitor); ok {
ctx = context.WithValue(ctx, componentsVisitorCtxKey{}, v)
}
if v, ok := handler.(ContactVisitor); ok {
ctx = context.WithValue(ctx, contactVisitorCtxKey{}, v)
}
if v, ok := handler.(DiscriminatorVisitor); ok {
ctx = context.WithValue(ctx, discriminatorVisitorCtxKey{}, v)
}
if v, ok := handler.(EncodingVisitor); ok {
ctx = context.WithValue(ctx, encodingVisitorCtxKey{}, v)
}
if v, ok := handler.(ExampleVisitor); ok {
ctx = context.WithValue(ctx, exampleVisitorCtxKey{}, v)
}
if v, ok := handler.(ExternalDocumentationVisitor); ok {
ctx = context.WithValue(ctx, externalDocumentationVisitorCtxKey{}, v)
}
if v, ok := handler.(HeaderVisitor); ok {
ctx = context.WithValue(ctx, headerVisitorCtxKey{}, v)
}
if v, ok := handler.(InfoVisitor); ok {
ctx = context.WithValue(ctx, infoVisitorCtxKey{}, v)
}
if v, ok := handler.(LicenseVisitor); ok {
ctx = context.WithValue(ctx, licenseVisitorCtxKey{}, v)
}
if v, ok := handler.(LinkVisitor); ok {
ctx = context.WithValue(ctx, linkVisitorCtxKey{}, v)
}
if v, ok := handler.(MediaTypeVisitor); ok {
ctx = context.WithValue(ctx, mediaTypeVisitorCtxKey{}, v)
}
if v, ok := handler.(OAuthFlowVisitor); ok {
ctx = context.WithValue(ctx, oauthFlowVisitorCtxKey{}, v)
}
if v, ok := handler.(OAuthFlowsVisitor); ok {
ctx = context.WithValue(ctx, oauthFlowsVisitorCtxKey{}, v)
}
if v, ok := handler.(OpenAPIVisitor); ok {
ctx = context.WithValue(ctx, openapiVisitorCtxKey{}, v)
}
if v, ok := handler.(OperationVisitor); ok {
ctx = context.WithValue(ctx, operationVisitorCtxKey{}, v)
}
if v, ok := handler.(ParameterVisitor); ok {
ctx = context.WithValue(ctx, parameterVisitorCtxKey{}, v)
}
if v, ok := handler.(PathItemVisitor); ok {
ctx = context.WithValue(ctx, pathItemVisitorCtxKey{}, v)
}
if v, ok := handler.(PathsVisitor); ok {
ctx = context.WithValue(ctx, pathsVisitorCtxKey{}, v)
}
if v, ok := handler.(RequestBodyVisitor); ok {
ctx = context.WithValue(ctx, requestBodyVisitorCtxKey{}, v)
}
if v, ok := handler.(ResponseVisitor); ok {
ctx = context.WithValue(ctx, responseVisitorCtxKey{}, v)
}
if v, ok := handler.(ResponsesVisitor); ok {
ctx = context.WithValue(ctx, responsesVisitorCtxKey{}, v)
}
if v, ok := handler.(SchemaVisitor); ok {
ctx = context.WithValue(ctx, schemaVisitorCtxKey{}, v)
}
if v, ok := handler.(SecurityRequirementVisitor); ok {
ctx = context.WithValue(ctx, securityRequirementVisitorCtxKey{}, v)
}
if v, ok := handler.(SecuritySchemeVisitor); ok {
ctx = context.WithValue(ctx, securitySchemeVisitorCtxKey{}, v)
}
if v, ok := handler.(ServerVisitor); ok {
ctx = context.WithValue(ctx, serverVisitorCtxKey{}, v)
}
if v, ok := handler.(ServerVariableVisitor); ok {
ctx = context.WithValue(ctx, serverVariableVisitorCtxKey{}, v)
}
if v, ok := handler.(TagVisitor); ok {
ctx = context.WithValue(ctx, tagVisitorCtxKey{}, v)
}
return visit(ctx, elem)
}
func visit(ctx context.Context, elem interface{}) error {
switch elem := elem.(type) {
case Callback:
return visitCallback(ctx, elem)
case Components:
return visitComponents(ctx, elem)
case Contact:
return visitContact(ctx, elem)
case Discriminator:
return visitDiscriminator(ctx, elem)
case Encoding:
return visitEncoding(ctx, elem)
case Example:
return visitExample(ctx, elem)
case ExternalDocumentation:
return visitExternalDocumentation(ctx, elem)
case Header:
return visitHeader(ctx, elem)
case Info:
return visitInfo(ctx, elem)
case License:
return visitLicense(ctx, elem)
case Link:
return visitLink(ctx, elem)
case MediaType:
return visitMediaType(ctx, elem)
case OAuthFlow:
return visitOAuthFlow(ctx, elem)
case OAuthFlows:
return visitOAuthFlows(ctx, elem)
case OpenAPI:
return visitOpenAPI(ctx, elem)
case Operation:
return visitOperation(ctx, elem)
case Parameter:
return visitParameter(ctx, elem)
case PathItem:
return visitPathItem(ctx, elem)
case Paths:
return visitPaths(ctx, elem)
case RequestBody:
return visitRequestBody(ctx, elem)
case Response:
return visitResponse(ctx, elem)
case Responses:
return visitResponses(ctx, elem)
case Schema:
return visitSchema(ctx, elem)
case SecurityRequirement:
return visitSecurityRequirement(ctx, elem)
case SecurityScheme:
return visitSecurityScheme(ctx, elem)
case Server:
return visitServer(ctx, elem)
case ServerVariable:
return visitServerVariable(ctx, elem)
case Tag:
return visitTag(ctx, elem)
default:
return errors.Errorf(`unknown element %T`, elem)
}
}