-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenapi.go
277 lines (240 loc) · 10.7 KB
/
openapi.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
// Copyright 2022 beego
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package oai
type API struct {
Openapi string `json:"openapi" yaml:"openapi"`
Info Info `json:"info" yaml:"info"`
JsonSchemaDialect string `json:"jsonSchemaDialect" yaml:"jsonSchemaDialect"`
Servers []Server `json:"servers" yaml:"servers"`
Paths map[string]Path `json:"paths" yaml:"paths"`
Webhooks map[string]PathValue `json:"webhooks" yaml:"webhooks"`
Components Components
}
type Components struct {
Schemas map[string]Schema `json:"schemas" yaml:"schemas"`
Responses map[string]ResponseValue `json:"responses" yaml:"responses"`
Parameters map[string]ParameterValue `json:"parameters" yaml:"parameters"`
Examples map[string]ExampleValue `json:"examples" yaml:"examples"`
RequestBodies map[string]RequestBodyValue `json:"requestBodies" yaml:"requestBodies"`
Headers map[string]HeaderValue `json:"headers" yaml:"headers"`
SecuritySchemes map[string]SecurityScheme `json:"securitySchemes" yaml:"securitySchemes"`
Links map[string]LinkValue `json:"links" yaml:"links"`
Callbacks map[string]CallbackValue `json:"callbacks" yaml:"callbacks"`
PathItems map[string]PathValue `json:"pathItems" yaml:"pathItems"`
Security SecurityRequirement `json:"security" yaml:"security"`
Tags []Tag `json:"tags" yaml:"tags"`
ExternalDocs ExternalDoc `json:"externalDocs" yaml:"externalDocs"`
}
type Tag struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
ExternalDocs ExternalDoc `json:"externalDocs" yaml:"externalDocs"`
}
type SecurityScheme struct {
Type string `json:"type" yaml:"type"`
Description string `json:"description" yaml:"description"`
Name string `json:"name" yaml:"name"`
In string `json:"in" yaml:"in"`
Scheme string `json:"scheme" yaml:"scheme"`
BearerFormat string `json:"bearerFormat" yaml:"bearerFormat"`
Flows OAuthFlows `json:"flows" yaml:"flows"`
OpenIdConnectUrl string `json:"openIdConnectUrl" yaml:"openIdConnectUrl"`
}
type OAuthFlows struct {
Implicit OAuthFlow `json:"implicit" yaml:"implicit"`
Password OAuthFlow `json:"password" yaml:"password"`
ClientCredentials OAuthFlow `json:"clientCredential" yaml:"clientCredential"`
AuthorizationCode OAuthFlow `json:"authorizationCode" yaml:"authorizationCode"`
}
type OAuthFlow struct {
AuthorizationUrl string `json:"authorizationUrl" yaml:"authorizationUrl"`
TokenUrl string `json:"tokenUrl" yaml:"tokenUrl"`
RefreshUrl string `json:"RefreshUrl" yaml:"refreshUrl"`
Scopes map[string]string `json:"scopes" yaml:"scopes"`
}
type ResponseValue struct {
Response
Reference
}
type PathValue struct {
Path
Reference
}
type Path struct {
Ref string `json:"$ref" yaml:"$ref"`
Summary string `json:"summary" yaml:"summary"`
Description string `json:"description" yaml:"description"`
Get Operation `json:"get" yaml:"get"`
Put Operation `json:"put" yaml:"put"`
Post Operation `json:"post" yaml:"post"`
Delete Operation `json:"delete" yaml:"delete"`
Options Operation `json:"options" yaml:"options"`
Head Operation `json:"head" yaml:"head"`
Patch Operation `json:"patch" yaml:"patch"`
Trace Operation `json:"trace" yaml:"trace"`
Servers []Server `json:"servers" yaml:"servers"`
Parameters []ParameterValue `json:"parameters" yaml:"parameters"`
}
type Operation struct {
Tags []string `json:"tags" yaml:"tags"`
Summary string `json:"summary" yaml:"summary"`
Description string `json:"description" yaml:"description"`
ExternalDocs ExternalDoc `json:"externalDocs" yaml:"externalDocs"`
OperationId string `json:"operationId" yaml:"operationId"`
Parameters []ParameterValue `json:"parameters" yaml:"parameters"`
RequestBody RequestBodyValue `json:"requestBody" yaml:"requestBody"`
Responses map[string]Response `json:"responses" yaml:"responses"`
Callbacks map[string]CallbackValue `json:"callbacks" yaml:"callbacks"`
Deprecated bool `json:"deprecated" yaml:"deprecated"`
Security []SecurityRequirement `json:"security" yaml:"security"`
Servers []Server `json:"servers" yaml:"servers"`
}
type SecurityRequirement map[string][]string
type CallbackValue struct {
CallbackMap
Reference
}
type CallbackMap map[string]Callback
type Callback struct {
Path
Reference
}
type Response struct {
Description string `json:"description" yaml:"description"`
Headers map[string]HeaderValue `json:"headers" yaml:"headers"`
Content map[string]MediaType `json:"content" yaml:"content"`
Links map[string]LinkValue `json:"links" yaml:"links"`
}
type LinkValue struct {
Link
Reference
}
type Link struct {
OperationRef string `json:"operationRef" yaml:"operationRef"`
OperationId string `json:"operationId" yaml:"operationId"`
Parameters map[string]string `json:"parameters" yaml:"parameters"`
RequestBody string `json:"requestBody" yaml:"requestBody"`
Description string `json:"description" yaml:"description"`
Server Server `json:"server" yaml:"server"`
}
type RequestBodyValue struct {
RequestBody
Reference
}
type RequestBody struct {
Description string `json:"description" yaml:"description"`
Content map[string]MediaType `json:"content" yaml:"content"`
Required bool `json:"required" yaml:"required"`
}
type ParameterValue struct {
Parameter
Reference
}
type Parameter struct {
Name string `json:"name" yaml:"name"`
In string `json:"in" yaml:"in"`
Description string `json:"description" yaml:"description"`
Required bool `json:"required" yaml:"required"`
Deprecated bool `json:"deprecated" yaml:"deprecated"`
AllowEmptyValue bool `json:"allowEmptyValue" yaml:"allowEmptyValue"`
Style string `json:"style" yaml:"style"`
Explode bool `json:"explode" yaml:"explode"`
AllowReserved bool `json:"allowReserved" yaml:"allowReserved"`
Schema Schema `json:"schema" yaml:"schema"`
Example ExampleValue `json:"example" yaml:"example"`
Examples map[string]ExampleValue `json:"examples" yaml:"examples"`
Content map[string]MediaType `json:"content" yaml:"content"`
}
type MediaType struct {
Schema Schema `json:"schema" yaml:"schema"`
Example ExampleValue `json:"example" yaml:"example"`
Examples map[string]ExampleValue `json:"examples" yaml:"examples"`
Encoding map[string]Encoding `json:"encoding" yaml:"encoding"`
}
type Encoding struct {
ContentType string `json:"contentType" yaml:"contentType"`
Headers map[string]HeaderValue `json:"headers" yaml:"headers"`
Style string `json:"style" yaml:"style"`
Explode bool `json:"explode" yaml:"explode"`
AllowReserved bool `json:"allowReserved" yaml:"allowReserved"`
}
type HeaderValue struct {
Header
Reference
}
type Header Parameter
type ExampleValue struct {
Example
Reference
}
type Reference struct {
Ref string `json:"$ref" yaml:"$ref"`
Summary string `json:"summary" yaml:"summary"`
Description string `json:"description" yaml:"description"`
}
type Example struct {
Summary string `json:"summary" yaml:"summary"`
Description string `json:"description" yaml:"description"`
Value interface{} `json:"value" yaml:"value"`
ExternalValue string `json:"externalValue" yaml:"externalValue"`
}
type Schema struct {
Discriminator Discriminator `json:"discriminator" yaml:"discriminator"`
XML XML `json:"xml" yaml:"xml"`
ExternalDocs ExternalDoc `json:"externalDocs" yaml:"externalDocs"`
}
type XML struct {
Name string `json:"name" yaml:"name"`
Namespace string `json:"namespace" yaml:"namespace"`
Prefix string `json:"prefix" yaml:"prefix"`
Attribute bool `json:"attribute" yaml:"attribute"`
Wrapped bool `json:"wrapped" yaml:"wrapped"`
}
type Discriminator struct {
PropertyName string `json:"propertyName" yaml:"propertyName"`
Mapping map[string]string `json:"mapping" yaml:"mapping"`
}
type ExternalDoc struct {
Description string `json:"description" yaml:"description"`
Url string `json:"url" yaml:"url"`
}
type Server struct {
Url string `json:"url" yaml:"url"`
Description string `json:"description" yaml:"description"`
Variables map[string]ServerVariable `json:"variables" yaml:"variables"`
}
type ServerVariable struct {
Enum []string `json:"enum" yaml:"enum"`
Default string `json:"default" yaml:"default"`
Description string `json:"description" yaml:"description"`
}
type Info struct {
Title string `json:"title" yaml:"title"`
Summary string `json:"summary" yaml:"summary"`
Description string `json:"description" yaml:"description"`
TermsOfService string `json:"termsOfService" yaml:"termsOfService"`
Contact Contact `json:"contact" yaml:"contact"`
License License `json:"license" yaml:"license"`
Version string `json:"version" yaml:"version"`
}
type License struct {
Name string `json:"name" yaml:"name"`
Identifier string `json:"identifier" yaml:"identifier"`
Url string `json:"url" yaml:"url"`
}
type Contact struct {
Name string `json:"name" yaml:"name"`
Url string `json:"url" yaml:"url"`
Email string `json:"email" yaml:"email"`
}