sslobodr | d046be8 | 2019-01-16 10:02:22 -0500 | [diff] [blame] | 1 | // Copyright 2017 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // THIS FILE IS AUTOMATICALLY GENERATED. |
| 16 | |
| 17 | package openapi_v2 |
| 18 | |
| 19 | import ( |
| 20 | "fmt" |
| 21 | "github.com/googleapis/gnostic/compiler" |
| 22 | "gopkg.in/yaml.v2" |
| 23 | "regexp" |
| 24 | "strings" |
| 25 | ) |
| 26 | |
| 27 | // Version returns the package name (and OpenAPI version). |
| 28 | func Version() string { |
| 29 | return "openapi_v2" |
| 30 | } |
| 31 | |
| 32 | // NewAdditionalPropertiesItem creates an object of type AdditionalPropertiesItem if possible, returning an error if not. |
| 33 | func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*AdditionalPropertiesItem, error) { |
| 34 | errors := make([]error, 0) |
| 35 | x := &AdditionalPropertiesItem{} |
| 36 | matched := false |
| 37 | // Schema schema = 1; |
| 38 | { |
| 39 | m, ok := compiler.UnpackMap(in) |
| 40 | if ok { |
| 41 | // errors might be ok here, they mean we just don't have the right subtype |
| 42 | t, matchingError := NewSchema(m, compiler.NewContext("schema", context)) |
| 43 | if matchingError == nil { |
| 44 | x.Oneof = &AdditionalPropertiesItem_Schema{Schema: t} |
| 45 | matched = true |
| 46 | } else { |
| 47 | errors = append(errors, matchingError) |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | // bool boolean = 2; |
| 52 | boolValue, ok := in.(bool) |
| 53 | if ok { |
| 54 | x.Oneof = &AdditionalPropertiesItem_Boolean{Boolean: boolValue} |
| 55 | } |
| 56 | if matched { |
| 57 | // since the oneof matched one of its possibilities, discard any matching errors |
| 58 | errors = make([]error, 0) |
| 59 | } |
| 60 | return x, compiler.NewErrorGroupOrNil(errors) |
| 61 | } |
| 62 | |
| 63 | // NewAny creates an object of type Any if possible, returning an error if not. |
| 64 | func NewAny(in interface{}, context *compiler.Context) (*Any, error) { |
| 65 | errors := make([]error, 0) |
| 66 | x := &Any{} |
| 67 | bytes, _ := yaml.Marshal(in) |
| 68 | x.Yaml = string(bytes) |
| 69 | return x, compiler.NewErrorGroupOrNil(errors) |
| 70 | } |
| 71 | |
| 72 | // NewApiKeySecurity creates an object of type ApiKeySecurity if possible, returning an error if not. |
| 73 | func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecurity, error) { |
| 74 | errors := make([]error, 0) |
| 75 | x := &ApiKeySecurity{} |
| 76 | m, ok := compiler.UnpackMap(in) |
| 77 | if !ok { |
| 78 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 79 | errors = append(errors, compiler.NewError(context, message)) |
| 80 | } else { |
| 81 | requiredKeys := []string{"in", "name", "type"} |
| 82 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 83 | if len(missingKeys) > 0 { |
| 84 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 85 | errors = append(errors, compiler.NewError(context, message)) |
| 86 | } |
| 87 | allowedKeys := []string{"description", "in", "name", "type"} |
| 88 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 89 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 90 | if len(invalidKeys) > 0 { |
| 91 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 92 | errors = append(errors, compiler.NewError(context, message)) |
| 93 | } |
| 94 | // string type = 1; |
| 95 | v1 := compiler.MapValueForKey(m, "type") |
| 96 | if v1 != nil { |
| 97 | x.Type, ok = v1.(string) |
| 98 | if !ok { |
| 99 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 100 | errors = append(errors, compiler.NewError(context, message)) |
| 101 | } |
| 102 | // check for valid enum values |
| 103 | // [apiKey] |
| 104 | if ok && !compiler.StringArrayContainsValue([]string{"apiKey"}, x.Type) { |
| 105 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 106 | errors = append(errors, compiler.NewError(context, message)) |
| 107 | } |
| 108 | } |
| 109 | // string name = 2; |
| 110 | v2 := compiler.MapValueForKey(m, "name") |
| 111 | if v2 != nil { |
| 112 | x.Name, ok = v2.(string) |
| 113 | if !ok { |
| 114 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v2, v2) |
| 115 | errors = append(errors, compiler.NewError(context, message)) |
| 116 | } |
| 117 | } |
| 118 | // string in = 3; |
| 119 | v3 := compiler.MapValueForKey(m, "in") |
| 120 | if v3 != nil { |
| 121 | x.In, ok = v3.(string) |
| 122 | if !ok { |
| 123 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) |
| 124 | errors = append(errors, compiler.NewError(context, message)) |
| 125 | } |
| 126 | // check for valid enum values |
| 127 | // [header query] |
| 128 | if ok && !compiler.StringArrayContainsValue([]string{"header", "query"}, x.In) { |
| 129 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) |
| 130 | errors = append(errors, compiler.NewError(context, message)) |
| 131 | } |
| 132 | } |
| 133 | // string description = 4; |
| 134 | v4 := compiler.MapValueForKey(m, "description") |
| 135 | if v4 != nil { |
| 136 | x.Description, ok = v4.(string) |
| 137 | if !ok { |
| 138 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) |
| 139 | errors = append(errors, compiler.NewError(context, message)) |
| 140 | } |
| 141 | } |
| 142 | // repeated NamedAny vendor_extension = 5; |
| 143 | // MAP: Any ^x- |
| 144 | x.VendorExtension = make([]*NamedAny, 0) |
| 145 | for _, item := range m { |
| 146 | k, ok := compiler.StringValue(item.Key) |
| 147 | if ok { |
| 148 | v := item.Value |
| 149 | if strings.HasPrefix(k, "x-") { |
| 150 | pair := &NamedAny{} |
| 151 | pair.Name = k |
| 152 | result := &Any{} |
| 153 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 154 | if handled { |
| 155 | if err != nil { |
| 156 | errors = append(errors, err) |
| 157 | } else { |
| 158 | bytes, _ := yaml.Marshal(v) |
| 159 | result.Yaml = string(bytes) |
| 160 | result.Value = resultFromExt |
| 161 | pair.Value = result |
| 162 | } |
| 163 | } else { |
| 164 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 165 | if err != nil { |
| 166 | errors = append(errors, err) |
| 167 | } |
| 168 | } |
| 169 | x.VendorExtension = append(x.VendorExtension, pair) |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | return x, compiler.NewErrorGroupOrNil(errors) |
| 175 | } |
| 176 | |
| 177 | // NewBasicAuthenticationSecurity creates an object of type BasicAuthenticationSecurity if possible, returning an error if not. |
| 178 | func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) (*BasicAuthenticationSecurity, error) { |
| 179 | errors := make([]error, 0) |
| 180 | x := &BasicAuthenticationSecurity{} |
| 181 | m, ok := compiler.UnpackMap(in) |
| 182 | if !ok { |
| 183 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 184 | errors = append(errors, compiler.NewError(context, message)) |
| 185 | } else { |
| 186 | requiredKeys := []string{"type"} |
| 187 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 188 | if len(missingKeys) > 0 { |
| 189 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 190 | errors = append(errors, compiler.NewError(context, message)) |
| 191 | } |
| 192 | allowedKeys := []string{"description", "type"} |
| 193 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 194 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 195 | if len(invalidKeys) > 0 { |
| 196 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 197 | errors = append(errors, compiler.NewError(context, message)) |
| 198 | } |
| 199 | // string type = 1; |
| 200 | v1 := compiler.MapValueForKey(m, "type") |
| 201 | if v1 != nil { |
| 202 | x.Type, ok = v1.(string) |
| 203 | if !ok { |
| 204 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 205 | errors = append(errors, compiler.NewError(context, message)) |
| 206 | } |
| 207 | // check for valid enum values |
| 208 | // [basic] |
| 209 | if ok && !compiler.StringArrayContainsValue([]string{"basic"}, x.Type) { |
| 210 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 211 | errors = append(errors, compiler.NewError(context, message)) |
| 212 | } |
| 213 | } |
| 214 | // string description = 2; |
| 215 | v2 := compiler.MapValueForKey(m, "description") |
| 216 | if v2 != nil { |
| 217 | x.Description, ok = v2.(string) |
| 218 | if !ok { |
| 219 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) |
| 220 | errors = append(errors, compiler.NewError(context, message)) |
| 221 | } |
| 222 | } |
| 223 | // repeated NamedAny vendor_extension = 3; |
| 224 | // MAP: Any ^x- |
| 225 | x.VendorExtension = make([]*NamedAny, 0) |
| 226 | for _, item := range m { |
| 227 | k, ok := compiler.StringValue(item.Key) |
| 228 | if ok { |
| 229 | v := item.Value |
| 230 | if strings.HasPrefix(k, "x-") { |
| 231 | pair := &NamedAny{} |
| 232 | pair.Name = k |
| 233 | result := &Any{} |
| 234 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 235 | if handled { |
| 236 | if err != nil { |
| 237 | errors = append(errors, err) |
| 238 | } else { |
| 239 | bytes, _ := yaml.Marshal(v) |
| 240 | result.Yaml = string(bytes) |
| 241 | result.Value = resultFromExt |
| 242 | pair.Value = result |
| 243 | } |
| 244 | } else { |
| 245 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 246 | if err != nil { |
| 247 | errors = append(errors, err) |
| 248 | } |
| 249 | } |
| 250 | x.VendorExtension = append(x.VendorExtension, pair) |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | return x, compiler.NewErrorGroupOrNil(errors) |
| 256 | } |
| 257 | |
| 258 | // NewBodyParameter creates an object of type BodyParameter if possible, returning an error if not. |
| 259 | func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter, error) { |
| 260 | errors := make([]error, 0) |
| 261 | x := &BodyParameter{} |
| 262 | m, ok := compiler.UnpackMap(in) |
| 263 | if !ok { |
| 264 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 265 | errors = append(errors, compiler.NewError(context, message)) |
| 266 | } else { |
| 267 | requiredKeys := []string{"in", "name", "schema"} |
| 268 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 269 | if len(missingKeys) > 0 { |
| 270 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 271 | errors = append(errors, compiler.NewError(context, message)) |
| 272 | } |
| 273 | allowedKeys := []string{"description", "in", "name", "required", "schema"} |
| 274 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 275 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 276 | if len(invalidKeys) > 0 { |
| 277 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 278 | errors = append(errors, compiler.NewError(context, message)) |
| 279 | } |
| 280 | // string description = 1; |
| 281 | v1 := compiler.MapValueForKey(m, "description") |
| 282 | if v1 != nil { |
| 283 | x.Description, ok = v1.(string) |
| 284 | if !ok { |
| 285 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) |
| 286 | errors = append(errors, compiler.NewError(context, message)) |
| 287 | } |
| 288 | } |
| 289 | // string name = 2; |
| 290 | v2 := compiler.MapValueForKey(m, "name") |
| 291 | if v2 != nil { |
| 292 | x.Name, ok = v2.(string) |
| 293 | if !ok { |
| 294 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v2, v2) |
| 295 | errors = append(errors, compiler.NewError(context, message)) |
| 296 | } |
| 297 | } |
| 298 | // string in = 3; |
| 299 | v3 := compiler.MapValueForKey(m, "in") |
| 300 | if v3 != nil { |
| 301 | x.In, ok = v3.(string) |
| 302 | if !ok { |
| 303 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) |
| 304 | errors = append(errors, compiler.NewError(context, message)) |
| 305 | } |
| 306 | // check for valid enum values |
| 307 | // [body] |
| 308 | if ok && !compiler.StringArrayContainsValue([]string{"body"}, x.In) { |
| 309 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) |
| 310 | errors = append(errors, compiler.NewError(context, message)) |
| 311 | } |
| 312 | } |
| 313 | // bool required = 4; |
| 314 | v4 := compiler.MapValueForKey(m, "required") |
| 315 | if v4 != nil { |
| 316 | x.Required, ok = v4.(bool) |
| 317 | if !ok { |
| 318 | message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v4, v4) |
| 319 | errors = append(errors, compiler.NewError(context, message)) |
| 320 | } |
| 321 | } |
| 322 | // Schema schema = 5; |
| 323 | v5 := compiler.MapValueForKey(m, "schema") |
| 324 | if v5 != nil { |
| 325 | var err error |
| 326 | x.Schema, err = NewSchema(v5, compiler.NewContext("schema", context)) |
| 327 | if err != nil { |
| 328 | errors = append(errors, err) |
| 329 | } |
| 330 | } |
| 331 | // repeated NamedAny vendor_extension = 6; |
| 332 | // MAP: Any ^x- |
| 333 | x.VendorExtension = make([]*NamedAny, 0) |
| 334 | for _, item := range m { |
| 335 | k, ok := compiler.StringValue(item.Key) |
| 336 | if ok { |
| 337 | v := item.Value |
| 338 | if strings.HasPrefix(k, "x-") { |
| 339 | pair := &NamedAny{} |
| 340 | pair.Name = k |
| 341 | result := &Any{} |
| 342 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 343 | if handled { |
| 344 | if err != nil { |
| 345 | errors = append(errors, err) |
| 346 | } else { |
| 347 | bytes, _ := yaml.Marshal(v) |
| 348 | result.Yaml = string(bytes) |
| 349 | result.Value = resultFromExt |
| 350 | pair.Value = result |
| 351 | } |
| 352 | } else { |
| 353 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 354 | if err != nil { |
| 355 | errors = append(errors, err) |
| 356 | } |
| 357 | } |
| 358 | x.VendorExtension = append(x.VendorExtension, pair) |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | return x, compiler.NewErrorGroupOrNil(errors) |
| 364 | } |
| 365 | |
| 366 | // NewContact creates an object of type Contact if possible, returning an error if not. |
| 367 | func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { |
| 368 | errors := make([]error, 0) |
| 369 | x := &Contact{} |
| 370 | m, ok := compiler.UnpackMap(in) |
| 371 | if !ok { |
| 372 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 373 | errors = append(errors, compiler.NewError(context, message)) |
| 374 | } else { |
| 375 | allowedKeys := []string{"email", "name", "url"} |
| 376 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 377 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 378 | if len(invalidKeys) > 0 { |
| 379 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 380 | errors = append(errors, compiler.NewError(context, message)) |
| 381 | } |
| 382 | // string name = 1; |
| 383 | v1 := compiler.MapValueForKey(m, "name") |
| 384 | if v1 != nil { |
| 385 | x.Name, ok = v1.(string) |
| 386 | if !ok { |
| 387 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 388 | errors = append(errors, compiler.NewError(context, message)) |
| 389 | } |
| 390 | } |
| 391 | // string url = 2; |
| 392 | v2 := compiler.MapValueForKey(m, "url") |
| 393 | if v2 != nil { |
| 394 | x.Url, ok = v2.(string) |
| 395 | if !ok { |
| 396 | message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) |
| 397 | errors = append(errors, compiler.NewError(context, message)) |
| 398 | } |
| 399 | } |
| 400 | // string email = 3; |
| 401 | v3 := compiler.MapValueForKey(m, "email") |
| 402 | if v3 != nil { |
| 403 | x.Email, ok = v3.(string) |
| 404 | if !ok { |
| 405 | message := fmt.Sprintf("has unexpected value for email: %+v (%T)", v3, v3) |
| 406 | errors = append(errors, compiler.NewError(context, message)) |
| 407 | } |
| 408 | } |
| 409 | // repeated NamedAny vendor_extension = 4; |
| 410 | // MAP: Any ^x- |
| 411 | x.VendorExtension = make([]*NamedAny, 0) |
| 412 | for _, item := range m { |
| 413 | k, ok := compiler.StringValue(item.Key) |
| 414 | if ok { |
| 415 | v := item.Value |
| 416 | if strings.HasPrefix(k, "x-") { |
| 417 | pair := &NamedAny{} |
| 418 | pair.Name = k |
| 419 | result := &Any{} |
| 420 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 421 | if handled { |
| 422 | if err != nil { |
| 423 | errors = append(errors, err) |
| 424 | } else { |
| 425 | bytes, _ := yaml.Marshal(v) |
| 426 | result.Yaml = string(bytes) |
| 427 | result.Value = resultFromExt |
| 428 | pair.Value = result |
| 429 | } |
| 430 | } else { |
| 431 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 432 | if err != nil { |
| 433 | errors = append(errors, err) |
| 434 | } |
| 435 | } |
| 436 | x.VendorExtension = append(x.VendorExtension, pair) |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | return x, compiler.NewErrorGroupOrNil(errors) |
| 442 | } |
| 443 | |
| 444 | // NewDefault creates an object of type Default if possible, returning an error if not. |
| 445 | func NewDefault(in interface{}, context *compiler.Context) (*Default, error) { |
| 446 | errors := make([]error, 0) |
| 447 | x := &Default{} |
| 448 | m, ok := compiler.UnpackMap(in) |
| 449 | if !ok { |
| 450 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 451 | errors = append(errors, compiler.NewError(context, message)) |
| 452 | } else { |
| 453 | // repeated NamedAny additional_properties = 1; |
| 454 | // MAP: Any |
| 455 | x.AdditionalProperties = make([]*NamedAny, 0) |
| 456 | for _, item := range m { |
| 457 | k, ok := compiler.StringValue(item.Key) |
| 458 | if ok { |
| 459 | v := item.Value |
| 460 | pair := &NamedAny{} |
| 461 | pair.Name = k |
| 462 | result := &Any{} |
| 463 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 464 | if handled { |
| 465 | if err != nil { |
| 466 | errors = append(errors, err) |
| 467 | } else { |
| 468 | bytes, _ := yaml.Marshal(v) |
| 469 | result.Yaml = string(bytes) |
| 470 | result.Value = resultFromExt |
| 471 | pair.Value = result |
| 472 | } |
| 473 | } else { |
| 474 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 475 | if err != nil { |
| 476 | errors = append(errors, err) |
| 477 | } |
| 478 | } |
| 479 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 480 | } |
| 481 | } |
| 482 | } |
| 483 | return x, compiler.NewErrorGroupOrNil(errors) |
| 484 | } |
| 485 | |
| 486 | // NewDefinitions creates an object of type Definitions if possible, returning an error if not. |
| 487 | func NewDefinitions(in interface{}, context *compiler.Context) (*Definitions, error) { |
| 488 | errors := make([]error, 0) |
| 489 | x := &Definitions{} |
| 490 | m, ok := compiler.UnpackMap(in) |
| 491 | if !ok { |
| 492 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 493 | errors = append(errors, compiler.NewError(context, message)) |
| 494 | } else { |
| 495 | // repeated NamedSchema additional_properties = 1; |
| 496 | // MAP: Schema |
| 497 | x.AdditionalProperties = make([]*NamedSchema, 0) |
| 498 | for _, item := range m { |
| 499 | k, ok := compiler.StringValue(item.Key) |
| 500 | if ok { |
| 501 | v := item.Value |
| 502 | pair := &NamedSchema{} |
| 503 | pair.Name = k |
| 504 | var err error |
| 505 | pair.Value, err = NewSchema(v, compiler.NewContext(k, context)) |
| 506 | if err != nil { |
| 507 | errors = append(errors, err) |
| 508 | } |
| 509 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 510 | } |
| 511 | } |
| 512 | } |
| 513 | return x, compiler.NewErrorGroupOrNil(errors) |
| 514 | } |
| 515 | |
| 516 | // NewDocument creates an object of type Document if possible, returning an error if not. |
| 517 | func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { |
| 518 | errors := make([]error, 0) |
| 519 | x := &Document{} |
| 520 | m, ok := compiler.UnpackMap(in) |
| 521 | if !ok { |
| 522 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 523 | errors = append(errors, compiler.NewError(context, message)) |
| 524 | } else { |
| 525 | requiredKeys := []string{"info", "paths", "swagger"} |
| 526 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 527 | if len(missingKeys) > 0 { |
| 528 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 529 | errors = append(errors, compiler.NewError(context, message)) |
| 530 | } |
| 531 | allowedKeys := []string{"basePath", "consumes", "definitions", "externalDocs", "host", "info", "parameters", "paths", "produces", "responses", "schemes", "security", "securityDefinitions", "swagger", "tags"} |
| 532 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 533 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 534 | if len(invalidKeys) > 0 { |
| 535 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 536 | errors = append(errors, compiler.NewError(context, message)) |
| 537 | } |
| 538 | // string swagger = 1; |
| 539 | v1 := compiler.MapValueForKey(m, "swagger") |
| 540 | if v1 != nil { |
| 541 | x.Swagger, ok = v1.(string) |
| 542 | if !ok { |
| 543 | message := fmt.Sprintf("has unexpected value for swagger: %+v (%T)", v1, v1) |
| 544 | errors = append(errors, compiler.NewError(context, message)) |
| 545 | } |
| 546 | // check for valid enum values |
| 547 | // [2.0] |
| 548 | if ok && !compiler.StringArrayContainsValue([]string{"2.0"}, x.Swagger) { |
| 549 | message := fmt.Sprintf("has unexpected value for swagger: %+v (%T)", v1, v1) |
| 550 | errors = append(errors, compiler.NewError(context, message)) |
| 551 | } |
| 552 | } |
| 553 | // Info info = 2; |
| 554 | v2 := compiler.MapValueForKey(m, "info") |
| 555 | if v2 != nil { |
| 556 | var err error |
| 557 | x.Info, err = NewInfo(v2, compiler.NewContext("info", context)) |
| 558 | if err != nil { |
| 559 | errors = append(errors, err) |
| 560 | } |
| 561 | } |
| 562 | // string host = 3; |
| 563 | v3 := compiler.MapValueForKey(m, "host") |
| 564 | if v3 != nil { |
| 565 | x.Host, ok = v3.(string) |
| 566 | if !ok { |
| 567 | message := fmt.Sprintf("has unexpected value for host: %+v (%T)", v3, v3) |
| 568 | errors = append(errors, compiler.NewError(context, message)) |
| 569 | } |
| 570 | } |
| 571 | // string base_path = 4; |
| 572 | v4 := compiler.MapValueForKey(m, "basePath") |
| 573 | if v4 != nil { |
| 574 | x.BasePath, ok = v4.(string) |
| 575 | if !ok { |
| 576 | message := fmt.Sprintf("has unexpected value for basePath: %+v (%T)", v4, v4) |
| 577 | errors = append(errors, compiler.NewError(context, message)) |
| 578 | } |
| 579 | } |
| 580 | // repeated string schemes = 5; |
| 581 | v5 := compiler.MapValueForKey(m, "schemes") |
| 582 | if v5 != nil { |
| 583 | v, ok := v5.([]interface{}) |
| 584 | if ok { |
| 585 | x.Schemes = compiler.ConvertInterfaceArrayToStringArray(v) |
| 586 | } else { |
| 587 | message := fmt.Sprintf("has unexpected value for schemes: %+v (%T)", v5, v5) |
| 588 | errors = append(errors, compiler.NewError(context, message)) |
| 589 | } |
| 590 | // check for valid enum values |
| 591 | // [http https ws wss] |
| 592 | if ok && !compiler.StringArrayContainsValues([]string{"http", "https", "ws", "wss"}, x.Schemes) { |
| 593 | message := fmt.Sprintf("has unexpected value for schemes: %+v", v5) |
| 594 | errors = append(errors, compiler.NewError(context, message)) |
| 595 | } |
| 596 | } |
| 597 | // repeated string consumes = 6; |
| 598 | v6 := compiler.MapValueForKey(m, "consumes") |
| 599 | if v6 != nil { |
| 600 | v, ok := v6.([]interface{}) |
| 601 | if ok { |
| 602 | x.Consumes = compiler.ConvertInterfaceArrayToStringArray(v) |
| 603 | } else { |
| 604 | message := fmt.Sprintf("has unexpected value for consumes: %+v (%T)", v6, v6) |
| 605 | errors = append(errors, compiler.NewError(context, message)) |
| 606 | } |
| 607 | } |
| 608 | // repeated string produces = 7; |
| 609 | v7 := compiler.MapValueForKey(m, "produces") |
| 610 | if v7 != nil { |
| 611 | v, ok := v7.([]interface{}) |
| 612 | if ok { |
| 613 | x.Produces = compiler.ConvertInterfaceArrayToStringArray(v) |
| 614 | } else { |
| 615 | message := fmt.Sprintf("has unexpected value for produces: %+v (%T)", v7, v7) |
| 616 | errors = append(errors, compiler.NewError(context, message)) |
| 617 | } |
| 618 | } |
| 619 | // Paths paths = 8; |
| 620 | v8 := compiler.MapValueForKey(m, "paths") |
| 621 | if v8 != nil { |
| 622 | var err error |
| 623 | x.Paths, err = NewPaths(v8, compiler.NewContext("paths", context)) |
| 624 | if err != nil { |
| 625 | errors = append(errors, err) |
| 626 | } |
| 627 | } |
| 628 | // Definitions definitions = 9; |
| 629 | v9 := compiler.MapValueForKey(m, "definitions") |
| 630 | if v9 != nil { |
| 631 | var err error |
| 632 | x.Definitions, err = NewDefinitions(v9, compiler.NewContext("definitions", context)) |
| 633 | if err != nil { |
| 634 | errors = append(errors, err) |
| 635 | } |
| 636 | } |
| 637 | // ParameterDefinitions parameters = 10; |
| 638 | v10 := compiler.MapValueForKey(m, "parameters") |
| 639 | if v10 != nil { |
| 640 | var err error |
| 641 | x.Parameters, err = NewParameterDefinitions(v10, compiler.NewContext("parameters", context)) |
| 642 | if err != nil { |
| 643 | errors = append(errors, err) |
| 644 | } |
| 645 | } |
| 646 | // ResponseDefinitions responses = 11; |
| 647 | v11 := compiler.MapValueForKey(m, "responses") |
| 648 | if v11 != nil { |
| 649 | var err error |
| 650 | x.Responses, err = NewResponseDefinitions(v11, compiler.NewContext("responses", context)) |
| 651 | if err != nil { |
| 652 | errors = append(errors, err) |
| 653 | } |
| 654 | } |
| 655 | // repeated SecurityRequirement security = 12; |
| 656 | v12 := compiler.MapValueForKey(m, "security") |
| 657 | if v12 != nil { |
| 658 | // repeated SecurityRequirement |
| 659 | x.Security = make([]*SecurityRequirement, 0) |
| 660 | a, ok := v12.([]interface{}) |
| 661 | if ok { |
| 662 | for _, item := range a { |
| 663 | y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) |
| 664 | if err != nil { |
| 665 | errors = append(errors, err) |
| 666 | } |
| 667 | x.Security = append(x.Security, y) |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | // SecurityDefinitions security_definitions = 13; |
| 672 | v13 := compiler.MapValueForKey(m, "securityDefinitions") |
| 673 | if v13 != nil { |
| 674 | var err error |
| 675 | x.SecurityDefinitions, err = NewSecurityDefinitions(v13, compiler.NewContext("securityDefinitions", context)) |
| 676 | if err != nil { |
| 677 | errors = append(errors, err) |
| 678 | } |
| 679 | } |
| 680 | // repeated Tag tags = 14; |
| 681 | v14 := compiler.MapValueForKey(m, "tags") |
| 682 | if v14 != nil { |
| 683 | // repeated Tag |
| 684 | x.Tags = make([]*Tag, 0) |
| 685 | a, ok := v14.([]interface{}) |
| 686 | if ok { |
| 687 | for _, item := range a { |
| 688 | y, err := NewTag(item, compiler.NewContext("tags", context)) |
| 689 | if err != nil { |
| 690 | errors = append(errors, err) |
| 691 | } |
| 692 | x.Tags = append(x.Tags, y) |
| 693 | } |
| 694 | } |
| 695 | } |
| 696 | // ExternalDocs external_docs = 15; |
| 697 | v15 := compiler.MapValueForKey(m, "externalDocs") |
| 698 | if v15 != nil { |
| 699 | var err error |
| 700 | x.ExternalDocs, err = NewExternalDocs(v15, compiler.NewContext("externalDocs", context)) |
| 701 | if err != nil { |
| 702 | errors = append(errors, err) |
| 703 | } |
| 704 | } |
| 705 | // repeated NamedAny vendor_extension = 16; |
| 706 | // MAP: Any ^x- |
| 707 | x.VendorExtension = make([]*NamedAny, 0) |
| 708 | for _, item := range m { |
| 709 | k, ok := compiler.StringValue(item.Key) |
| 710 | if ok { |
| 711 | v := item.Value |
| 712 | if strings.HasPrefix(k, "x-") { |
| 713 | pair := &NamedAny{} |
| 714 | pair.Name = k |
| 715 | result := &Any{} |
| 716 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 717 | if handled { |
| 718 | if err != nil { |
| 719 | errors = append(errors, err) |
| 720 | } else { |
| 721 | bytes, _ := yaml.Marshal(v) |
| 722 | result.Yaml = string(bytes) |
| 723 | result.Value = resultFromExt |
| 724 | pair.Value = result |
| 725 | } |
| 726 | } else { |
| 727 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 728 | if err != nil { |
| 729 | errors = append(errors, err) |
| 730 | } |
| 731 | } |
| 732 | x.VendorExtension = append(x.VendorExtension, pair) |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | } |
| 737 | return x, compiler.NewErrorGroupOrNil(errors) |
| 738 | } |
| 739 | |
| 740 | // NewExamples creates an object of type Examples if possible, returning an error if not. |
| 741 | func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) { |
| 742 | errors := make([]error, 0) |
| 743 | x := &Examples{} |
| 744 | m, ok := compiler.UnpackMap(in) |
| 745 | if !ok { |
| 746 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 747 | errors = append(errors, compiler.NewError(context, message)) |
| 748 | } else { |
| 749 | // repeated NamedAny additional_properties = 1; |
| 750 | // MAP: Any |
| 751 | x.AdditionalProperties = make([]*NamedAny, 0) |
| 752 | for _, item := range m { |
| 753 | k, ok := compiler.StringValue(item.Key) |
| 754 | if ok { |
| 755 | v := item.Value |
| 756 | pair := &NamedAny{} |
| 757 | pair.Name = k |
| 758 | result := &Any{} |
| 759 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 760 | if handled { |
| 761 | if err != nil { |
| 762 | errors = append(errors, err) |
| 763 | } else { |
| 764 | bytes, _ := yaml.Marshal(v) |
| 765 | result.Yaml = string(bytes) |
| 766 | result.Value = resultFromExt |
| 767 | pair.Value = result |
| 768 | } |
| 769 | } else { |
| 770 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 771 | if err != nil { |
| 772 | errors = append(errors, err) |
| 773 | } |
| 774 | } |
| 775 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 776 | } |
| 777 | } |
| 778 | } |
| 779 | return x, compiler.NewErrorGroupOrNil(errors) |
| 780 | } |
| 781 | |
| 782 | // NewExternalDocs creates an object of type ExternalDocs if possible, returning an error if not. |
| 783 | func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, error) { |
| 784 | errors := make([]error, 0) |
| 785 | x := &ExternalDocs{} |
| 786 | m, ok := compiler.UnpackMap(in) |
| 787 | if !ok { |
| 788 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 789 | errors = append(errors, compiler.NewError(context, message)) |
| 790 | } else { |
| 791 | requiredKeys := []string{"url"} |
| 792 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 793 | if len(missingKeys) > 0 { |
| 794 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 795 | errors = append(errors, compiler.NewError(context, message)) |
| 796 | } |
| 797 | allowedKeys := []string{"description", "url"} |
| 798 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 799 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 800 | if len(invalidKeys) > 0 { |
| 801 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 802 | errors = append(errors, compiler.NewError(context, message)) |
| 803 | } |
| 804 | // string description = 1; |
| 805 | v1 := compiler.MapValueForKey(m, "description") |
| 806 | if v1 != nil { |
| 807 | x.Description, ok = v1.(string) |
| 808 | if !ok { |
| 809 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) |
| 810 | errors = append(errors, compiler.NewError(context, message)) |
| 811 | } |
| 812 | } |
| 813 | // string url = 2; |
| 814 | v2 := compiler.MapValueForKey(m, "url") |
| 815 | if v2 != nil { |
| 816 | x.Url, ok = v2.(string) |
| 817 | if !ok { |
| 818 | message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) |
| 819 | errors = append(errors, compiler.NewError(context, message)) |
| 820 | } |
| 821 | } |
| 822 | // repeated NamedAny vendor_extension = 3; |
| 823 | // MAP: Any ^x- |
| 824 | x.VendorExtension = make([]*NamedAny, 0) |
| 825 | for _, item := range m { |
| 826 | k, ok := compiler.StringValue(item.Key) |
| 827 | if ok { |
| 828 | v := item.Value |
| 829 | if strings.HasPrefix(k, "x-") { |
| 830 | pair := &NamedAny{} |
| 831 | pair.Name = k |
| 832 | result := &Any{} |
| 833 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 834 | if handled { |
| 835 | if err != nil { |
| 836 | errors = append(errors, err) |
| 837 | } else { |
| 838 | bytes, _ := yaml.Marshal(v) |
| 839 | result.Yaml = string(bytes) |
| 840 | result.Value = resultFromExt |
| 841 | pair.Value = result |
| 842 | } |
| 843 | } else { |
| 844 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 845 | if err != nil { |
| 846 | errors = append(errors, err) |
| 847 | } |
| 848 | } |
| 849 | x.VendorExtension = append(x.VendorExtension, pair) |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | } |
| 854 | return x, compiler.NewErrorGroupOrNil(errors) |
| 855 | } |
| 856 | |
| 857 | // NewFileSchema creates an object of type FileSchema if possible, returning an error if not. |
| 858 | func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, error) { |
| 859 | errors := make([]error, 0) |
| 860 | x := &FileSchema{} |
| 861 | m, ok := compiler.UnpackMap(in) |
| 862 | if !ok { |
| 863 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 864 | errors = append(errors, compiler.NewError(context, message)) |
| 865 | } else { |
| 866 | requiredKeys := []string{"type"} |
| 867 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 868 | if len(missingKeys) > 0 { |
| 869 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 870 | errors = append(errors, compiler.NewError(context, message)) |
| 871 | } |
| 872 | allowedKeys := []string{"default", "description", "example", "externalDocs", "format", "readOnly", "required", "title", "type"} |
| 873 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 874 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 875 | if len(invalidKeys) > 0 { |
| 876 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 877 | errors = append(errors, compiler.NewError(context, message)) |
| 878 | } |
| 879 | // string format = 1; |
| 880 | v1 := compiler.MapValueForKey(m, "format") |
| 881 | if v1 != nil { |
| 882 | x.Format, ok = v1.(string) |
| 883 | if !ok { |
| 884 | message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v1, v1) |
| 885 | errors = append(errors, compiler.NewError(context, message)) |
| 886 | } |
| 887 | } |
| 888 | // string title = 2; |
| 889 | v2 := compiler.MapValueForKey(m, "title") |
| 890 | if v2 != nil { |
| 891 | x.Title, ok = v2.(string) |
| 892 | if !ok { |
| 893 | message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v2, v2) |
| 894 | errors = append(errors, compiler.NewError(context, message)) |
| 895 | } |
| 896 | } |
| 897 | // string description = 3; |
| 898 | v3 := compiler.MapValueForKey(m, "description") |
| 899 | if v3 != nil { |
| 900 | x.Description, ok = v3.(string) |
| 901 | if !ok { |
| 902 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) |
| 903 | errors = append(errors, compiler.NewError(context, message)) |
| 904 | } |
| 905 | } |
| 906 | // Any default = 4; |
| 907 | v4 := compiler.MapValueForKey(m, "default") |
| 908 | if v4 != nil { |
| 909 | var err error |
| 910 | x.Default, err = NewAny(v4, compiler.NewContext("default", context)) |
| 911 | if err != nil { |
| 912 | errors = append(errors, err) |
| 913 | } |
| 914 | } |
| 915 | // repeated string required = 5; |
| 916 | v5 := compiler.MapValueForKey(m, "required") |
| 917 | if v5 != nil { |
| 918 | v, ok := v5.([]interface{}) |
| 919 | if ok { |
| 920 | x.Required = compiler.ConvertInterfaceArrayToStringArray(v) |
| 921 | } else { |
| 922 | message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v5, v5) |
| 923 | errors = append(errors, compiler.NewError(context, message)) |
| 924 | } |
| 925 | } |
| 926 | // string type = 6; |
| 927 | v6 := compiler.MapValueForKey(m, "type") |
| 928 | if v6 != nil { |
| 929 | x.Type, ok = v6.(string) |
| 930 | if !ok { |
| 931 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) |
| 932 | errors = append(errors, compiler.NewError(context, message)) |
| 933 | } |
| 934 | // check for valid enum values |
| 935 | // [file] |
| 936 | if ok && !compiler.StringArrayContainsValue([]string{"file"}, x.Type) { |
| 937 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) |
| 938 | errors = append(errors, compiler.NewError(context, message)) |
| 939 | } |
| 940 | } |
| 941 | // bool read_only = 7; |
| 942 | v7 := compiler.MapValueForKey(m, "readOnly") |
| 943 | if v7 != nil { |
| 944 | x.ReadOnly, ok = v7.(bool) |
| 945 | if !ok { |
| 946 | message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v7, v7) |
| 947 | errors = append(errors, compiler.NewError(context, message)) |
| 948 | } |
| 949 | } |
| 950 | // ExternalDocs external_docs = 8; |
| 951 | v8 := compiler.MapValueForKey(m, "externalDocs") |
| 952 | if v8 != nil { |
| 953 | var err error |
| 954 | x.ExternalDocs, err = NewExternalDocs(v8, compiler.NewContext("externalDocs", context)) |
| 955 | if err != nil { |
| 956 | errors = append(errors, err) |
| 957 | } |
| 958 | } |
| 959 | // Any example = 9; |
| 960 | v9 := compiler.MapValueForKey(m, "example") |
| 961 | if v9 != nil { |
| 962 | var err error |
| 963 | x.Example, err = NewAny(v9, compiler.NewContext("example", context)) |
| 964 | if err != nil { |
| 965 | errors = append(errors, err) |
| 966 | } |
| 967 | } |
| 968 | // repeated NamedAny vendor_extension = 10; |
| 969 | // MAP: Any ^x- |
| 970 | x.VendorExtension = make([]*NamedAny, 0) |
| 971 | for _, item := range m { |
| 972 | k, ok := compiler.StringValue(item.Key) |
| 973 | if ok { |
| 974 | v := item.Value |
| 975 | if strings.HasPrefix(k, "x-") { |
| 976 | pair := &NamedAny{} |
| 977 | pair.Name = k |
| 978 | result := &Any{} |
| 979 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 980 | if handled { |
| 981 | if err != nil { |
| 982 | errors = append(errors, err) |
| 983 | } else { |
| 984 | bytes, _ := yaml.Marshal(v) |
| 985 | result.Yaml = string(bytes) |
| 986 | result.Value = resultFromExt |
| 987 | pair.Value = result |
| 988 | } |
| 989 | } else { |
| 990 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 991 | if err != nil { |
| 992 | errors = append(errors, err) |
| 993 | } |
| 994 | } |
| 995 | x.VendorExtension = append(x.VendorExtension, pair) |
| 996 | } |
| 997 | } |
| 998 | } |
| 999 | } |
| 1000 | return x, compiler.NewErrorGroupOrNil(errors) |
| 1001 | } |
| 1002 | |
| 1003 | // NewFormDataParameterSubSchema creates an object of type FormDataParameterSubSchema if possible, returning an error if not. |
| 1004 | func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (*FormDataParameterSubSchema, error) { |
| 1005 | errors := make([]error, 0) |
| 1006 | x := &FormDataParameterSubSchema{} |
| 1007 | m, ok := compiler.UnpackMap(in) |
| 1008 | if !ok { |
| 1009 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1010 | errors = append(errors, compiler.NewError(context, message)) |
| 1011 | } else { |
| 1012 | allowedKeys := []string{"allowEmptyValue", "collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} |
| 1013 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 1014 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1015 | if len(invalidKeys) > 0 { |
| 1016 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1017 | errors = append(errors, compiler.NewError(context, message)) |
| 1018 | } |
| 1019 | // bool required = 1; |
| 1020 | v1 := compiler.MapValueForKey(m, "required") |
| 1021 | if v1 != nil { |
| 1022 | x.Required, ok = v1.(bool) |
| 1023 | if !ok { |
| 1024 | message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) |
| 1025 | errors = append(errors, compiler.NewError(context, message)) |
| 1026 | } |
| 1027 | } |
| 1028 | // string in = 2; |
| 1029 | v2 := compiler.MapValueForKey(m, "in") |
| 1030 | if v2 != nil { |
| 1031 | x.In, ok = v2.(string) |
| 1032 | if !ok { |
| 1033 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) |
| 1034 | errors = append(errors, compiler.NewError(context, message)) |
| 1035 | } |
| 1036 | // check for valid enum values |
| 1037 | // [formData] |
| 1038 | if ok && !compiler.StringArrayContainsValue([]string{"formData"}, x.In) { |
| 1039 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) |
| 1040 | errors = append(errors, compiler.NewError(context, message)) |
| 1041 | } |
| 1042 | } |
| 1043 | // string description = 3; |
| 1044 | v3 := compiler.MapValueForKey(m, "description") |
| 1045 | if v3 != nil { |
| 1046 | x.Description, ok = v3.(string) |
| 1047 | if !ok { |
| 1048 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) |
| 1049 | errors = append(errors, compiler.NewError(context, message)) |
| 1050 | } |
| 1051 | } |
| 1052 | // string name = 4; |
| 1053 | v4 := compiler.MapValueForKey(m, "name") |
| 1054 | if v4 != nil { |
| 1055 | x.Name, ok = v4.(string) |
| 1056 | if !ok { |
| 1057 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) |
| 1058 | errors = append(errors, compiler.NewError(context, message)) |
| 1059 | } |
| 1060 | } |
| 1061 | // bool allow_empty_value = 5; |
| 1062 | v5 := compiler.MapValueForKey(m, "allowEmptyValue") |
| 1063 | if v5 != nil { |
| 1064 | x.AllowEmptyValue, ok = v5.(bool) |
| 1065 | if !ok { |
| 1066 | message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v5, v5) |
| 1067 | errors = append(errors, compiler.NewError(context, message)) |
| 1068 | } |
| 1069 | } |
| 1070 | // string type = 6; |
| 1071 | v6 := compiler.MapValueForKey(m, "type") |
| 1072 | if v6 != nil { |
| 1073 | x.Type, ok = v6.(string) |
| 1074 | if !ok { |
| 1075 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) |
| 1076 | errors = append(errors, compiler.NewError(context, message)) |
| 1077 | } |
| 1078 | // check for valid enum values |
| 1079 | // [string number boolean integer array file] |
| 1080 | if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array", "file"}, x.Type) { |
| 1081 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) |
| 1082 | errors = append(errors, compiler.NewError(context, message)) |
| 1083 | } |
| 1084 | } |
| 1085 | // string format = 7; |
| 1086 | v7 := compiler.MapValueForKey(m, "format") |
| 1087 | if v7 != nil { |
| 1088 | x.Format, ok = v7.(string) |
| 1089 | if !ok { |
| 1090 | message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7) |
| 1091 | errors = append(errors, compiler.NewError(context, message)) |
| 1092 | } |
| 1093 | } |
| 1094 | // PrimitivesItems items = 8; |
| 1095 | v8 := compiler.MapValueForKey(m, "items") |
| 1096 | if v8 != nil { |
| 1097 | var err error |
| 1098 | x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", context)) |
| 1099 | if err != nil { |
| 1100 | errors = append(errors, err) |
| 1101 | } |
| 1102 | } |
| 1103 | // string collection_format = 9; |
| 1104 | v9 := compiler.MapValueForKey(m, "collectionFormat") |
| 1105 | if v9 != nil { |
| 1106 | x.CollectionFormat, ok = v9.(string) |
| 1107 | if !ok { |
| 1108 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) |
| 1109 | errors = append(errors, compiler.NewError(context, message)) |
| 1110 | } |
| 1111 | // check for valid enum values |
| 1112 | // [csv ssv tsv pipes multi] |
| 1113 | if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes", "multi"}, x.CollectionFormat) { |
| 1114 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) |
| 1115 | errors = append(errors, compiler.NewError(context, message)) |
| 1116 | } |
| 1117 | } |
| 1118 | // Any default = 10; |
| 1119 | v10 := compiler.MapValueForKey(m, "default") |
| 1120 | if v10 != nil { |
| 1121 | var err error |
| 1122 | x.Default, err = NewAny(v10, compiler.NewContext("default", context)) |
| 1123 | if err != nil { |
| 1124 | errors = append(errors, err) |
| 1125 | } |
| 1126 | } |
| 1127 | // float maximum = 11; |
| 1128 | v11 := compiler.MapValueForKey(m, "maximum") |
| 1129 | if v11 != nil { |
| 1130 | switch v11 := v11.(type) { |
| 1131 | case float64: |
| 1132 | x.Maximum = v11 |
| 1133 | case float32: |
| 1134 | x.Maximum = float64(v11) |
| 1135 | case uint64: |
| 1136 | x.Maximum = float64(v11) |
| 1137 | case uint32: |
| 1138 | x.Maximum = float64(v11) |
| 1139 | case int64: |
| 1140 | x.Maximum = float64(v11) |
| 1141 | case int32: |
| 1142 | x.Maximum = float64(v11) |
| 1143 | case int: |
| 1144 | x.Maximum = float64(v11) |
| 1145 | default: |
| 1146 | message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11) |
| 1147 | errors = append(errors, compiler.NewError(context, message)) |
| 1148 | } |
| 1149 | } |
| 1150 | // bool exclusive_maximum = 12; |
| 1151 | v12 := compiler.MapValueForKey(m, "exclusiveMaximum") |
| 1152 | if v12 != nil { |
| 1153 | x.ExclusiveMaximum, ok = v12.(bool) |
| 1154 | if !ok { |
| 1155 | message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12) |
| 1156 | errors = append(errors, compiler.NewError(context, message)) |
| 1157 | } |
| 1158 | } |
| 1159 | // float minimum = 13; |
| 1160 | v13 := compiler.MapValueForKey(m, "minimum") |
| 1161 | if v13 != nil { |
| 1162 | switch v13 := v13.(type) { |
| 1163 | case float64: |
| 1164 | x.Minimum = v13 |
| 1165 | case float32: |
| 1166 | x.Minimum = float64(v13) |
| 1167 | case uint64: |
| 1168 | x.Minimum = float64(v13) |
| 1169 | case uint32: |
| 1170 | x.Minimum = float64(v13) |
| 1171 | case int64: |
| 1172 | x.Minimum = float64(v13) |
| 1173 | case int32: |
| 1174 | x.Minimum = float64(v13) |
| 1175 | case int: |
| 1176 | x.Minimum = float64(v13) |
| 1177 | default: |
| 1178 | message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13) |
| 1179 | errors = append(errors, compiler.NewError(context, message)) |
| 1180 | } |
| 1181 | } |
| 1182 | // bool exclusive_minimum = 14; |
| 1183 | v14 := compiler.MapValueForKey(m, "exclusiveMinimum") |
| 1184 | if v14 != nil { |
| 1185 | x.ExclusiveMinimum, ok = v14.(bool) |
| 1186 | if !ok { |
| 1187 | message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14) |
| 1188 | errors = append(errors, compiler.NewError(context, message)) |
| 1189 | } |
| 1190 | } |
| 1191 | // int64 max_length = 15; |
| 1192 | v15 := compiler.MapValueForKey(m, "maxLength") |
| 1193 | if v15 != nil { |
| 1194 | t, ok := v15.(int) |
| 1195 | if ok { |
| 1196 | x.MaxLength = int64(t) |
| 1197 | } else { |
| 1198 | message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v15, v15) |
| 1199 | errors = append(errors, compiler.NewError(context, message)) |
| 1200 | } |
| 1201 | } |
| 1202 | // int64 min_length = 16; |
| 1203 | v16 := compiler.MapValueForKey(m, "minLength") |
| 1204 | if v16 != nil { |
| 1205 | t, ok := v16.(int) |
| 1206 | if ok { |
| 1207 | x.MinLength = int64(t) |
| 1208 | } else { |
| 1209 | message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v16, v16) |
| 1210 | errors = append(errors, compiler.NewError(context, message)) |
| 1211 | } |
| 1212 | } |
| 1213 | // string pattern = 17; |
| 1214 | v17 := compiler.MapValueForKey(m, "pattern") |
| 1215 | if v17 != nil { |
| 1216 | x.Pattern, ok = v17.(string) |
| 1217 | if !ok { |
| 1218 | message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17) |
| 1219 | errors = append(errors, compiler.NewError(context, message)) |
| 1220 | } |
| 1221 | } |
| 1222 | // int64 max_items = 18; |
| 1223 | v18 := compiler.MapValueForKey(m, "maxItems") |
| 1224 | if v18 != nil { |
| 1225 | t, ok := v18.(int) |
| 1226 | if ok { |
| 1227 | x.MaxItems = int64(t) |
| 1228 | } else { |
| 1229 | message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v18, v18) |
| 1230 | errors = append(errors, compiler.NewError(context, message)) |
| 1231 | } |
| 1232 | } |
| 1233 | // int64 min_items = 19; |
| 1234 | v19 := compiler.MapValueForKey(m, "minItems") |
| 1235 | if v19 != nil { |
| 1236 | t, ok := v19.(int) |
| 1237 | if ok { |
| 1238 | x.MinItems = int64(t) |
| 1239 | } else { |
| 1240 | message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v19, v19) |
| 1241 | errors = append(errors, compiler.NewError(context, message)) |
| 1242 | } |
| 1243 | } |
| 1244 | // bool unique_items = 20; |
| 1245 | v20 := compiler.MapValueForKey(m, "uniqueItems") |
| 1246 | if v20 != nil { |
| 1247 | x.UniqueItems, ok = v20.(bool) |
| 1248 | if !ok { |
| 1249 | message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20) |
| 1250 | errors = append(errors, compiler.NewError(context, message)) |
| 1251 | } |
| 1252 | } |
| 1253 | // repeated Any enum = 21; |
| 1254 | v21 := compiler.MapValueForKey(m, "enum") |
| 1255 | if v21 != nil { |
| 1256 | // repeated Any |
| 1257 | x.Enum = make([]*Any, 0) |
| 1258 | a, ok := v21.([]interface{}) |
| 1259 | if ok { |
| 1260 | for _, item := range a { |
| 1261 | y, err := NewAny(item, compiler.NewContext("enum", context)) |
| 1262 | if err != nil { |
| 1263 | errors = append(errors, err) |
| 1264 | } |
| 1265 | x.Enum = append(x.Enum, y) |
| 1266 | } |
| 1267 | } |
| 1268 | } |
| 1269 | // float multiple_of = 22; |
| 1270 | v22 := compiler.MapValueForKey(m, "multipleOf") |
| 1271 | if v22 != nil { |
| 1272 | switch v22 := v22.(type) { |
| 1273 | case float64: |
| 1274 | x.MultipleOf = v22 |
| 1275 | case float32: |
| 1276 | x.MultipleOf = float64(v22) |
| 1277 | case uint64: |
| 1278 | x.MultipleOf = float64(v22) |
| 1279 | case uint32: |
| 1280 | x.MultipleOf = float64(v22) |
| 1281 | case int64: |
| 1282 | x.MultipleOf = float64(v22) |
| 1283 | case int32: |
| 1284 | x.MultipleOf = float64(v22) |
| 1285 | case int: |
| 1286 | x.MultipleOf = float64(v22) |
| 1287 | default: |
| 1288 | message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v22, v22) |
| 1289 | errors = append(errors, compiler.NewError(context, message)) |
| 1290 | } |
| 1291 | } |
| 1292 | // repeated NamedAny vendor_extension = 23; |
| 1293 | // MAP: Any ^x- |
| 1294 | x.VendorExtension = make([]*NamedAny, 0) |
| 1295 | for _, item := range m { |
| 1296 | k, ok := compiler.StringValue(item.Key) |
| 1297 | if ok { |
| 1298 | v := item.Value |
| 1299 | if strings.HasPrefix(k, "x-") { |
| 1300 | pair := &NamedAny{} |
| 1301 | pair.Name = k |
| 1302 | result := &Any{} |
| 1303 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 1304 | if handled { |
| 1305 | if err != nil { |
| 1306 | errors = append(errors, err) |
| 1307 | } else { |
| 1308 | bytes, _ := yaml.Marshal(v) |
| 1309 | result.Yaml = string(bytes) |
| 1310 | result.Value = resultFromExt |
| 1311 | pair.Value = result |
| 1312 | } |
| 1313 | } else { |
| 1314 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 1315 | if err != nil { |
| 1316 | errors = append(errors, err) |
| 1317 | } |
| 1318 | } |
| 1319 | x.VendorExtension = append(x.VendorExtension, pair) |
| 1320 | } |
| 1321 | } |
| 1322 | } |
| 1323 | } |
| 1324 | return x, compiler.NewErrorGroupOrNil(errors) |
| 1325 | } |
| 1326 | |
| 1327 | // NewHeader creates an object of type Header if possible, returning an error if not. |
| 1328 | func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { |
| 1329 | errors := make([]error, 0) |
| 1330 | x := &Header{} |
| 1331 | m, ok := compiler.UnpackMap(in) |
| 1332 | if !ok { |
| 1333 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1334 | errors = append(errors, compiler.NewError(context, message)) |
| 1335 | } else { |
| 1336 | requiredKeys := []string{"type"} |
| 1337 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 1338 | if len(missingKeys) > 0 { |
| 1339 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 1340 | errors = append(errors, compiler.NewError(context, message)) |
| 1341 | } |
| 1342 | allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "pattern", "type", "uniqueItems"} |
| 1343 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 1344 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1345 | if len(invalidKeys) > 0 { |
| 1346 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1347 | errors = append(errors, compiler.NewError(context, message)) |
| 1348 | } |
| 1349 | // string type = 1; |
| 1350 | v1 := compiler.MapValueForKey(m, "type") |
| 1351 | if v1 != nil { |
| 1352 | x.Type, ok = v1.(string) |
| 1353 | if !ok { |
| 1354 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 1355 | errors = append(errors, compiler.NewError(context, message)) |
| 1356 | } |
| 1357 | // check for valid enum values |
| 1358 | // [string number integer boolean array] |
| 1359 | if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "integer", "boolean", "array"}, x.Type) { |
| 1360 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 1361 | errors = append(errors, compiler.NewError(context, message)) |
| 1362 | } |
| 1363 | } |
| 1364 | // string format = 2; |
| 1365 | v2 := compiler.MapValueForKey(m, "format") |
| 1366 | if v2 != nil { |
| 1367 | x.Format, ok = v2.(string) |
| 1368 | if !ok { |
| 1369 | message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) |
| 1370 | errors = append(errors, compiler.NewError(context, message)) |
| 1371 | } |
| 1372 | } |
| 1373 | // PrimitivesItems items = 3; |
| 1374 | v3 := compiler.MapValueForKey(m, "items") |
| 1375 | if v3 != nil { |
| 1376 | var err error |
| 1377 | x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", context)) |
| 1378 | if err != nil { |
| 1379 | errors = append(errors, err) |
| 1380 | } |
| 1381 | } |
| 1382 | // string collection_format = 4; |
| 1383 | v4 := compiler.MapValueForKey(m, "collectionFormat") |
| 1384 | if v4 != nil { |
| 1385 | x.CollectionFormat, ok = v4.(string) |
| 1386 | if !ok { |
| 1387 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) |
| 1388 | errors = append(errors, compiler.NewError(context, message)) |
| 1389 | } |
| 1390 | // check for valid enum values |
| 1391 | // [csv ssv tsv pipes] |
| 1392 | if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { |
| 1393 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) |
| 1394 | errors = append(errors, compiler.NewError(context, message)) |
| 1395 | } |
| 1396 | } |
| 1397 | // Any default = 5; |
| 1398 | v5 := compiler.MapValueForKey(m, "default") |
| 1399 | if v5 != nil { |
| 1400 | var err error |
| 1401 | x.Default, err = NewAny(v5, compiler.NewContext("default", context)) |
| 1402 | if err != nil { |
| 1403 | errors = append(errors, err) |
| 1404 | } |
| 1405 | } |
| 1406 | // float maximum = 6; |
| 1407 | v6 := compiler.MapValueForKey(m, "maximum") |
| 1408 | if v6 != nil { |
| 1409 | switch v6 := v6.(type) { |
| 1410 | case float64: |
| 1411 | x.Maximum = v6 |
| 1412 | case float32: |
| 1413 | x.Maximum = float64(v6) |
| 1414 | case uint64: |
| 1415 | x.Maximum = float64(v6) |
| 1416 | case uint32: |
| 1417 | x.Maximum = float64(v6) |
| 1418 | case int64: |
| 1419 | x.Maximum = float64(v6) |
| 1420 | case int32: |
| 1421 | x.Maximum = float64(v6) |
| 1422 | case int: |
| 1423 | x.Maximum = float64(v6) |
| 1424 | default: |
| 1425 | message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v6, v6) |
| 1426 | errors = append(errors, compiler.NewError(context, message)) |
| 1427 | } |
| 1428 | } |
| 1429 | // bool exclusive_maximum = 7; |
| 1430 | v7 := compiler.MapValueForKey(m, "exclusiveMaximum") |
| 1431 | if v7 != nil { |
| 1432 | x.ExclusiveMaximum, ok = v7.(bool) |
| 1433 | if !ok { |
| 1434 | message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v7, v7) |
| 1435 | errors = append(errors, compiler.NewError(context, message)) |
| 1436 | } |
| 1437 | } |
| 1438 | // float minimum = 8; |
| 1439 | v8 := compiler.MapValueForKey(m, "minimum") |
| 1440 | if v8 != nil { |
| 1441 | switch v8 := v8.(type) { |
| 1442 | case float64: |
| 1443 | x.Minimum = v8 |
| 1444 | case float32: |
| 1445 | x.Minimum = float64(v8) |
| 1446 | case uint64: |
| 1447 | x.Minimum = float64(v8) |
| 1448 | case uint32: |
| 1449 | x.Minimum = float64(v8) |
| 1450 | case int64: |
| 1451 | x.Minimum = float64(v8) |
| 1452 | case int32: |
| 1453 | x.Minimum = float64(v8) |
| 1454 | case int: |
| 1455 | x.Minimum = float64(v8) |
| 1456 | default: |
| 1457 | message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8) |
| 1458 | errors = append(errors, compiler.NewError(context, message)) |
| 1459 | } |
| 1460 | } |
| 1461 | // bool exclusive_minimum = 9; |
| 1462 | v9 := compiler.MapValueForKey(m, "exclusiveMinimum") |
| 1463 | if v9 != nil { |
| 1464 | x.ExclusiveMinimum, ok = v9.(bool) |
| 1465 | if !ok { |
| 1466 | message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v9, v9) |
| 1467 | errors = append(errors, compiler.NewError(context, message)) |
| 1468 | } |
| 1469 | } |
| 1470 | // int64 max_length = 10; |
| 1471 | v10 := compiler.MapValueForKey(m, "maxLength") |
| 1472 | if v10 != nil { |
| 1473 | t, ok := v10.(int) |
| 1474 | if ok { |
| 1475 | x.MaxLength = int64(t) |
| 1476 | } else { |
| 1477 | message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v10, v10) |
| 1478 | errors = append(errors, compiler.NewError(context, message)) |
| 1479 | } |
| 1480 | } |
| 1481 | // int64 min_length = 11; |
| 1482 | v11 := compiler.MapValueForKey(m, "minLength") |
| 1483 | if v11 != nil { |
| 1484 | t, ok := v11.(int) |
| 1485 | if ok { |
| 1486 | x.MinLength = int64(t) |
| 1487 | } else { |
| 1488 | message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v11, v11) |
| 1489 | errors = append(errors, compiler.NewError(context, message)) |
| 1490 | } |
| 1491 | } |
| 1492 | // string pattern = 12; |
| 1493 | v12 := compiler.MapValueForKey(m, "pattern") |
| 1494 | if v12 != nil { |
| 1495 | x.Pattern, ok = v12.(string) |
| 1496 | if !ok { |
| 1497 | message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v12, v12) |
| 1498 | errors = append(errors, compiler.NewError(context, message)) |
| 1499 | } |
| 1500 | } |
| 1501 | // int64 max_items = 13; |
| 1502 | v13 := compiler.MapValueForKey(m, "maxItems") |
| 1503 | if v13 != nil { |
| 1504 | t, ok := v13.(int) |
| 1505 | if ok { |
| 1506 | x.MaxItems = int64(t) |
| 1507 | } else { |
| 1508 | message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v13, v13) |
| 1509 | errors = append(errors, compiler.NewError(context, message)) |
| 1510 | } |
| 1511 | } |
| 1512 | // int64 min_items = 14; |
| 1513 | v14 := compiler.MapValueForKey(m, "minItems") |
| 1514 | if v14 != nil { |
| 1515 | t, ok := v14.(int) |
| 1516 | if ok { |
| 1517 | x.MinItems = int64(t) |
| 1518 | } else { |
| 1519 | message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v14, v14) |
| 1520 | errors = append(errors, compiler.NewError(context, message)) |
| 1521 | } |
| 1522 | } |
| 1523 | // bool unique_items = 15; |
| 1524 | v15 := compiler.MapValueForKey(m, "uniqueItems") |
| 1525 | if v15 != nil { |
| 1526 | x.UniqueItems, ok = v15.(bool) |
| 1527 | if !ok { |
| 1528 | message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v15, v15) |
| 1529 | errors = append(errors, compiler.NewError(context, message)) |
| 1530 | } |
| 1531 | } |
| 1532 | // repeated Any enum = 16; |
| 1533 | v16 := compiler.MapValueForKey(m, "enum") |
| 1534 | if v16 != nil { |
| 1535 | // repeated Any |
| 1536 | x.Enum = make([]*Any, 0) |
| 1537 | a, ok := v16.([]interface{}) |
| 1538 | if ok { |
| 1539 | for _, item := range a { |
| 1540 | y, err := NewAny(item, compiler.NewContext("enum", context)) |
| 1541 | if err != nil { |
| 1542 | errors = append(errors, err) |
| 1543 | } |
| 1544 | x.Enum = append(x.Enum, y) |
| 1545 | } |
| 1546 | } |
| 1547 | } |
| 1548 | // float multiple_of = 17; |
| 1549 | v17 := compiler.MapValueForKey(m, "multipleOf") |
| 1550 | if v17 != nil { |
| 1551 | switch v17 := v17.(type) { |
| 1552 | case float64: |
| 1553 | x.MultipleOf = v17 |
| 1554 | case float32: |
| 1555 | x.MultipleOf = float64(v17) |
| 1556 | case uint64: |
| 1557 | x.MultipleOf = float64(v17) |
| 1558 | case uint32: |
| 1559 | x.MultipleOf = float64(v17) |
| 1560 | case int64: |
| 1561 | x.MultipleOf = float64(v17) |
| 1562 | case int32: |
| 1563 | x.MultipleOf = float64(v17) |
| 1564 | case int: |
| 1565 | x.MultipleOf = float64(v17) |
| 1566 | default: |
| 1567 | message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v17, v17) |
| 1568 | errors = append(errors, compiler.NewError(context, message)) |
| 1569 | } |
| 1570 | } |
| 1571 | // string description = 18; |
| 1572 | v18 := compiler.MapValueForKey(m, "description") |
| 1573 | if v18 != nil { |
| 1574 | x.Description, ok = v18.(string) |
| 1575 | if !ok { |
| 1576 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v18, v18) |
| 1577 | errors = append(errors, compiler.NewError(context, message)) |
| 1578 | } |
| 1579 | } |
| 1580 | // repeated NamedAny vendor_extension = 19; |
| 1581 | // MAP: Any ^x- |
| 1582 | x.VendorExtension = make([]*NamedAny, 0) |
| 1583 | for _, item := range m { |
| 1584 | k, ok := compiler.StringValue(item.Key) |
| 1585 | if ok { |
| 1586 | v := item.Value |
| 1587 | if strings.HasPrefix(k, "x-") { |
| 1588 | pair := &NamedAny{} |
| 1589 | pair.Name = k |
| 1590 | result := &Any{} |
| 1591 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 1592 | if handled { |
| 1593 | if err != nil { |
| 1594 | errors = append(errors, err) |
| 1595 | } else { |
| 1596 | bytes, _ := yaml.Marshal(v) |
| 1597 | result.Yaml = string(bytes) |
| 1598 | result.Value = resultFromExt |
| 1599 | pair.Value = result |
| 1600 | } |
| 1601 | } else { |
| 1602 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 1603 | if err != nil { |
| 1604 | errors = append(errors, err) |
| 1605 | } |
| 1606 | } |
| 1607 | x.VendorExtension = append(x.VendorExtension, pair) |
| 1608 | } |
| 1609 | } |
| 1610 | } |
| 1611 | } |
| 1612 | return x, compiler.NewErrorGroupOrNil(errors) |
| 1613 | } |
| 1614 | |
| 1615 | // NewHeaderParameterSubSchema creates an object of type HeaderParameterSubSchema if possible, returning an error if not. |
| 1616 | func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*HeaderParameterSubSchema, error) { |
| 1617 | errors := make([]error, 0) |
| 1618 | x := &HeaderParameterSubSchema{} |
| 1619 | m, ok := compiler.UnpackMap(in) |
| 1620 | if !ok { |
| 1621 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1622 | errors = append(errors, compiler.NewError(context, message)) |
| 1623 | } else { |
| 1624 | allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} |
| 1625 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 1626 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1627 | if len(invalidKeys) > 0 { |
| 1628 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1629 | errors = append(errors, compiler.NewError(context, message)) |
| 1630 | } |
| 1631 | // bool required = 1; |
| 1632 | v1 := compiler.MapValueForKey(m, "required") |
| 1633 | if v1 != nil { |
| 1634 | x.Required, ok = v1.(bool) |
| 1635 | if !ok { |
| 1636 | message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) |
| 1637 | errors = append(errors, compiler.NewError(context, message)) |
| 1638 | } |
| 1639 | } |
| 1640 | // string in = 2; |
| 1641 | v2 := compiler.MapValueForKey(m, "in") |
| 1642 | if v2 != nil { |
| 1643 | x.In, ok = v2.(string) |
| 1644 | if !ok { |
| 1645 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) |
| 1646 | errors = append(errors, compiler.NewError(context, message)) |
| 1647 | } |
| 1648 | // check for valid enum values |
| 1649 | // [header] |
| 1650 | if ok && !compiler.StringArrayContainsValue([]string{"header"}, x.In) { |
| 1651 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) |
| 1652 | errors = append(errors, compiler.NewError(context, message)) |
| 1653 | } |
| 1654 | } |
| 1655 | // string description = 3; |
| 1656 | v3 := compiler.MapValueForKey(m, "description") |
| 1657 | if v3 != nil { |
| 1658 | x.Description, ok = v3.(string) |
| 1659 | if !ok { |
| 1660 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) |
| 1661 | errors = append(errors, compiler.NewError(context, message)) |
| 1662 | } |
| 1663 | } |
| 1664 | // string name = 4; |
| 1665 | v4 := compiler.MapValueForKey(m, "name") |
| 1666 | if v4 != nil { |
| 1667 | x.Name, ok = v4.(string) |
| 1668 | if !ok { |
| 1669 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) |
| 1670 | errors = append(errors, compiler.NewError(context, message)) |
| 1671 | } |
| 1672 | } |
| 1673 | // string type = 5; |
| 1674 | v5 := compiler.MapValueForKey(m, "type") |
| 1675 | if v5 != nil { |
| 1676 | x.Type, ok = v5.(string) |
| 1677 | if !ok { |
| 1678 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) |
| 1679 | errors = append(errors, compiler.NewError(context, message)) |
| 1680 | } |
| 1681 | // check for valid enum values |
| 1682 | // [string number boolean integer array] |
| 1683 | if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { |
| 1684 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) |
| 1685 | errors = append(errors, compiler.NewError(context, message)) |
| 1686 | } |
| 1687 | } |
| 1688 | // string format = 6; |
| 1689 | v6 := compiler.MapValueForKey(m, "format") |
| 1690 | if v6 != nil { |
| 1691 | x.Format, ok = v6.(string) |
| 1692 | if !ok { |
| 1693 | message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6) |
| 1694 | errors = append(errors, compiler.NewError(context, message)) |
| 1695 | } |
| 1696 | } |
| 1697 | // PrimitivesItems items = 7; |
| 1698 | v7 := compiler.MapValueForKey(m, "items") |
| 1699 | if v7 != nil { |
| 1700 | var err error |
| 1701 | x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", context)) |
| 1702 | if err != nil { |
| 1703 | errors = append(errors, err) |
| 1704 | } |
| 1705 | } |
| 1706 | // string collection_format = 8; |
| 1707 | v8 := compiler.MapValueForKey(m, "collectionFormat") |
| 1708 | if v8 != nil { |
| 1709 | x.CollectionFormat, ok = v8.(string) |
| 1710 | if !ok { |
| 1711 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) |
| 1712 | errors = append(errors, compiler.NewError(context, message)) |
| 1713 | } |
| 1714 | // check for valid enum values |
| 1715 | // [csv ssv tsv pipes] |
| 1716 | if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { |
| 1717 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) |
| 1718 | errors = append(errors, compiler.NewError(context, message)) |
| 1719 | } |
| 1720 | } |
| 1721 | // Any default = 9; |
| 1722 | v9 := compiler.MapValueForKey(m, "default") |
| 1723 | if v9 != nil { |
| 1724 | var err error |
| 1725 | x.Default, err = NewAny(v9, compiler.NewContext("default", context)) |
| 1726 | if err != nil { |
| 1727 | errors = append(errors, err) |
| 1728 | } |
| 1729 | } |
| 1730 | // float maximum = 10; |
| 1731 | v10 := compiler.MapValueForKey(m, "maximum") |
| 1732 | if v10 != nil { |
| 1733 | switch v10 := v10.(type) { |
| 1734 | case float64: |
| 1735 | x.Maximum = v10 |
| 1736 | case float32: |
| 1737 | x.Maximum = float64(v10) |
| 1738 | case uint64: |
| 1739 | x.Maximum = float64(v10) |
| 1740 | case uint32: |
| 1741 | x.Maximum = float64(v10) |
| 1742 | case int64: |
| 1743 | x.Maximum = float64(v10) |
| 1744 | case int32: |
| 1745 | x.Maximum = float64(v10) |
| 1746 | case int: |
| 1747 | x.Maximum = float64(v10) |
| 1748 | default: |
| 1749 | message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10) |
| 1750 | errors = append(errors, compiler.NewError(context, message)) |
| 1751 | } |
| 1752 | } |
| 1753 | // bool exclusive_maximum = 11; |
| 1754 | v11 := compiler.MapValueForKey(m, "exclusiveMaximum") |
| 1755 | if v11 != nil { |
| 1756 | x.ExclusiveMaximum, ok = v11.(bool) |
| 1757 | if !ok { |
| 1758 | message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11) |
| 1759 | errors = append(errors, compiler.NewError(context, message)) |
| 1760 | } |
| 1761 | } |
| 1762 | // float minimum = 12; |
| 1763 | v12 := compiler.MapValueForKey(m, "minimum") |
| 1764 | if v12 != nil { |
| 1765 | switch v12 := v12.(type) { |
| 1766 | case float64: |
| 1767 | x.Minimum = v12 |
| 1768 | case float32: |
| 1769 | x.Minimum = float64(v12) |
| 1770 | case uint64: |
| 1771 | x.Minimum = float64(v12) |
| 1772 | case uint32: |
| 1773 | x.Minimum = float64(v12) |
| 1774 | case int64: |
| 1775 | x.Minimum = float64(v12) |
| 1776 | case int32: |
| 1777 | x.Minimum = float64(v12) |
| 1778 | case int: |
| 1779 | x.Minimum = float64(v12) |
| 1780 | default: |
| 1781 | message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12) |
| 1782 | errors = append(errors, compiler.NewError(context, message)) |
| 1783 | } |
| 1784 | } |
| 1785 | // bool exclusive_minimum = 13; |
| 1786 | v13 := compiler.MapValueForKey(m, "exclusiveMinimum") |
| 1787 | if v13 != nil { |
| 1788 | x.ExclusiveMinimum, ok = v13.(bool) |
| 1789 | if !ok { |
| 1790 | message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13) |
| 1791 | errors = append(errors, compiler.NewError(context, message)) |
| 1792 | } |
| 1793 | } |
| 1794 | // int64 max_length = 14; |
| 1795 | v14 := compiler.MapValueForKey(m, "maxLength") |
| 1796 | if v14 != nil { |
| 1797 | t, ok := v14.(int) |
| 1798 | if ok { |
| 1799 | x.MaxLength = int64(t) |
| 1800 | } else { |
| 1801 | message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v14, v14) |
| 1802 | errors = append(errors, compiler.NewError(context, message)) |
| 1803 | } |
| 1804 | } |
| 1805 | // int64 min_length = 15; |
| 1806 | v15 := compiler.MapValueForKey(m, "minLength") |
| 1807 | if v15 != nil { |
| 1808 | t, ok := v15.(int) |
| 1809 | if ok { |
| 1810 | x.MinLength = int64(t) |
| 1811 | } else { |
| 1812 | message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v15, v15) |
| 1813 | errors = append(errors, compiler.NewError(context, message)) |
| 1814 | } |
| 1815 | } |
| 1816 | // string pattern = 16; |
| 1817 | v16 := compiler.MapValueForKey(m, "pattern") |
| 1818 | if v16 != nil { |
| 1819 | x.Pattern, ok = v16.(string) |
| 1820 | if !ok { |
| 1821 | message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16) |
| 1822 | errors = append(errors, compiler.NewError(context, message)) |
| 1823 | } |
| 1824 | } |
| 1825 | // int64 max_items = 17; |
| 1826 | v17 := compiler.MapValueForKey(m, "maxItems") |
| 1827 | if v17 != nil { |
| 1828 | t, ok := v17.(int) |
| 1829 | if ok { |
| 1830 | x.MaxItems = int64(t) |
| 1831 | } else { |
| 1832 | message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v17, v17) |
| 1833 | errors = append(errors, compiler.NewError(context, message)) |
| 1834 | } |
| 1835 | } |
| 1836 | // int64 min_items = 18; |
| 1837 | v18 := compiler.MapValueForKey(m, "minItems") |
| 1838 | if v18 != nil { |
| 1839 | t, ok := v18.(int) |
| 1840 | if ok { |
| 1841 | x.MinItems = int64(t) |
| 1842 | } else { |
| 1843 | message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v18, v18) |
| 1844 | errors = append(errors, compiler.NewError(context, message)) |
| 1845 | } |
| 1846 | } |
| 1847 | // bool unique_items = 19; |
| 1848 | v19 := compiler.MapValueForKey(m, "uniqueItems") |
| 1849 | if v19 != nil { |
| 1850 | x.UniqueItems, ok = v19.(bool) |
| 1851 | if !ok { |
| 1852 | message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19) |
| 1853 | errors = append(errors, compiler.NewError(context, message)) |
| 1854 | } |
| 1855 | } |
| 1856 | // repeated Any enum = 20; |
| 1857 | v20 := compiler.MapValueForKey(m, "enum") |
| 1858 | if v20 != nil { |
| 1859 | // repeated Any |
| 1860 | x.Enum = make([]*Any, 0) |
| 1861 | a, ok := v20.([]interface{}) |
| 1862 | if ok { |
| 1863 | for _, item := range a { |
| 1864 | y, err := NewAny(item, compiler.NewContext("enum", context)) |
| 1865 | if err != nil { |
| 1866 | errors = append(errors, err) |
| 1867 | } |
| 1868 | x.Enum = append(x.Enum, y) |
| 1869 | } |
| 1870 | } |
| 1871 | } |
| 1872 | // float multiple_of = 21; |
| 1873 | v21 := compiler.MapValueForKey(m, "multipleOf") |
| 1874 | if v21 != nil { |
| 1875 | switch v21 := v21.(type) { |
| 1876 | case float64: |
| 1877 | x.MultipleOf = v21 |
| 1878 | case float32: |
| 1879 | x.MultipleOf = float64(v21) |
| 1880 | case uint64: |
| 1881 | x.MultipleOf = float64(v21) |
| 1882 | case uint32: |
| 1883 | x.MultipleOf = float64(v21) |
| 1884 | case int64: |
| 1885 | x.MultipleOf = float64(v21) |
| 1886 | case int32: |
| 1887 | x.MultipleOf = float64(v21) |
| 1888 | case int: |
| 1889 | x.MultipleOf = float64(v21) |
| 1890 | default: |
| 1891 | message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v21, v21) |
| 1892 | errors = append(errors, compiler.NewError(context, message)) |
| 1893 | } |
| 1894 | } |
| 1895 | // repeated NamedAny vendor_extension = 22; |
| 1896 | // MAP: Any ^x- |
| 1897 | x.VendorExtension = make([]*NamedAny, 0) |
| 1898 | for _, item := range m { |
| 1899 | k, ok := compiler.StringValue(item.Key) |
| 1900 | if ok { |
| 1901 | v := item.Value |
| 1902 | if strings.HasPrefix(k, "x-") { |
| 1903 | pair := &NamedAny{} |
| 1904 | pair.Name = k |
| 1905 | result := &Any{} |
| 1906 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 1907 | if handled { |
| 1908 | if err != nil { |
| 1909 | errors = append(errors, err) |
| 1910 | } else { |
| 1911 | bytes, _ := yaml.Marshal(v) |
| 1912 | result.Yaml = string(bytes) |
| 1913 | result.Value = resultFromExt |
| 1914 | pair.Value = result |
| 1915 | } |
| 1916 | } else { |
| 1917 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 1918 | if err != nil { |
| 1919 | errors = append(errors, err) |
| 1920 | } |
| 1921 | } |
| 1922 | x.VendorExtension = append(x.VendorExtension, pair) |
| 1923 | } |
| 1924 | } |
| 1925 | } |
| 1926 | } |
| 1927 | return x, compiler.NewErrorGroupOrNil(errors) |
| 1928 | } |
| 1929 | |
| 1930 | // NewHeaders creates an object of type Headers if possible, returning an error if not. |
| 1931 | func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) { |
| 1932 | errors := make([]error, 0) |
| 1933 | x := &Headers{} |
| 1934 | m, ok := compiler.UnpackMap(in) |
| 1935 | if !ok { |
| 1936 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1937 | errors = append(errors, compiler.NewError(context, message)) |
| 1938 | } else { |
| 1939 | // repeated NamedHeader additional_properties = 1; |
| 1940 | // MAP: Header |
| 1941 | x.AdditionalProperties = make([]*NamedHeader, 0) |
| 1942 | for _, item := range m { |
| 1943 | k, ok := compiler.StringValue(item.Key) |
| 1944 | if ok { |
| 1945 | v := item.Value |
| 1946 | pair := &NamedHeader{} |
| 1947 | pair.Name = k |
| 1948 | var err error |
| 1949 | pair.Value, err = NewHeader(v, compiler.NewContext(k, context)) |
| 1950 | if err != nil { |
| 1951 | errors = append(errors, err) |
| 1952 | } |
| 1953 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 1954 | } |
| 1955 | } |
| 1956 | } |
| 1957 | return x, compiler.NewErrorGroupOrNil(errors) |
| 1958 | } |
| 1959 | |
| 1960 | // NewInfo creates an object of type Info if possible, returning an error if not. |
| 1961 | func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { |
| 1962 | errors := make([]error, 0) |
| 1963 | x := &Info{} |
| 1964 | m, ok := compiler.UnpackMap(in) |
| 1965 | if !ok { |
| 1966 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1967 | errors = append(errors, compiler.NewError(context, message)) |
| 1968 | } else { |
| 1969 | requiredKeys := []string{"title", "version"} |
| 1970 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 1971 | if len(missingKeys) > 0 { |
| 1972 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 1973 | errors = append(errors, compiler.NewError(context, message)) |
| 1974 | } |
| 1975 | allowedKeys := []string{"contact", "description", "license", "termsOfService", "title", "version"} |
| 1976 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 1977 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1978 | if len(invalidKeys) > 0 { |
| 1979 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1980 | errors = append(errors, compiler.NewError(context, message)) |
| 1981 | } |
| 1982 | // string title = 1; |
| 1983 | v1 := compiler.MapValueForKey(m, "title") |
| 1984 | if v1 != nil { |
| 1985 | x.Title, ok = v1.(string) |
| 1986 | if !ok { |
| 1987 | message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v1, v1) |
| 1988 | errors = append(errors, compiler.NewError(context, message)) |
| 1989 | } |
| 1990 | } |
| 1991 | // string version = 2; |
| 1992 | v2 := compiler.MapValueForKey(m, "version") |
| 1993 | if v2 != nil { |
| 1994 | x.Version, ok = v2.(string) |
| 1995 | if !ok { |
| 1996 | message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v2, v2) |
| 1997 | errors = append(errors, compiler.NewError(context, message)) |
| 1998 | } |
| 1999 | } |
| 2000 | // string description = 3; |
| 2001 | v3 := compiler.MapValueForKey(m, "description") |
| 2002 | if v3 != nil { |
| 2003 | x.Description, ok = v3.(string) |
| 2004 | if !ok { |
| 2005 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) |
| 2006 | errors = append(errors, compiler.NewError(context, message)) |
| 2007 | } |
| 2008 | } |
| 2009 | // string terms_of_service = 4; |
| 2010 | v4 := compiler.MapValueForKey(m, "termsOfService") |
| 2011 | if v4 != nil { |
| 2012 | x.TermsOfService, ok = v4.(string) |
| 2013 | if !ok { |
| 2014 | message := fmt.Sprintf("has unexpected value for termsOfService: %+v (%T)", v4, v4) |
| 2015 | errors = append(errors, compiler.NewError(context, message)) |
| 2016 | } |
| 2017 | } |
| 2018 | // Contact contact = 5; |
| 2019 | v5 := compiler.MapValueForKey(m, "contact") |
| 2020 | if v5 != nil { |
| 2021 | var err error |
| 2022 | x.Contact, err = NewContact(v5, compiler.NewContext("contact", context)) |
| 2023 | if err != nil { |
| 2024 | errors = append(errors, err) |
| 2025 | } |
| 2026 | } |
| 2027 | // License license = 6; |
| 2028 | v6 := compiler.MapValueForKey(m, "license") |
| 2029 | if v6 != nil { |
| 2030 | var err error |
| 2031 | x.License, err = NewLicense(v6, compiler.NewContext("license", context)) |
| 2032 | if err != nil { |
| 2033 | errors = append(errors, err) |
| 2034 | } |
| 2035 | } |
| 2036 | // repeated NamedAny vendor_extension = 7; |
| 2037 | // MAP: Any ^x- |
| 2038 | x.VendorExtension = make([]*NamedAny, 0) |
| 2039 | for _, item := range m { |
| 2040 | k, ok := compiler.StringValue(item.Key) |
| 2041 | if ok { |
| 2042 | v := item.Value |
| 2043 | if strings.HasPrefix(k, "x-") { |
| 2044 | pair := &NamedAny{} |
| 2045 | pair.Name = k |
| 2046 | result := &Any{} |
| 2047 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 2048 | if handled { |
| 2049 | if err != nil { |
| 2050 | errors = append(errors, err) |
| 2051 | } else { |
| 2052 | bytes, _ := yaml.Marshal(v) |
| 2053 | result.Yaml = string(bytes) |
| 2054 | result.Value = resultFromExt |
| 2055 | pair.Value = result |
| 2056 | } |
| 2057 | } else { |
| 2058 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 2059 | if err != nil { |
| 2060 | errors = append(errors, err) |
| 2061 | } |
| 2062 | } |
| 2063 | x.VendorExtension = append(x.VendorExtension, pair) |
| 2064 | } |
| 2065 | } |
| 2066 | } |
| 2067 | } |
| 2068 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2069 | } |
| 2070 | |
| 2071 | // NewItemsItem creates an object of type ItemsItem if possible, returning an error if not. |
| 2072 | func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) { |
| 2073 | errors := make([]error, 0) |
| 2074 | x := &ItemsItem{} |
| 2075 | m, ok := compiler.UnpackMap(in) |
| 2076 | if !ok { |
| 2077 | message := fmt.Sprintf("has unexpected value for item array: %+v (%T)", in, in) |
| 2078 | errors = append(errors, compiler.NewError(context, message)) |
| 2079 | } else { |
| 2080 | x.Schema = make([]*Schema, 0) |
| 2081 | y, err := NewSchema(m, compiler.NewContext("<array>", context)) |
| 2082 | if err != nil { |
| 2083 | return nil, err |
| 2084 | } |
| 2085 | x.Schema = append(x.Schema, y) |
| 2086 | } |
| 2087 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2088 | } |
| 2089 | |
| 2090 | // NewJsonReference creates an object of type JsonReference if possible, returning an error if not. |
| 2091 | func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference, error) { |
| 2092 | errors := make([]error, 0) |
| 2093 | x := &JsonReference{} |
| 2094 | m, ok := compiler.UnpackMap(in) |
| 2095 | if !ok { |
| 2096 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2097 | errors = append(errors, compiler.NewError(context, message)) |
| 2098 | } else { |
| 2099 | requiredKeys := []string{"$ref"} |
| 2100 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 2101 | if len(missingKeys) > 0 { |
| 2102 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 2103 | errors = append(errors, compiler.NewError(context, message)) |
| 2104 | } |
| 2105 | allowedKeys := []string{"$ref", "description"} |
| 2106 | var allowedPatterns []*regexp.Regexp |
| 2107 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2108 | if len(invalidKeys) > 0 { |
| 2109 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2110 | errors = append(errors, compiler.NewError(context, message)) |
| 2111 | } |
| 2112 | // string _ref = 1; |
| 2113 | v1 := compiler.MapValueForKey(m, "$ref") |
| 2114 | if v1 != nil { |
| 2115 | x.XRef, ok = v1.(string) |
| 2116 | if !ok { |
| 2117 | message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) |
| 2118 | errors = append(errors, compiler.NewError(context, message)) |
| 2119 | } |
| 2120 | } |
| 2121 | // string description = 2; |
| 2122 | v2 := compiler.MapValueForKey(m, "description") |
| 2123 | if v2 != nil { |
| 2124 | x.Description, ok = v2.(string) |
| 2125 | if !ok { |
| 2126 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) |
| 2127 | errors = append(errors, compiler.NewError(context, message)) |
| 2128 | } |
| 2129 | } |
| 2130 | } |
| 2131 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2132 | } |
| 2133 | |
| 2134 | // NewLicense creates an object of type License if possible, returning an error if not. |
| 2135 | func NewLicense(in interface{}, context *compiler.Context) (*License, error) { |
| 2136 | errors := make([]error, 0) |
| 2137 | x := &License{} |
| 2138 | m, ok := compiler.UnpackMap(in) |
| 2139 | if !ok { |
| 2140 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2141 | errors = append(errors, compiler.NewError(context, message)) |
| 2142 | } else { |
| 2143 | requiredKeys := []string{"name"} |
| 2144 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 2145 | if len(missingKeys) > 0 { |
| 2146 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 2147 | errors = append(errors, compiler.NewError(context, message)) |
| 2148 | } |
| 2149 | allowedKeys := []string{"name", "url"} |
| 2150 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 2151 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2152 | if len(invalidKeys) > 0 { |
| 2153 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2154 | errors = append(errors, compiler.NewError(context, message)) |
| 2155 | } |
| 2156 | // string name = 1; |
| 2157 | v1 := compiler.MapValueForKey(m, "name") |
| 2158 | if v1 != nil { |
| 2159 | x.Name, ok = v1.(string) |
| 2160 | if !ok { |
| 2161 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2162 | errors = append(errors, compiler.NewError(context, message)) |
| 2163 | } |
| 2164 | } |
| 2165 | // string url = 2; |
| 2166 | v2 := compiler.MapValueForKey(m, "url") |
| 2167 | if v2 != nil { |
| 2168 | x.Url, ok = v2.(string) |
| 2169 | if !ok { |
| 2170 | message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) |
| 2171 | errors = append(errors, compiler.NewError(context, message)) |
| 2172 | } |
| 2173 | } |
| 2174 | // repeated NamedAny vendor_extension = 3; |
| 2175 | // MAP: Any ^x- |
| 2176 | x.VendorExtension = make([]*NamedAny, 0) |
| 2177 | for _, item := range m { |
| 2178 | k, ok := compiler.StringValue(item.Key) |
| 2179 | if ok { |
| 2180 | v := item.Value |
| 2181 | if strings.HasPrefix(k, "x-") { |
| 2182 | pair := &NamedAny{} |
| 2183 | pair.Name = k |
| 2184 | result := &Any{} |
| 2185 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 2186 | if handled { |
| 2187 | if err != nil { |
| 2188 | errors = append(errors, err) |
| 2189 | } else { |
| 2190 | bytes, _ := yaml.Marshal(v) |
| 2191 | result.Yaml = string(bytes) |
| 2192 | result.Value = resultFromExt |
| 2193 | pair.Value = result |
| 2194 | } |
| 2195 | } else { |
| 2196 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 2197 | if err != nil { |
| 2198 | errors = append(errors, err) |
| 2199 | } |
| 2200 | } |
| 2201 | x.VendorExtension = append(x.VendorExtension, pair) |
| 2202 | } |
| 2203 | } |
| 2204 | } |
| 2205 | } |
| 2206 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2207 | } |
| 2208 | |
| 2209 | // NewNamedAny creates an object of type NamedAny if possible, returning an error if not. |
| 2210 | func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { |
| 2211 | errors := make([]error, 0) |
| 2212 | x := &NamedAny{} |
| 2213 | m, ok := compiler.UnpackMap(in) |
| 2214 | if !ok { |
| 2215 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2216 | errors = append(errors, compiler.NewError(context, message)) |
| 2217 | } else { |
| 2218 | allowedKeys := []string{"name", "value"} |
| 2219 | var allowedPatterns []*regexp.Regexp |
| 2220 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2221 | if len(invalidKeys) > 0 { |
| 2222 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2223 | errors = append(errors, compiler.NewError(context, message)) |
| 2224 | } |
| 2225 | // string name = 1; |
| 2226 | v1 := compiler.MapValueForKey(m, "name") |
| 2227 | if v1 != nil { |
| 2228 | x.Name, ok = v1.(string) |
| 2229 | if !ok { |
| 2230 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2231 | errors = append(errors, compiler.NewError(context, message)) |
| 2232 | } |
| 2233 | } |
| 2234 | // Any value = 2; |
| 2235 | v2 := compiler.MapValueForKey(m, "value") |
| 2236 | if v2 != nil { |
| 2237 | var err error |
| 2238 | x.Value, err = NewAny(v2, compiler.NewContext("value", context)) |
| 2239 | if err != nil { |
| 2240 | errors = append(errors, err) |
| 2241 | } |
| 2242 | } |
| 2243 | } |
| 2244 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2245 | } |
| 2246 | |
| 2247 | // NewNamedHeader creates an object of type NamedHeader if possible, returning an error if not. |
| 2248 | func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, error) { |
| 2249 | errors := make([]error, 0) |
| 2250 | x := &NamedHeader{} |
| 2251 | m, ok := compiler.UnpackMap(in) |
| 2252 | if !ok { |
| 2253 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2254 | errors = append(errors, compiler.NewError(context, message)) |
| 2255 | } else { |
| 2256 | allowedKeys := []string{"name", "value"} |
| 2257 | var allowedPatterns []*regexp.Regexp |
| 2258 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2259 | if len(invalidKeys) > 0 { |
| 2260 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2261 | errors = append(errors, compiler.NewError(context, message)) |
| 2262 | } |
| 2263 | // string name = 1; |
| 2264 | v1 := compiler.MapValueForKey(m, "name") |
| 2265 | if v1 != nil { |
| 2266 | x.Name, ok = v1.(string) |
| 2267 | if !ok { |
| 2268 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2269 | errors = append(errors, compiler.NewError(context, message)) |
| 2270 | } |
| 2271 | } |
| 2272 | // Header value = 2; |
| 2273 | v2 := compiler.MapValueForKey(m, "value") |
| 2274 | if v2 != nil { |
| 2275 | var err error |
| 2276 | x.Value, err = NewHeader(v2, compiler.NewContext("value", context)) |
| 2277 | if err != nil { |
| 2278 | errors = append(errors, err) |
| 2279 | } |
| 2280 | } |
| 2281 | } |
| 2282 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2283 | } |
| 2284 | |
| 2285 | // NewNamedParameter creates an object of type NamedParameter if possible, returning an error if not. |
| 2286 | func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParameter, error) { |
| 2287 | errors := make([]error, 0) |
| 2288 | x := &NamedParameter{} |
| 2289 | m, ok := compiler.UnpackMap(in) |
| 2290 | if !ok { |
| 2291 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2292 | errors = append(errors, compiler.NewError(context, message)) |
| 2293 | } else { |
| 2294 | allowedKeys := []string{"name", "value"} |
| 2295 | var allowedPatterns []*regexp.Regexp |
| 2296 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2297 | if len(invalidKeys) > 0 { |
| 2298 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2299 | errors = append(errors, compiler.NewError(context, message)) |
| 2300 | } |
| 2301 | // string name = 1; |
| 2302 | v1 := compiler.MapValueForKey(m, "name") |
| 2303 | if v1 != nil { |
| 2304 | x.Name, ok = v1.(string) |
| 2305 | if !ok { |
| 2306 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2307 | errors = append(errors, compiler.NewError(context, message)) |
| 2308 | } |
| 2309 | } |
| 2310 | // Parameter value = 2; |
| 2311 | v2 := compiler.MapValueForKey(m, "value") |
| 2312 | if v2 != nil { |
| 2313 | var err error |
| 2314 | x.Value, err = NewParameter(v2, compiler.NewContext("value", context)) |
| 2315 | if err != nil { |
| 2316 | errors = append(errors, err) |
| 2317 | } |
| 2318 | } |
| 2319 | } |
| 2320 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2321 | } |
| 2322 | |
| 2323 | // NewNamedPathItem creates an object of type NamedPathItem if possible, returning an error if not. |
| 2324 | func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem, error) { |
| 2325 | errors := make([]error, 0) |
| 2326 | x := &NamedPathItem{} |
| 2327 | m, ok := compiler.UnpackMap(in) |
| 2328 | if !ok { |
| 2329 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2330 | errors = append(errors, compiler.NewError(context, message)) |
| 2331 | } else { |
| 2332 | allowedKeys := []string{"name", "value"} |
| 2333 | var allowedPatterns []*regexp.Regexp |
| 2334 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2335 | if len(invalidKeys) > 0 { |
| 2336 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2337 | errors = append(errors, compiler.NewError(context, message)) |
| 2338 | } |
| 2339 | // string name = 1; |
| 2340 | v1 := compiler.MapValueForKey(m, "name") |
| 2341 | if v1 != nil { |
| 2342 | x.Name, ok = v1.(string) |
| 2343 | if !ok { |
| 2344 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2345 | errors = append(errors, compiler.NewError(context, message)) |
| 2346 | } |
| 2347 | } |
| 2348 | // PathItem value = 2; |
| 2349 | v2 := compiler.MapValueForKey(m, "value") |
| 2350 | if v2 != nil { |
| 2351 | var err error |
| 2352 | x.Value, err = NewPathItem(v2, compiler.NewContext("value", context)) |
| 2353 | if err != nil { |
| 2354 | errors = append(errors, err) |
| 2355 | } |
| 2356 | } |
| 2357 | } |
| 2358 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2359 | } |
| 2360 | |
| 2361 | // NewNamedResponse creates an object of type NamedResponse if possible, returning an error if not. |
| 2362 | func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse, error) { |
| 2363 | errors := make([]error, 0) |
| 2364 | x := &NamedResponse{} |
| 2365 | m, ok := compiler.UnpackMap(in) |
| 2366 | if !ok { |
| 2367 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2368 | errors = append(errors, compiler.NewError(context, message)) |
| 2369 | } else { |
| 2370 | allowedKeys := []string{"name", "value"} |
| 2371 | var allowedPatterns []*regexp.Regexp |
| 2372 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2373 | if len(invalidKeys) > 0 { |
| 2374 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2375 | errors = append(errors, compiler.NewError(context, message)) |
| 2376 | } |
| 2377 | // string name = 1; |
| 2378 | v1 := compiler.MapValueForKey(m, "name") |
| 2379 | if v1 != nil { |
| 2380 | x.Name, ok = v1.(string) |
| 2381 | if !ok { |
| 2382 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2383 | errors = append(errors, compiler.NewError(context, message)) |
| 2384 | } |
| 2385 | } |
| 2386 | // Response value = 2; |
| 2387 | v2 := compiler.MapValueForKey(m, "value") |
| 2388 | if v2 != nil { |
| 2389 | var err error |
| 2390 | x.Value, err = NewResponse(v2, compiler.NewContext("value", context)) |
| 2391 | if err != nil { |
| 2392 | errors = append(errors, err) |
| 2393 | } |
| 2394 | } |
| 2395 | } |
| 2396 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2397 | } |
| 2398 | |
| 2399 | // NewNamedResponseValue creates an object of type NamedResponseValue if possible, returning an error if not. |
| 2400 | func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedResponseValue, error) { |
| 2401 | errors := make([]error, 0) |
| 2402 | x := &NamedResponseValue{} |
| 2403 | m, ok := compiler.UnpackMap(in) |
| 2404 | if !ok { |
| 2405 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2406 | errors = append(errors, compiler.NewError(context, message)) |
| 2407 | } else { |
| 2408 | allowedKeys := []string{"name", "value"} |
| 2409 | var allowedPatterns []*regexp.Regexp |
| 2410 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2411 | if len(invalidKeys) > 0 { |
| 2412 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2413 | errors = append(errors, compiler.NewError(context, message)) |
| 2414 | } |
| 2415 | // string name = 1; |
| 2416 | v1 := compiler.MapValueForKey(m, "name") |
| 2417 | if v1 != nil { |
| 2418 | x.Name, ok = v1.(string) |
| 2419 | if !ok { |
| 2420 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2421 | errors = append(errors, compiler.NewError(context, message)) |
| 2422 | } |
| 2423 | } |
| 2424 | // ResponseValue value = 2; |
| 2425 | v2 := compiler.MapValueForKey(m, "value") |
| 2426 | if v2 != nil { |
| 2427 | var err error |
| 2428 | x.Value, err = NewResponseValue(v2, compiler.NewContext("value", context)) |
| 2429 | if err != nil { |
| 2430 | errors = append(errors, err) |
| 2431 | } |
| 2432 | } |
| 2433 | } |
| 2434 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2435 | } |
| 2436 | |
| 2437 | // NewNamedSchema creates an object of type NamedSchema if possible, returning an error if not. |
| 2438 | func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, error) { |
| 2439 | errors := make([]error, 0) |
| 2440 | x := &NamedSchema{} |
| 2441 | m, ok := compiler.UnpackMap(in) |
| 2442 | if !ok { |
| 2443 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2444 | errors = append(errors, compiler.NewError(context, message)) |
| 2445 | } else { |
| 2446 | allowedKeys := []string{"name", "value"} |
| 2447 | var allowedPatterns []*regexp.Regexp |
| 2448 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2449 | if len(invalidKeys) > 0 { |
| 2450 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2451 | errors = append(errors, compiler.NewError(context, message)) |
| 2452 | } |
| 2453 | // string name = 1; |
| 2454 | v1 := compiler.MapValueForKey(m, "name") |
| 2455 | if v1 != nil { |
| 2456 | x.Name, ok = v1.(string) |
| 2457 | if !ok { |
| 2458 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2459 | errors = append(errors, compiler.NewError(context, message)) |
| 2460 | } |
| 2461 | } |
| 2462 | // Schema value = 2; |
| 2463 | v2 := compiler.MapValueForKey(m, "value") |
| 2464 | if v2 != nil { |
| 2465 | var err error |
| 2466 | x.Value, err = NewSchema(v2, compiler.NewContext("value", context)) |
| 2467 | if err != nil { |
| 2468 | errors = append(errors, err) |
| 2469 | } |
| 2470 | } |
| 2471 | } |
| 2472 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2473 | } |
| 2474 | |
| 2475 | // NewNamedSecurityDefinitionsItem creates an object of type NamedSecurityDefinitionsItem if possible, returning an error if not. |
| 2476 | func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*NamedSecurityDefinitionsItem, error) { |
| 2477 | errors := make([]error, 0) |
| 2478 | x := &NamedSecurityDefinitionsItem{} |
| 2479 | m, ok := compiler.UnpackMap(in) |
| 2480 | if !ok { |
| 2481 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2482 | errors = append(errors, compiler.NewError(context, message)) |
| 2483 | } else { |
| 2484 | allowedKeys := []string{"name", "value"} |
| 2485 | var allowedPatterns []*regexp.Regexp |
| 2486 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2487 | if len(invalidKeys) > 0 { |
| 2488 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2489 | errors = append(errors, compiler.NewError(context, message)) |
| 2490 | } |
| 2491 | // string name = 1; |
| 2492 | v1 := compiler.MapValueForKey(m, "name") |
| 2493 | if v1 != nil { |
| 2494 | x.Name, ok = v1.(string) |
| 2495 | if !ok { |
| 2496 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2497 | errors = append(errors, compiler.NewError(context, message)) |
| 2498 | } |
| 2499 | } |
| 2500 | // SecurityDefinitionsItem value = 2; |
| 2501 | v2 := compiler.MapValueForKey(m, "value") |
| 2502 | if v2 != nil { |
| 2503 | var err error |
| 2504 | x.Value, err = NewSecurityDefinitionsItem(v2, compiler.NewContext("value", context)) |
| 2505 | if err != nil { |
| 2506 | errors = append(errors, err) |
| 2507 | } |
| 2508 | } |
| 2509 | } |
| 2510 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2511 | } |
| 2512 | |
| 2513 | // NewNamedString creates an object of type NamedString if possible, returning an error if not. |
| 2514 | func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, error) { |
| 2515 | errors := make([]error, 0) |
| 2516 | x := &NamedString{} |
| 2517 | m, ok := compiler.UnpackMap(in) |
| 2518 | if !ok { |
| 2519 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2520 | errors = append(errors, compiler.NewError(context, message)) |
| 2521 | } else { |
| 2522 | allowedKeys := []string{"name", "value"} |
| 2523 | var allowedPatterns []*regexp.Regexp |
| 2524 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2525 | if len(invalidKeys) > 0 { |
| 2526 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2527 | errors = append(errors, compiler.NewError(context, message)) |
| 2528 | } |
| 2529 | // string name = 1; |
| 2530 | v1 := compiler.MapValueForKey(m, "name") |
| 2531 | if v1 != nil { |
| 2532 | x.Name, ok = v1.(string) |
| 2533 | if !ok { |
| 2534 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2535 | errors = append(errors, compiler.NewError(context, message)) |
| 2536 | } |
| 2537 | } |
| 2538 | // string value = 2; |
| 2539 | v2 := compiler.MapValueForKey(m, "value") |
| 2540 | if v2 != nil { |
| 2541 | x.Value, ok = v2.(string) |
| 2542 | if !ok { |
| 2543 | message := fmt.Sprintf("has unexpected value for value: %+v (%T)", v2, v2) |
| 2544 | errors = append(errors, compiler.NewError(context, message)) |
| 2545 | } |
| 2546 | } |
| 2547 | } |
| 2548 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2549 | } |
| 2550 | |
| 2551 | // NewNamedStringArray creates an object of type NamedStringArray if possible, returning an error if not. |
| 2552 | func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStringArray, error) { |
| 2553 | errors := make([]error, 0) |
| 2554 | x := &NamedStringArray{} |
| 2555 | m, ok := compiler.UnpackMap(in) |
| 2556 | if !ok { |
| 2557 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2558 | errors = append(errors, compiler.NewError(context, message)) |
| 2559 | } else { |
| 2560 | allowedKeys := []string{"name", "value"} |
| 2561 | var allowedPatterns []*regexp.Regexp |
| 2562 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2563 | if len(invalidKeys) > 0 { |
| 2564 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2565 | errors = append(errors, compiler.NewError(context, message)) |
| 2566 | } |
| 2567 | // string name = 1; |
| 2568 | v1 := compiler.MapValueForKey(m, "name") |
| 2569 | if v1 != nil { |
| 2570 | x.Name, ok = v1.(string) |
| 2571 | if !ok { |
| 2572 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 2573 | errors = append(errors, compiler.NewError(context, message)) |
| 2574 | } |
| 2575 | } |
| 2576 | // StringArray value = 2; |
| 2577 | v2 := compiler.MapValueForKey(m, "value") |
| 2578 | if v2 != nil { |
| 2579 | var err error |
| 2580 | x.Value, err = NewStringArray(v2, compiler.NewContext("value", context)) |
| 2581 | if err != nil { |
| 2582 | errors = append(errors, err) |
| 2583 | } |
| 2584 | } |
| 2585 | } |
| 2586 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2587 | } |
| 2588 | |
| 2589 | // NewNonBodyParameter creates an object of type NonBodyParameter if possible, returning an error if not. |
| 2590 | func NewNonBodyParameter(in interface{}, context *compiler.Context) (*NonBodyParameter, error) { |
| 2591 | errors := make([]error, 0) |
| 2592 | x := &NonBodyParameter{} |
| 2593 | matched := false |
| 2594 | m, ok := compiler.UnpackMap(in) |
| 2595 | if !ok { |
| 2596 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2597 | errors = append(errors, compiler.NewError(context, message)) |
| 2598 | } else { |
| 2599 | requiredKeys := []string{"in", "name", "type"} |
| 2600 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 2601 | if len(missingKeys) > 0 { |
| 2602 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 2603 | errors = append(errors, compiler.NewError(context, message)) |
| 2604 | } |
| 2605 | // HeaderParameterSubSchema header_parameter_sub_schema = 1; |
| 2606 | { |
| 2607 | // errors might be ok here, they mean we just don't have the right subtype |
| 2608 | t, matchingError := NewHeaderParameterSubSchema(m, compiler.NewContext("headerParameterSubSchema", context)) |
| 2609 | if matchingError == nil { |
| 2610 | x.Oneof = &NonBodyParameter_HeaderParameterSubSchema{HeaderParameterSubSchema: t} |
| 2611 | matched = true |
| 2612 | } else { |
| 2613 | errors = append(errors, matchingError) |
| 2614 | } |
| 2615 | } |
| 2616 | // FormDataParameterSubSchema form_data_parameter_sub_schema = 2; |
| 2617 | { |
| 2618 | // errors might be ok here, they mean we just don't have the right subtype |
| 2619 | t, matchingError := NewFormDataParameterSubSchema(m, compiler.NewContext("formDataParameterSubSchema", context)) |
| 2620 | if matchingError == nil { |
| 2621 | x.Oneof = &NonBodyParameter_FormDataParameterSubSchema{FormDataParameterSubSchema: t} |
| 2622 | matched = true |
| 2623 | } else { |
| 2624 | errors = append(errors, matchingError) |
| 2625 | } |
| 2626 | } |
| 2627 | // QueryParameterSubSchema query_parameter_sub_schema = 3; |
| 2628 | { |
| 2629 | // errors might be ok here, they mean we just don't have the right subtype |
| 2630 | t, matchingError := NewQueryParameterSubSchema(m, compiler.NewContext("queryParameterSubSchema", context)) |
| 2631 | if matchingError == nil { |
| 2632 | x.Oneof = &NonBodyParameter_QueryParameterSubSchema{QueryParameterSubSchema: t} |
| 2633 | matched = true |
| 2634 | } else { |
| 2635 | errors = append(errors, matchingError) |
| 2636 | } |
| 2637 | } |
| 2638 | // PathParameterSubSchema path_parameter_sub_schema = 4; |
| 2639 | { |
| 2640 | // errors might be ok here, they mean we just don't have the right subtype |
| 2641 | t, matchingError := NewPathParameterSubSchema(m, compiler.NewContext("pathParameterSubSchema", context)) |
| 2642 | if matchingError == nil { |
| 2643 | x.Oneof = &NonBodyParameter_PathParameterSubSchema{PathParameterSubSchema: t} |
| 2644 | matched = true |
| 2645 | } else { |
| 2646 | errors = append(errors, matchingError) |
| 2647 | } |
| 2648 | } |
| 2649 | } |
| 2650 | if matched { |
| 2651 | // since the oneof matched one of its possibilities, discard any matching errors |
| 2652 | errors = make([]error, 0) |
| 2653 | } |
| 2654 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2655 | } |
| 2656 | |
| 2657 | // NewOauth2AccessCodeSecurity creates an object of type Oauth2AccessCodeSecurity if possible, returning an error if not. |
| 2658 | func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oauth2AccessCodeSecurity, error) { |
| 2659 | errors := make([]error, 0) |
| 2660 | x := &Oauth2AccessCodeSecurity{} |
| 2661 | m, ok := compiler.UnpackMap(in) |
| 2662 | if !ok { |
| 2663 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2664 | errors = append(errors, compiler.NewError(context, message)) |
| 2665 | } else { |
| 2666 | requiredKeys := []string{"authorizationUrl", "flow", "tokenUrl", "type"} |
| 2667 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 2668 | if len(missingKeys) > 0 { |
| 2669 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 2670 | errors = append(errors, compiler.NewError(context, message)) |
| 2671 | } |
| 2672 | allowedKeys := []string{"authorizationUrl", "description", "flow", "scopes", "tokenUrl", "type"} |
| 2673 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 2674 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2675 | if len(invalidKeys) > 0 { |
| 2676 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2677 | errors = append(errors, compiler.NewError(context, message)) |
| 2678 | } |
| 2679 | // string type = 1; |
| 2680 | v1 := compiler.MapValueForKey(m, "type") |
| 2681 | if v1 != nil { |
| 2682 | x.Type, ok = v1.(string) |
| 2683 | if !ok { |
| 2684 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 2685 | errors = append(errors, compiler.NewError(context, message)) |
| 2686 | } |
| 2687 | // check for valid enum values |
| 2688 | // [oauth2] |
| 2689 | if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { |
| 2690 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 2691 | errors = append(errors, compiler.NewError(context, message)) |
| 2692 | } |
| 2693 | } |
| 2694 | // string flow = 2; |
| 2695 | v2 := compiler.MapValueForKey(m, "flow") |
| 2696 | if v2 != nil { |
| 2697 | x.Flow, ok = v2.(string) |
| 2698 | if !ok { |
| 2699 | message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) |
| 2700 | errors = append(errors, compiler.NewError(context, message)) |
| 2701 | } |
| 2702 | // check for valid enum values |
| 2703 | // [accessCode] |
| 2704 | if ok && !compiler.StringArrayContainsValue([]string{"accessCode"}, x.Flow) { |
| 2705 | message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) |
| 2706 | errors = append(errors, compiler.NewError(context, message)) |
| 2707 | } |
| 2708 | } |
| 2709 | // Oauth2Scopes scopes = 3; |
| 2710 | v3 := compiler.MapValueForKey(m, "scopes") |
| 2711 | if v3 != nil { |
| 2712 | var err error |
| 2713 | x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context)) |
| 2714 | if err != nil { |
| 2715 | errors = append(errors, err) |
| 2716 | } |
| 2717 | } |
| 2718 | // string authorization_url = 4; |
| 2719 | v4 := compiler.MapValueForKey(m, "authorizationUrl") |
| 2720 | if v4 != nil { |
| 2721 | x.AuthorizationUrl, ok = v4.(string) |
| 2722 | if !ok { |
| 2723 | message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v4, v4) |
| 2724 | errors = append(errors, compiler.NewError(context, message)) |
| 2725 | } |
| 2726 | } |
| 2727 | // string token_url = 5; |
| 2728 | v5 := compiler.MapValueForKey(m, "tokenUrl") |
| 2729 | if v5 != nil { |
| 2730 | x.TokenUrl, ok = v5.(string) |
| 2731 | if !ok { |
| 2732 | message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v5, v5) |
| 2733 | errors = append(errors, compiler.NewError(context, message)) |
| 2734 | } |
| 2735 | } |
| 2736 | // string description = 6; |
| 2737 | v6 := compiler.MapValueForKey(m, "description") |
| 2738 | if v6 != nil { |
| 2739 | x.Description, ok = v6.(string) |
| 2740 | if !ok { |
| 2741 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v6, v6) |
| 2742 | errors = append(errors, compiler.NewError(context, message)) |
| 2743 | } |
| 2744 | } |
| 2745 | // repeated NamedAny vendor_extension = 7; |
| 2746 | // MAP: Any ^x- |
| 2747 | x.VendorExtension = make([]*NamedAny, 0) |
| 2748 | for _, item := range m { |
| 2749 | k, ok := compiler.StringValue(item.Key) |
| 2750 | if ok { |
| 2751 | v := item.Value |
| 2752 | if strings.HasPrefix(k, "x-") { |
| 2753 | pair := &NamedAny{} |
| 2754 | pair.Name = k |
| 2755 | result := &Any{} |
| 2756 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 2757 | if handled { |
| 2758 | if err != nil { |
| 2759 | errors = append(errors, err) |
| 2760 | } else { |
| 2761 | bytes, _ := yaml.Marshal(v) |
| 2762 | result.Yaml = string(bytes) |
| 2763 | result.Value = resultFromExt |
| 2764 | pair.Value = result |
| 2765 | } |
| 2766 | } else { |
| 2767 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 2768 | if err != nil { |
| 2769 | errors = append(errors, err) |
| 2770 | } |
| 2771 | } |
| 2772 | x.VendorExtension = append(x.VendorExtension, pair) |
| 2773 | } |
| 2774 | } |
| 2775 | } |
| 2776 | } |
| 2777 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2778 | } |
| 2779 | |
| 2780 | // NewOauth2ApplicationSecurity creates an object of type Oauth2ApplicationSecurity if possible, returning an error if not. |
| 2781 | func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*Oauth2ApplicationSecurity, error) { |
| 2782 | errors := make([]error, 0) |
| 2783 | x := &Oauth2ApplicationSecurity{} |
| 2784 | m, ok := compiler.UnpackMap(in) |
| 2785 | if !ok { |
| 2786 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2787 | errors = append(errors, compiler.NewError(context, message)) |
| 2788 | } else { |
| 2789 | requiredKeys := []string{"flow", "tokenUrl", "type"} |
| 2790 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 2791 | if len(missingKeys) > 0 { |
| 2792 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 2793 | errors = append(errors, compiler.NewError(context, message)) |
| 2794 | } |
| 2795 | allowedKeys := []string{"description", "flow", "scopes", "tokenUrl", "type"} |
| 2796 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 2797 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2798 | if len(invalidKeys) > 0 { |
| 2799 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2800 | errors = append(errors, compiler.NewError(context, message)) |
| 2801 | } |
| 2802 | // string type = 1; |
| 2803 | v1 := compiler.MapValueForKey(m, "type") |
| 2804 | if v1 != nil { |
| 2805 | x.Type, ok = v1.(string) |
| 2806 | if !ok { |
| 2807 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 2808 | errors = append(errors, compiler.NewError(context, message)) |
| 2809 | } |
| 2810 | // check for valid enum values |
| 2811 | // [oauth2] |
| 2812 | if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { |
| 2813 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 2814 | errors = append(errors, compiler.NewError(context, message)) |
| 2815 | } |
| 2816 | } |
| 2817 | // string flow = 2; |
| 2818 | v2 := compiler.MapValueForKey(m, "flow") |
| 2819 | if v2 != nil { |
| 2820 | x.Flow, ok = v2.(string) |
| 2821 | if !ok { |
| 2822 | message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) |
| 2823 | errors = append(errors, compiler.NewError(context, message)) |
| 2824 | } |
| 2825 | // check for valid enum values |
| 2826 | // [application] |
| 2827 | if ok && !compiler.StringArrayContainsValue([]string{"application"}, x.Flow) { |
| 2828 | message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) |
| 2829 | errors = append(errors, compiler.NewError(context, message)) |
| 2830 | } |
| 2831 | } |
| 2832 | // Oauth2Scopes scopes = 3; |
| 2833 | v3 := compiler.MapValueForKey(m, "scopes") |
| 2834 | if v3 != nil { |
| 2835 | var err error |
| 2836 | x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context)) |
| 2837 | if err != nil { |
| 2838 | errors = append(errors, err) |
| 2839 | } |
| 2840 | } |
| 2841 | // string token_url = 4; |
| 2842 | v4 := compiler.MapValueForKey(m, "tokenUrl") |
| 2843 | if v4 != nil { |
| 2844 | x.TokenUrl, ok = v4.(string) |
| 2845 | if !ok { |
| 2846 | message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v4, v4) |
| 2847 | errors = append(errors, compiler.NewError(context, message)) |
| 2848 | } |
| 2849 | } |
| 2850 | // string description = 5; |
| 2851 | v5 := compiler.MapValueForKey(m, "description") |
| 2852 | if v5 != nil { |
| 2853 | x.Description, ok = v5.(string) |
| 2854 | if !ok { |
| 2855 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) |
| 2856 | errors = append(errors, compiler.NewError(context, message)) |
| 2857 | } |
| 2858 | } |
| 2859 | // repeated NamedAny vendor_extension = 6; |
| 2860 | // MAP: Any ^x- |
| 2861 | x.VendorExtension = make([]*NamedAny, 0) |
| 2862 | for _, item := range m { |
| 2863 | k, ok := compiler.StringValue(item.Key) |
| 2864 | if ok { |
| 2865 | v := item.Value |
| 2866 | if strings.HasPrefix(k, "x-") { |
| 2867 | pair := &NamedAny{} |
| 2868 | pair.Name = k |
| 2869 | result := &Any{} |
| 2870 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 2871 | if handled { |
| 2872 | if err != nil { |
| 2873 | errors = append(errors, err) |
| 2874 | } else { |
| 2875 | bytes, _ := yaml.Marshal(v) |
| 2876 | result.Yaml = string(bytes) |
| 2877 | result.Value = resultFromExt |
| 2878 | pair.Value = result |
| 2879 | } |
| 2880 | } else { |
| 2881 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 2882 | if err != nil { |
| 2883 | errors = append(errors, err) |
| 2884 | } |
| 2885 | } |
| 2886 | x.VendorExtension = append(x.VendorExtension, pair) |
| 2887 | } |
| 2888 | } |
| 2889 | } |
| 2890 | } |
| 2891 | return x, compiler.NewErrorGroupOrNil(errors) |
| 2892 | } |
| 2893 | |
| 2894 | // NewOauth2ImplicitSecurity creates an object of type Oauth2ImplicitSecurity if possible, returning an error if not. |
| 2895 | func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oauth2ImplicitSecurity, error) { |
| 2896 | errors := make([]error, 0) |
| 2897 | x := &Oauth2ImplicitSecurity{} |
| 2898 | m, ok := compiler.UnpackMap(in) |
| 2899 | if !ok { |
| 2900 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 2901 | errors = append(errors, compiler.NewError(context, message)) |
| 2902 | } else { |
| 2903 | requiredKeys := []string{"authorizationUrl", "flow", "type"} |
| 2904 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 2905 | if len(missingKeys) > 0 { |
| 2906 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 2907 | errors = append(errors, compiler.NewError(context, message)) |
| 2908 | } |
| 2909 | allowedKeys := []string{"authorizationUrl", "description", "flow", "scopes", "type"} |
| 2910 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 2911 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 2912 | if len(invalidKeys) > 0 { |
| 2913 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 2914 | errors = append(errors, compiler.NewError(context, message)) |
| 2915 | } |
| 2916 | // string type = 1; |
| 2917 | v1 := compiler.MapValueForKey(m, "type") |
| 2918 | if v1 != nil { |
| 2919 | x.Type, ok = v1.(string) |
| 2920 | if !ok { |
| 2921 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 2922 | errors = append(errors, compiler.NewError(context, message)) |
| 2923 | } |
| 2924 | // check for valid enum values |
| 2925 | // [oauth2] |
| 2926 | if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { |
| 2927 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 2928 | errors = append(errors, compiler.NewError(context, message)) |
| 2929 | } |
| 2930 | } |
| 2931 | // string flow = 2; |
| 2932 | v2 := compiler.MapValueForKey(m, "flow") |
| 2933 | if v2 != nil { |
| 2934 | x.Flow, ok = v2.(string) |
| 2935 | if !ok { |
| 2936 | message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) |
| 2937 | errors = append(errors, compiler.NewError(context, message)) |
| 2938 | } |
| 2939 | // check for valid enum values |
| 2940 | // [implicit] |
| 2941 | if ok && !compiler.StringArrayContainsValue([]string{"implicit"}, x.Flow) { |
| 2942 | message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) |
| 2943 | errors = append(errors, compiler.NewError(context, message)) |
| 2944 | } |
| 2945 | } |
| 2946 | // Oauth2Scopes scopes = 3; |
| 2947 | v3 := compiler.MapValueForKey(m, "scopes") |
| 2948 | if v3 != nil { |
| 2949 | var err error |
| 2950 | x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context)) |
| 2951 | if err != nil { |
| 2952 | errors = append(errors, err) |
| 2953 | } |
| 2954 | } |
| 2955 | // string authorization_url = 4; |
| 2956 | v4 := compiler.MapValueForKey(m, "authorizationUrl") |
| 2957 | if v4 != nil { |
| 2958 | x.AuthorizationUrl, ok = v4.(string) |
| 2959 | if !ok { |
| 2960 | message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v4, v4) |
| 2961 | errors = append(errors, compiler.NewError(context, message)) |
| 2962 | } |
| 2963 | } |
| 2964 | // string description = 5; |
| 2965 | v5 := compiler.MapValueForKey(m, "description") |
| 2966 | if v5 != nil { |
| 2967 | x.Description, ok = v5.(string) |
| 2968 | if !ok { |
| 2969 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) |
| 2970 | errors = append(errors, compiler.NewError(context, message)) |
| 2971 | } |
| 2972 | } |
| 2973 | // repeated NamedAny vendor_extension = 6; |
| 2974 | // MAP: Any ^x- |
| 2975 | x.VendorExtension = make([]*NamedAny, 0) |
| 2976 | for _, item := range m { |
| 2977 | k, ok := compiler.StringValue(item.Key) |
| 2978 | if ok { |
| 2979 | v := item.Value |
| 2980 | if strings.HasPrefix(k, "x-") { |
| 2981 | pair := &NamedAny{} |
| 2982 | pair.Name = k |
| 2983 | result := &Any{} |
| 2984 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 2985 | if handled { |
| 2986 | if err != nil { |
| 2987 | errors = append(errors, err) |
| 2988 | } else { |
| 2989 | bytes, _ := yaml.Marshal(v) |
| 2990 | result.Yaml = string(bytes) |
| 2991 | result.Value = resultFromExt |
| 2992 | pair.Value = result |
| 2993 | } |
| 2994 | } else { |
| 2995 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 2996 | if err != nil { |
| 2997 | errors = append(errors, err) |
| 2998 | } |
| 2999 | } |
| 3000 | x.VendorExtension = append(x.VendorExtension, pair) |
| 3001 | } |
| 3002 | } |
| 3003 | } |
| 3004 | } |
| 3005 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3006 | } |
| 3007 | |
| 3008 | // NewOauth2PasswordSecurity creates an object of type Oauth2PasswordSecurity if possible, returning an error if not. |
| 3009 | func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oauth2PasswordSecurity, error) { |
| 3010 | errors := make([]error, 0) |
| 3011 | x := &Oauth2PasswordSecurity{} |
| 3012 | m, ok := compiler.UnpackMap(in) |
| 3013 | if !ok { |
| 3014 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 3015 | errors = append(errors, compiler.NewError(context, message)) |
| 3016 | } else { |
| 3017 | requiredKeys := []string{"flow", "tokenUrl", "type"} |
| 3018 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 3019 | if len(missingKeys) > 0 { |
| 3020 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 3021 | errors = append(errors, compiler.NewError(context, message)) |
| 3022 | } |
| 3023 | allowedKeys := []string{"description", "flow", "scopes", "tokenUrl", "type"} |
| 3024 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 3025 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 3026 | if len(invalidKeys) > 0 { |
| 3027 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 3028 | errors = append(errors, compiler.NewError(context, message)) |
| 3029 | } |
| 3030 | // string type = 1; |
| 3031 | v1 := compiler.MapValueForKey(m, "type") |
| 3032 | if v1 != nil { |
| 3033 | x.Type, ok = v1.(string) |
| 3034 | if !ok { |
| 3035 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 3036 | errors = append(errors, compiler.NewError(context, message)) |
| 3037 | } |
| 3038 | // check for valid enum values |
| 3039 | // [oauth2] |
| 3040 | if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { |
| 3041 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 3042 | errors = append(errors, compiler.NewError(context, message)) |
| 3043 | } |
| 3044 | } |
| 3045 | // string flow = 2; |
| 3046 | v2 := compiler.MapValueForKey(m, "flow") |
| 3047 | if v2 != nil { |
| 3048 | x.Flow, ok = v2.(string) |
| 3049 | if !ok { |
| 3050 | message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) |
| 3051 | errors = append(errors, compiler.NewError(context, message)) |
| 3052 | } |
| 3053 | // check for valid enum values |
| 3054 | // [password] |
| 3055 | if ok && !compiler.StringArrayContainsValue([]string{"password"}, x.Flow) { |
| 3056 | message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) |
| 3057 | errors = append(errors, compiler.NewError(context, message)) |
| 3058 | } |
| 3059 | } |
| 3060 | // Oauth2Scopes scopes = 3; |
| 3061 | v3 := compiler.MapValueForKey(m, "scopes") |
| 3062 | if v3 != nil { |
| 3063 | var err error |
| 3064 | x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context)) |
| 3065 | if err != nil { |
| 3066 | errors = append(errors, err) |
| 3067 | } |
| 3068 | } |
| 3069 | // string token_url = 4; |
| 3070 | v4 := compiler.MapValueForKey(m, "tokenUrl") |
| 3071 | if v4 != nil { |
| 3072 | x.TokenUrl, ok = v4.(string) |
| 3073 | if !ok { |
| 3074 | message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v4, v4) |
| 3075 | errors = append(errors, compiler.NewError(context, message)) |
| 3076 | } |
| 3077 | } |
| 3078 | // string description = 5; |
| 3079 | v5 := compiler.MapValueForKey(m, "description") |
| 3080 | if v5 != nil { |
| 3081 | x.Description, ok = v5.(string) |
| 3082 | if !ok { |
| 3083 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) |
| 3084 | errors = append(errors, compiler.NewError(context, message)) |
| 3085 | } |
| 3086 | } |
| 3087 | // repeated NamedAny vendor_extension = 6; |
| 3088 | // MAP: Any ^x- |
| 3089 | x.VendorExtension = make([]*NamedAny, 0) |
| 3090 | for _, item := range m { |
| 3091 | k, ok := compiler.StringValue(item.Key) |
| 3092 | if ok { |
| 3093 | v := item.Value |
| 3094 | if strings.HasPrefix(k, "x-") { |
| 3095 | pair := &NamedAny{} |
| 3096 | pair.Name = k |
| 3097 | result := &Any{} |
| 3098 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 3099 | if handled { |
| 3100 | if err != nil { |
| 3101 | errors = append(errors, err) |
| 3102 | } else { |
| 3103 | bytes, _ := yaml.Marshal(v) |
| 3104 | result.Yaml = string(bytes) |
| 3105 | result.Value = resultFromExt |
| 3106 | pair.Value = result |
| 3107 | } |
| 3108 | } else { |
| 3109 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 3110 | if err != nil { |
| 3111 | errors = append(errors, err) |
| 3112 | } |
| 3113 | } |
| 3114 | x.VendorExtension = append(x.VendorExtension, pair) |
| 3115 | } |
| 3116 | } |
| 3117 | } |
| 3118 | } |
| 3119 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3120 | } |
| 3121 | |
| 3122 | // NewOauth2Scopes creates an object of type Oauth2Scopes if possible, returning an error if not. |
| 3123 | func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, error) { |
| 3124 | errors := make([]error, 0) |
| 3125 | x := &Oauth2Scopes{} |
| 3126 | m, ok := compiler.UnpackMap(in) |
| 3127 | if !ok { |
| 3128 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 3129 | errors = append(errors, compiler.NewError(context, message)) |
| 3130 | } else { |
| 3131 | // repeated NamedString additional_properties = 1; |
| 3132 | // MAP: string |
| 3133 | x.AdditionalProperties = make([]*NamedString, 0) |
| 3134 | for _, item := range m { |
| 3135 | k, ok := compiler.StringValue(item.Key) |
| 3136 | if ok { |
| 3137 | v := item.Value |
| 3138 | pair := &NamedString{} |
| 3139 | pair.Name = k |
| 3140 | pair.Value = v.(string) |
| 3141 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 3142 | } |
| 3143 | } |
| 3144 | } |
| 3145 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3146 | } |
| 3147 | |
| 3148 | // NewOperation creates an object of type Operation if possible, returning an error if not. |
| 3149 | func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) { |
| 3150 | errors := make([]error, 0) |
| 3151 | x := &Operation{} |
| 3152 | m, ok := compiler.UnpackMap(in) |
| 3153 | if !ok { |
| 3154 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 3155 | errors = append(errors, compiler.NewError(context, message)) |
| 3156 | } else { |
| 3157 | requiredKeys := []string{"responses"} |
| 3158 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 3159 | if len(missingKeys) > 0 { |
| 3160 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 3161 | errors = append(errors, compiler.NewError(context, message)) |
| 3162 | } |
| 3163 | allowedKeys := []string{"consumes", "deprecated", "description", "externalDocs", "operationId", "parameters", "produces", "responses", "schemes", "security", "summary", "tags"} |
| 3164 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 3165 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 3166 | if len(invalidKeys) > 0 { |
| 3167 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 3168 | errors = append(errors, compiler.NewError(context, message)) |
| 3169 | } |
| 3170 | // repeated string tags = 1; |
| 3171 | v1 := compiler.MapValueForKey(m, "tags") |
| 3172 | if v1 != nil { |
| 3173 | v, ok := v1.([]interface{}) |
| 3174 | if ok { |
| 3175 | x.Tags = compiler.ConvertInterfaceArrayToStringArray(v) |
| 3176 | } else { |
| 3177 | message := fmt.Sprintf("has unexpected value for tags: %+v (%T)", v1, v1) |
| 3178 | errors = append(errors, compiler.NewError(context, message)) |
| 3179 | } |
| 3180 | } |
| 3181 | // string summary = 2; |
| 3182 | v2 := compiler.MapValueForKey(m, "summary") |
| 3183 | if v2 != nil { |
| 3184 | x.Summary, ok = v2.(string) |
| 3185 | if !ok { |
| 3186 | message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2) |
| 3187 | errors = append(errors, compiler.NewError(context, message)) |
| 3188 | } |
| 3189 | } |
| 3190 | // string description = 3; |
| 3191 | v3 := compiler.MapValueForKey(m, "description") |
| 3192 | if v3 != nil { |
| 3193 | x.Description, ok = v3.(string) |
| 3194 | if !ok { |
| 3195 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) |
| 3196 | errors = append(errors, compiler.NewError(context, message)) |
| 3197 | } |
| 3198 | } |
| 3199 | // ExternalDocs external_docs = 4; |
| 3200 | v4 := compiler.MapValueForKey(m, "externalDocs") |
| 3201 | if v4 != nil { |
| 3202 | var err error |
| 3203 | x.ExternalDocs, err = NewExternalDocs(v4, compiler.NewContext("externalDocs", context)) |
| 3204 | if err != nil { |
| 3205 | errors = append(errors, err) |
| 3206 | } |
| 3207 | } |
| 3208 | // string operation_id = 5; |
| 3209 | v5 := compiler.MapValueForKey(m, "operationId") |
| 3210 | if v5 != nil { |
| 3211 | x.OperationId, ok = v5.(string) |
| 3212 | if !ok { |
| 3213 | message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v5, v5) |
| 3214 | errors = append(errors, compiler.NewError(context, message)) |
| 3215 | } |
| 3216 | } |
| 3217 | // repeated string produces = 6; |
| 3218 | v6 := compiler.MapValueForKey(m, "produces") |
| 3219 | if v6 != nil { |
| 3220 | v, ok := v6.([]interface{}) |
| 3221 | if ok { |
| 3222 | x.Produces = compiler.ConvertInterfaceArrayToStringArray(v) |
| 3223 | } else { |
| 3224 | message := fmt.Sprintf("has unexpected value for produces: %+v (%T)", v6, v6) |
| 3225 | errors = append(errors, compiler.NewError(context, message)) |
| 3226 | } |
| 3227 | } |
| 3228 | // repeated string consumes = 7; |
| 3229 | v7 := compiler.MapValueForKey(m, "consumes") |
| 3230 | if v7 != nil { |
| 3231 | v, ok := v7.([]interface{}) |
| 3232 | if ok { |
| 3233 | x.Consumes = compiler.ConvertInterfaceArrayToStringArray(v) |
| 3234 | } else { |
| 3235 | message := fmt.Sprintf("has unexpected value for consumes: %+v (%T)", v7, v7) |
| 3236 | errors = append(errors, compiler.NewError(context, message)) |
| 3237 | } |
| 3238 | } |
| 3239 | // repeated ParametersItem parameters = 8; |
| 3240 | v8 := compiler.MapValueForKey(m, "parameters") |
| 3241 | if v8 != nil { |
| 3242 | // repeated ParametersItem |
| 3243 | x.Parameters = make([]*ParametersItem, 0) |
| 3244 | a, ok := v8.([]interface{}) |
| 3245 | if ok { |
| 3246 | for _, item := range a { |
| 3247 | y, err := NewParametersItem(item, compiler.NewContext("parameters", context)) |
| 3248 | if err != nil { |
| 3249 | errors = append(errors, err) |
| 3250 | } |
| 3251 | x.Parameters = append(x.Parameters, y) |
| 3252 | } |
| 3253 | } |
| 3254 | } |
| 3255 | // Responses responses = 9; |
| 3256 | v9 := compiler.MapValueForKey(m, "responses") |
| 3257 | if v9 != nil { |
| 3258 | var err error |
| 3259 | x.Responses, err = NewResponses(v9, compiler.NewContext("responses", context)) |
| 3260 | if err != nil { |
| 3261 | errors = append(errors, err) |
| 3262 | } |
| 3263 | } |
| 3264 | // repeated string schemes = 10; |
| 3265 | v10 := compiler.MapValueForKey(m, "schemes") |
| 3266 | if v10 != nil { |
| 3267 | v, ok := v10.([]interface{}) |
| 3268 | if ok { |
| 3269 | x.Schemes = compiler.ConvertInterfaceArrayToStringArray(v) |
| 3270 | } else { |
| 3271 | message := fmt.Sprintf("has unexpected value for schemes: %+v (%T)", v10, v10) |
| 3272 | errors = append(errors, compiler.NewError(context, message)) |
| 3273 | } |
| 3274 | // check for valid enum values |
| 3275 | // [http https ws wss] |
| 3276 | if ok && !compiler.StringArrayContainsValues([]string{"http", "https", "ws", "wss"}, x.Schemes) { |
| 3277 | message := fmt.Sprintf("has unexpected value for schemes: %+v", v10) |
| 3278 | errors = append(errors, compiler.NewError(context, message)) |
| 3279 | } |
| 3280 | } |
| 3281 | // bool deprecated = 11; |
| 3282 | v11 := compiler.MapValueForKey(m, "deprecated") |
| 3283 | if v11 != nil { |
| 3284 | x.Deprecated, ok = v11.(bool) |
| 3285 | if !ok { |
| 3286 | message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v11, v11) |
| 3287 | errors = append(errors, compiler.NewError(context, message)) |
| 3288 | } |
| 3289 | } |
| 3290 | // repeated SecurityRequirement security = 12; |
| 3291 | v12 := compiler.MapValueForKey(m, "security") |
| 3292 | if v12 != nil { |
| 3293 | // repeated SecurityRequirement |
| 3294 | x.Security = make([]*SecurityRequirement, 0) |
| 3295 | a, ok := v12.([]interface{}) |
| 3296 | if ok { |
| 3297 | for _, item := range a { |
| 3298 | y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) |
| 3299 | if err != nil { |
| 3300 | errors = append(errors, err) |
| 3301 | } |
| 3302 | x.Security = append(x.Security, y) |
| 3303 | } |
| 3304 | } |
| 3305 | } |
| 3306 | // repeated NamedAny vendor_extension = 13; |
| 3307 | // MAP: Any ^x- |
| 3308 | x.VendorExtension = make([]*NamedAny, 0) |
| 3309 | for _, item := range m { |
| 3310 | k, ok := compiler.StringValue(item.Key) |
| 3311 | if ok { |
| 3312 | v := item.Value |
| 3313 | if strings.HasPrefix(k, "x-") { |
| 3314 | pair := &NamedAny{} |
| 3315 | pair.Name = k |
| 3316 | result := &Any{} |
| 3317 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 3318 | if handled { |
| 3319 | if err != nil { |
| 3320 | errors = append(errors, err) |
| 3321 | } else { |
| 3322 | bytes, _ := yaml.Marshal(v) |
| 3323 | result.Yaml = string(bytes) |
| 3324 | result.Value = resultFromExt |
| 3325 | pair.Value = result |
| 3326 | } |
| 3327 | } else { |
| 3328 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 3329 | if err != nil { |
| 3330 | errors = append(errors, err) |
| 3331 | } |
| 3332 | } |
| 3333 | x.VendorExtension = append(x.VendorExtension, pair) |
| 3334 | } |
| 3335 | } |
| 3336 | } |
| 3337 | } |
| 3338 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3339 | } |
| 3340 | |
| 3341 | // NewParameter creates an object of type Parameter if possible, returning an error if not. |
| 3342 | func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) { |
| 3343 | errors := make([]error, 0) |
| 3344 | x := &Parameter{} |
| 3345 | matched := false |
| 3346 | // BodyParameter body_parameter = 1; |
| 3347 | { |
| 3348 | m, ok := compiler.UnpackMap(in) |
| 3349 | if ok { |
| 3350 | // errors might be ok here, they mean we just don't have the right subtype |
| 3351 | t, matchingError := NewBodyParameter(m, compiler.NewContext("bodyParameter", context)) |
| 3352 | if matchingError == nil { |
| 3353 | x.Oneof = &Parameter_BodyParameter{BodyParameter: t} |
| 3354 | matched = true |
| 3355 | } else { |
| 3356 | errors = append(errors, matchingError) |
| 3357 | } |
| 3358 | } |
| 3359 | } |
| 3360 | // NonBodyParameter non_body_parameter = 2; |
| 3361 | { |
| 3362 | m, ok := compiler.UnpackMap(in) |
| 3363 | if ok { |
| 3364 | // errors might be ok here, they mean we just don't have the right subtype |
| 3365 | t, matchingError := NewNonBodyParameter(m, compiler.NewContext("nonBodyParameter", context)) |
| 3366 | if matchingError == nil { |
| 3367 | x.Oneof = &Parameter_NonBodyParameter{NonBodyParameter: t} |
| 3368 | matched = true |
| 3369 | } else { |
| 3370 | errors = append(errors, matchingError) |
| 3371 | } |
| 3372 | } |
| 3373 | } |
| 3374 | if matched { |
| 3375 | // since the oneof matched one of its possibilities, discard any matching errors |
| 3376 | errors = make([]error, 0) |
| 3377 | } |
| 3378 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3379 | } |
| 3380 | |
| 3381 | // NewParameterDefinitions creates an object of type ParameterDefinitions if possible, returning an error if not. |
| 3382 | func NewParameterDefinitions(in interface{}, context *compiler.Context) (*ParameterDefinitions, error) { |
| 3383 | errors := make([]error, 0) |
| 3384 | x := &ParameterDefinitions{} |
| 3385 | m, ok := compiler.UnpackMap(in) |
| 3386 | if !ok { |
| 3387 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 3388 | errors = append(errors, compiler.NewError(context, message)) |
| 3389 | } else { |
| 3390 | // repeated NamedParameter additional_properties = 1; |
| 3391 | // MAP: Parameter |
| 3392 | x.AdditionalProperties = make([]*NamedParameter, 0) |
| 3393 | for _, item := range m { |
| 3394 | k, ok := compiler.StringValue(item.Key) |
| 3395 | if ok { |
| 3396 | v := item.Value |
| 3397 | pair := &NamedParameter{} |
| 3398 | pair.Name = k |
| 3399 | var err error |
| 3400 | pair.Value, err = NewParameter(v, compiler.NewContext(k, context)) |
| 3401 | if err != nil { |
| 3402 | errors = append(errors, err) |
| 3403 | } |
| 3404 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 3405 | } |
| 3406 | } |
| 3407 | } |
| 3408 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3409 | } |
| 3410 | |
| 3411 | // NewParametersItem creates an object of type ParametersItem if possible, returning an error if not. |
| 3412 | func NewParametersItem(in interface{}, context *compiler.Context) (*ParametersItem, error) { |
| 3413 | errors := make([]error, 0) |
| 3414 | x := &ParametersItem{} |
| 3415 | matched := false |
| 3416 | // Parameter parameter = 1; |
| 3417 | { |
| 3418 | m, ok := compiler.UnpackMap(in) |
| 3419 | if ok { |
| 3420 | // errors might be ok here, they mean we just don't have the right subtype |
| 3421 | t, matchingError := NewParameter(m, compiler.NewContext("parameter", context)) |
| 3422 | if matchingError == nil { |
| 3423 | x.Oneof = &ParametersItem_Parameter{Parameter: t} |
| 3424 | matched = true |
| 3425 | } else { |
| 3426 | errors = append(errors, matchingError) |
| 3427 | } |
| 3428 | } |
| 3429 | } |
| 3430 | // JsonReference json_reference = 2; |
| 3431 | { |
| 3432 | m, ok := compiler.UnpackMap(in) |
| 3433 | if ok { |
| 3434 | // errors might be ok here, they mean we just don't have the right subtype |
| 3435 | t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", context)) |
| 3436 | if matchingError == nil { |
| 3437 | x.Oneof = &ParametersItem_JsonReference{JsonReference: t} |
| 3438 | matched = true |
| 3439 | } else { |
| 3440 | errors = append(errors, matchingError) |
| 3441 | } |
| 3442 | } |
| 3443 | } |
| 3444 | if matched { |
| 3445 | // since the oneof matched one of its possibilities, discard any matching errors |
| 3446 | errors = make([]error, 0) |
| 3447 | } |
| 3448 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3449 | } |
| 3450 | |
| 3451 | // NewPathItem creates an object of type PathItem if possible, returning an error if not. |
| 3452 | func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { |
| 3453 | errors := make([]error, 0) |
| 3454 | x := &PathItem{} |
| 3455 | m, ok := compiler.UnpackMap(in) |
| 3456 | if !ok { |
| 3457 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 3458 | errors = append(errors, compiler.NewError(context, message)) |
| 3459 | } else { |
| 3460 | allowedKeys := []string{"$ref", "delete", "get", "head", "options", "parameters", "patch", "post", "put"} |
| 3461 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 3462 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 3463 | if len(invalidKeys) > 0 { |
| 3464 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 3465 | errors = append(errors, compiler.NewError(context, message)) |
| 3466 | } |
| 3467 | // string _ref = 1; |
| 3468 | v1 := compiler.MapValueForKey(m, "$ref") |
| 3469 | if v1 != nil { |
| 3470 | x.XRef, ok = v1.(string) |
| 3471 | if !ok { |
| 3472 | message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) |
| 3473 | errors = append(errors, compiler.NewError(context, message)) |
| 3474 | } |
| 3475 | } |
| 3476 | // Operation get = 2; |
| 3477 | v2 := compiler.MapValueForKey(m, "get") |
| 3478 | if v2 != nil { |
| 3479 | var err error |
| 3480 | x.Get, err = NewOperation(v2, compiler.NewContext("get", context)) |
| 3481 | if err != nil { |
| 3482 | errors = append(errors, err) |
| 3483 | } |
| 3484 | } |
| 3485 | // Operation put = 3; |
| 3486 | v3 := compiler.MapValueForKey(m, "put") |
| 3487 | if v3 != nil { |
| 3488 | var err error |
| 3489 | x.Put, err = NewOperation(v3, compiler.NewContext("put", context)) |
| 3490 | if err != nil { |
| 3491 | errors = append(errors, err) |
| 3492 | } |
| 3493 | } |
| 3494 | // Operation post = 4; |
| 3495 | v4 := compiler.MapValueForKey(m, "post") |
| 3496 | if v4 != nil { |
| 3497 | var err error |
| 3498 | x.Post, err = NewOperation(v4, compiler.NewContext("post", context)) |
| 3499 | if err != nil { |
| 3500 | errors = append(errors, err) |
| 3501 | } |
| 3502 | } |
| 3503 | // Operation delete = 5; |
| 3504 | v5 := compiler.MapValueForKey(m, "delete") |
| 3505 | if v5 != nil { |
| 3506 | var err error |
| 3507 | x.Delete, err = NewOperation(v5, compiler.NewContext("delete", context)) |
| 3508 | if err != nil { |
| 3509 | errors = append(errors, err) |
| 3510 | } |
| 3511 | } |
| 3512 | // Operation options = 6; |
| 3513 | v6 := compiler.MapValueForKey(m, "options") |
| 3514 | if v6 != nil { |
| 3515 | var err error |
| 3516 | x.Options, err = NewOperation(v6, compiler.NewContext("options", context)) |
| 3517 | if err != nil { |
| 3518 | errors = append(errors, err) |
| 3519 | } |
| 3520 | } |
| 3521 | // Operation head = 7; |
| 3522 | v7 := compiler.MapValueForKey(m, "head") |
| 3523 | if v7 != nil { |
| 3524 | var err error |
| 3525 | x.Head, err = NewOperation(v7, compiler.NewContext("head", context)) |
| 3526 | if err != nil { |
| 3527 | errors = append(errors, err) |
| 3528 | } |
| 3529 | } |
| 3530 | // Operation patch = 8; |
| 3531 | v8 := compiler.MapValueForKey(m, "patch") |
| 3532 | if v8 != nil { |
| 3533 | var err error |
| 3534 | x.Patch, err = NewOperation(v8, compiler.NewContext("patch", context)) |
| 3535 | if err != nil { |
| 3536 | errors = append(errors, err) |
| 3537 | } |
| 3538 | } |
| 3539 | // repeated ParametersItem parameters = 9; |
| 3540 | v9 := compiler.MapValueForKey(m, "parameters") |
| 3541 | if v9 != nil { |
| 3542 | // repeated ParametersItem |
| 3543 | x.Parameters = make([]*ParametersItem, 0) |
| 3544 | a, ok := v9.([]interface{}) |
| 3545 | if ok { |
| 3546 | for _, item := range a { |
| 3547 | y, err := NewParametersItem(item, compiler.NewContext("parameters", context)) |
| 3548 | if err != nil { |
| 3549 | errors = append(errors, err) |
| 3550 | } |
| 3551 | x.Parameters = append(x.Parameters, y) |
| 3552 | } |
| 3553 | } |
| 3554 | } |
| 3555 | // repeated NamedAny vendor_extension = 10; |
| 3556 | // MAP: Any ^x- |
| 3557 | x.VendorExtension = make([]*NamedAny, 0) |
| 3558 | for _, item := range m { |
| 3559 | k, ok := compiler.StringValue(item.Key) |
| 3560 | if ok { |
| 3561 | v := item.Value |
| 3562 | if strings.HasPrefix(k, "x-") { |
| 3563 | pair := &NamedAny{} |
| 3564 | pair.Name = k |
| 3565 | result := &Any{} |
| 3566 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 3567 | if handled { |
| 3568 | if err != nil { |
| 3569 | errors = append(errors, err) |
| 3570 | } else { |
| 3571 | bytes, _ := yaml.Marshal(v) |
| 3572 | result.Yaml = string(bytes) |
| 3573 | result.Value = resultFromExt |
| 3574 | pair.Value = result |
| 3575 | } |
| 3576 | } else { |
| 3577 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 3578 | if err != nil { |
| 3579 | errors = append(errors, err) |
| 3580 | } |
| 3581 | } |
| 3582 | x.VendorExtension = append(x.VendorExtension, pair) |
| 3583 | } |
| 3584 | } |
| 3585 | } |
| 3586 | } |
| 3587 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3588 | } |
| 3589 | |
| 3590 | // NewPathParameterSubSchema creates an object of type PathParameterSubSchema if possible, returning an error if not. |
| 3591 | func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*PathParameterSubSchema, error) { |
| 3592 | errors := make([]error, 0) |
| 3593 | x := &PathParameterSubSchema{} |
| 3594 | m, ok := compiler.UnpackMap(in) |
| 3595 | if !ok { |
| 3596 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 3597 | errors = append(errors, compiler.NewError(context, message)) |
| 3598 | } else { |
| 3599 | requiredKeys := []string{"required"} |
| 3600 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 3601 | if len(missingKeys) > 0 { |
| 3602 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 3603 | errors = append(errors, compiler.NewError(context, message)) |
| 3604 | } |
| 3605 | allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} |
| 3606 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 3607 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 3608 | if len(invalidKeys) > 0 { |
| 3609 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 3610 | errors = append(errors, compiler.NewError(context, message)) |
| 3611 | } |
| 3612 | // bool required = 1; |
| 3613 | v1 := compiler.MapValueForKey(m, "required") |
| 3614 | if v1 != nil { |
| 3615 | x.Required, ok = v1.(bool) |
| 3616 | if !ok { |
| 3617 | message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) |
| 3618 | errors = append(errors, compiler.NewError(context, message)) |
| 3619 | } |
| 3620 | } |
| 3621 | // string in = 2; |
| 3622 | v2 := compiler.MapValueForKey(m, "in") |
| 3623 | if v2 != nil { |
| 3624 | x.In, ok = v2.(string) |
| 3625 | if !ok { |
| 3626 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) |
| 3627 | errors = append(errors, compiler.NewError(context, message)) |
| 3628 | } |
| 3629 | // check for valid enum values |
| 3630 | // [path] |
| 3631 | if ok && !compiler.StringArrayContainsValue([]string{"path"}, x.In) { |
| 3632 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) |
| 3633 | errors = append(errors, compiler.NewError(context, message)) |
| 3634 | } |
| 3635 | } |
| 3636 | // string description = 3; |
| 3637 | v3 := compiler.MapValueForKey(m, "description") |
| 3638 | if v3 != nil { |
| 3639 | x.Description, ok = v3.(string) |
| 3640 | if !ok { |
| 3641 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) |
| 3642 | errors = append(errors, compiler.NewError(context, message)) |
| 3643 | } |
| 3644 | } |
| 3645 | // string name = 4; |
| 3646 | v4 := compiler.MapValueForKey(m, "name") |
| 3647 | if v4 != nil { |
| 3648 | x.Name, ok = v4.(string) |
| 3649 | if !ok { |
| 3650 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) |
| 3651 | errors = append(errors, compiler.NewError(context, message)) |
| 3652 | } |
| 3653 | } |
| 3654 | // string type = 5; |
| 3655 | v5 := compiler.MapValueForKey(m, "type") |
| 3656 | if v5 != nil { |
| 3657 | x.Type, ok = v5.(string) |
| 3658 | if !ok { |
| 3659 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) |
| 3660 | errors = append(errors, compiler.NewError(context, message)) |
| 3661 | } |
| 3662 | // check for valid enum values |
| 3663 | // [string number boolean integer array] |
| 3664 | if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { |
| 3665 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) |
| 3666 | errors = append(errors, compiler.NewError(context, message)) |
| 3667 | } |
| 3668 | } |
| 3669 | // string format = 6; |
| 3670 | v6 := compiler.MapValueForKey(m, "format") |
| 3671 | if v6 != nil { |
| 3672 | x.Format, ok = v6.(string) |
| 3673 | if !ok { |
| 3674 | message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6) |
| 3675 | errors = append(errors, compiler.NewError(context, message)) |
| 3676 | } |
| 3677 | } |
| 3678 | // PrimitivesItems items = 7; |
| 3679 | v7 := compiler.MapValueForKey(m, "items") |
| 3680 | if v7 != nil { |
| 3681 | var err error |
| 3682 | x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", context)) |
| 3683 | if err != nil { |
| 3684 | errors = append(errors, err) |
| 3685 | } |
| 3686 | } |
| 3687 | // string collection_format = 8; |
| 3688 | v8 := compiler.MapValueForKey(m, "collectionFormat") |
| 3689 | if v8 != nil { |
| 3690 | x.CollectionFormat, ok = v8.(string) |
| 3691 | if !ok { |
| 3692 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) |
| 3693 | errors = append(errors, compiler.NewError(context, message)) |
| 3694 | } |
| 3695 | // check for valid enum values |
| 3696 | // [csv ssv tsv pipes] |
| 3697 | if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { |
| 3698 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) |
| 3699 | errors = append(errors, compiler.NewError(context, message)) |
| 3700 | } |
| 3701 | } |
| 3702 | // Any default = 9; |
| 3703 | v9 := compiler.MapValueForKey(m, "default") |
| 3704 | if v9 != nil { |
| 3705 | var err error |
| 3706 | x.Default, err = NewAny(v9, compiler.NewContext("default", context)) |
| 3707 | if err != nil { |
| 3708 | errors = append(errors, err) |
| 3709 | } |
| 3710 | } |
| 3711 | // float maximum = 10; |
| 3712 | v10 := compiler.MapValueForKey(m, "maximum") |
| 3713 | if v10 != nil { |
| 3714 | switch v10 := v10.(type) { |
| 3715 | case float64: |
| 3716 | x.Maximum = v10 |
| 3717 | case float32: |
| 3718 | x.Maximum = float64(v10) |
| 3719 | case uint64: |
| 3720 | x.Maximum = float64(v10) |
| 3721 | case uint32: |
| 3722 | x.Maximum = float64(v10) |
| 3723 | case int64: |
| 3724 | x.Maximum = float64(v10) |
| 3725 | case int32: |
| 3726 | x.Maximum = float64(v10) |
| 3727 | case int: |
| 3728 | x.Maximum = float64(v10) |
| 3729 | default: |
| 3730 | message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10) |
| 3731 | errors = append(errors, compiler.NewError(context, message)) |
| 3732 | } |
| 3733 | } |
| 3734 | // bool exclusive_maximum = 11; |
| 3735 | v11 := compiler.MapValueForKey(m, "exclusiveMaximum") |
| 3736 | if v11 != nil { |
| 3737 | x.ExclusiveMaximum, ok = v11.(bool) |
| 3738 | if !ok { |
| 3739 | message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11) |
| 3740 | errors = append(errors, compiler.NewError(context, message)) |
| 3741 | } |
| 3742 | } |
| 3743 | // float minimum = 12; |
| 3744 | v12 := compiler.MapValueForKey(m, "minimum") |
| 3745 | if v12 != nil { |
| 3746 | switch v12 := v12.(type) { |
| 3747 | case float64: |
| 3748 | x.Minimum = v12 |
| 3749 | case float32: |
| 3750 | x.Minimum = float64(v12) |
| 3751 | case uint64: |
| 3752 | x.Minimum = float64(v12) |
| 3753 | case uint32: |
| 3754 | x.Minimum = float64(v12) |
| 3755 | case int64: |
| 3756 | x.Minimum = float64(v12) |
| 3757 | case int32: |
| 3758 | x.Minimum = float64(v12) |
| 3759 | case int: |
| 3760 | x.Minimum = float64(v12) |
| 3761 | default: |
| 3762 | message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12) |
| 3763 | errors = append(errors, compiler.NewError(context, message)) |
| 3764 | } |
| 3765 | } |
| 3766 | // bool exclusive_minimum = 13; |
| 3767 | v13 := compiler.MapValueForKey(m, "exclusiveMinimum") |
| 3768 | if v13 != nil { |
| 3769 | x.ExclusiveMinimum, ok = v13.(bool) |
| 3770 | if !ok { |
| 3771 | message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13) |
| 3772 | errors = append(errors, compiler.NewError(context, message)) |
| 3773 | } |
| 3774 | } |
| 3775 | // int64 max_length = 14; |
| 3776 | v14 := compiler.MapValueForKey(m, "maxLength") |
| 3777 | if v14 != nil { |
| 3778 | t, ok := v14.(int) |
| 3779 | if ok { |
| 3780 | x.MaxLength = int64(t) |
| 3781 | } else { |
| 3782 | message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v14, v14) |
| 3783 | errors = append(errors, compiler.NewError(context, message)) |
| 3784 | } |
| 3785 | } |
| 3786 | // int64 min_length = 15; |
| 3787 | v15 := compiler.MapValueForKey(m, "minLength") |
| 3788 | if v15 != nil { |
| 3789 | t, ok := v15.(int) |
| 3790 | if ok { |
| 3791 | x.MinLength = int64(t) |
| 3792 | } else { |
| 3793 | message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v15, v15) |
| 3794 | errors = append(errors, compiler.NewError(context, message)) |
| 3795 | } |
| 3796 | } |
| 3797 | // string pattern = 16; |
| 3798 | v16 := compiler.MapValueForKey(m, "pattern") |
| 3799 | if v16 != nil { |
| 3800 | x.Pattern, ok = v16.(string) |
| 3801 | if !ok { |
| 3802 | message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16) |
| 3803 | errors = append(errors, compiler.NewError(context, message)) |
| 3804 | } |
| 3805 | } |
| 3806 | // int64 max_items = 17; |
| 3807 | v17 := compiler.MapValueForKey(m, "maxItems") |
| 3808 | if v17 != nil { |
| 3809 | t, ok := v17.(int) |
| 3810 | if ok { |
| 3811 | x.MaxItems = int64(t) |
| 3812 | } else { |
| 3813 | message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v17, v17) |
| 3814 | errors = append(errors, compiler.NewError(context, message)) |
| 3815 | } |
| 3816 | } |
| 3817 | // int64 min_items = 18; |
| 3818 | v18 := compiler.MapValueForKey(m, "minItems") |
| 3819 | if v18 != nil { |
| 3820 | t, ok := v18.(int) |
| 3821 | if ok { |
| 3822 | x.MinItems = int64(t) |
| 3823 | } else { |
| 3824 | message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v18, v18) |
| 3825 | errors = append(errors, compiler.NewError(context, message)) |
| 3826 | } |
| 3827 | } |
| 3828 | // bool unique_items = 19; |
| 3829 | v19 := compiler.MapValueForKey(m, "uniqueItems") |
| 3830 | if v19 != nil { |
| 3831 | x.UniqueItems, ok = v19.(bool) |
| 3832 | if !ok { |
| 3833 | message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19) |
| 3834 | errors = append(errors, compiler.NewError(context, message)) |
| 3835 | } |
| 3836 | } |
| 3837 | // repeated Any enum = 20; |
| 3838 | v20 := compiler.MapValueForKey(m, "enum") |
| 3839 | if v20 != nil { |
| 3840 | // repeated Any |
| 3841 | x.Enum = make([]*Any, 0) |
| 3842 | a, ok := v20.([]interface{}) |
| 3843 | if ok { |
| 3844 | for _, item := range a { |
| 3845 | y, err := NewAny(item, compiler.NewContext("enum", context)) |
| 3846 | if err != nil { |
| 3847 | errors = append(errors, err) |
| 3848 | } |
| 3849 | x.Enum = append(x.Enum, y) |
| 3850 | } |
| 3851 | } |
| 3852 | } |
| 3853 | // float multiple_of = 21; |
| 3854 | v21 := compiler.MapValueForKey(m, "multipleOf") |
| 3855 | if v21 != nil { |
| 3856 | switch v21 := v21.(type) { |
| 3857 | case float64: |
| 3858 | x.MultipleOf = v21 |
| 3859 | case float32: |
| 3860 | x.MultipleOf = float64(v21) |
| 3861 | case uint64: |
| 3862 | x.MultipleOf = float64(v21) |
| 3863 | case uint32: |
| 3864 | x.MultipleOf = float64(v21) |
| 3865 | case int64: |
| 3866 | x.MultipleOf = float64(v21) |
| 3867 | case int32: |
| 3868 | x.MultipleOf = float64(v21) |
| 3869 | case int: |
| 3870 | x.MultipleOf = float64(v21) |
| 3871 | default: |
| 3872 | message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v21, v21) |
| 3873 | errors = append(errors, compiler.NewError(context, message)) |
| 3874 | } |
| 3875 | } |
| 3876 | // repeated NamedAny vendor_extension = 22; |
| 3877 | // MAP: Any ^x- |
| 3878 | x.VendorExtension = make([]*NamedAny, 0) |
| 3879 | for _, item := range m { |
| 3880 | k, ok := compiler.StringValue(item.Key) |
| 3881 | if ok { |
| 3882 | v := item.Value |
| 3883 | if strings.HasPrefix(k, "x-") { |
| 3884 | pair := &NamedAny{} |
| 3885 | pair.Name = k |
| 3886 | result := &Any{} |
| 3887 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 3888 | if handled { |
| 3889 | if err != nil { |
| 3890 | errors = append(errors, err) |
| 3891 | } else { |
| 3892 | bytes, _ := yaml.Marshal(v) |
| 3893 | result.Yaml = string(bytes) |
| 3894 | result.Value = resultFromExt |
| 3895 | pair.Value = result |
| 3896 | } |
| 3897 | } else { |
| 3898 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 3899 | if err != nil { |
| 3900 | errors = append(errors, err) |
| 3901 | } |
| 3902 | } |
| 3903 | x.VendorExtension = append(x.VendorExtension, pair) |
| 3904 | } |
| 3905 | } |
| 3906 | } |
| 3907 | } |
| 3908 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3909 | } |
| 3910 | |
| 3911 | // NewPaths creates an object of type Paths if possible, returning an error if not. |
| 3912 | func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { |
| 3913 | errors := make([]error, 0) |
| 3914 | x := &Paths{} |
| 3915 | m, ok := compiler.UnpackMap(in) |
| 3916 | if !ok { |
| 3917 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 3918 | errors = append(errors, compiler.NewError(context, message)) |
| 3919 | } else { |
| 3920 | allowedKeys := []string{} |
| 3921 | allowedPatterns := []*regexp.Regexp{pattern0, pattern1} |
| 3922 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 3923 | if len(invalidKeys) > 0 { |
| 3924 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 3925 | errors = append(errors, compiler.NewError(context, message)) |
| 3926 | } |
| 3927 | // repeated NamedAny vendor_extension = 1; |
| 3928 | // MAP: Any ^x- |
| 3929 | x.VendorExtension = make([]*NamedAny, 0) |
| 3930 | for _, item := range m { |
| 3931 | k, ok := compiler.StringValue(item.Key) |
| 3932 | if ok { |
| 3933 | v := item.Value |
| 3934 | if strings.HasPrefix(k, "x-") { |
| 3935 | pair := &NamedAny{} |
| 3936 | pair.Name = k |
| 3937 | result := &Any{} |
| 3938 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 3939 | if handled { |
| 3940 | if err != nil { |
| 3941 | errors = append(errors, err) |
| 3942 | } else { |
| 3943 | bytes, _ := yaml.Marshal(v) |
| 3944 | result.Yaml = string(bytes) |
| 3945 | result.Value = resultFromExt |
| 3946 | pair.Value = result |
| 3947 | } |
| 3948 | } else { |
| 3949 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 3950 | if err != nil { |
| 3951 | errors = append(errors, err) |
| 3952 | } |
| 3953 | } |
| 3954 | x.VendorExtension = append(x.VendorExtension, pair) |
| 3955 | } |
| 3956 | } |
| 3957 | } |
| 3958 | // repeated NamedPathItem path = 2; |
| 3959 | // MAP: PathItem ^/ |
| 3960 | x.Path = make([]*NamedPathItem, 0) |
| 3961 | for _, item := range m { |
| 3962 | k, ok := compiler.StringValue(item.Key) |
| 3963 | if ok { |
| 3964 | v := item.Value |
| 3965 | if strings.HasPrefix(k, "/") { |
| 3966 | pair := &NamedPathItem{} |
| 3967 | pair.Name = k |
| 3968 | var err error |
| 3969 | pair.Value, err = NewPathItem(v, compiler.NewContext(k, context)) |
| 3970 | if err != nil { |
| 3971 | errors = append(errors, err) |
| 3972 | } |
| 3973 | x.Path = append(x.Path, pair) |
| 3974 | } |
| 3975 | } |
| 3976 | } |
| 3977 | } |
| 3978 | return x, compiler.NewErrorGroupOrNil(errors) |
| 3979 | } |
| 3980 | |
| 3981 | // NewPrimitivesItems creates an object of type PrimitivesItems if possible, returning an error if not. |
| 3982 | func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesItems, error) { |
| 3983 | errors := make([]error, 0) |
| 3984 | x := &PrimitivesItems{} |
| 3985 | m, ok := compiler.UnpackMap(in) |
| 3986 | if !ok { |
| 3987 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 3988 | errors = append(errors, compiler.NewError(context, message)) |
| 3989 | } else { |
| 3990 | allowedKeys := []string{"collectionFormat", "default", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "pattern", "type", "uniqueItems"} |
| 3991 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 3992 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 3993 | if len(invalidKeys) > 0 { |
| 3994 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 3995 | errors = append(errors, compiler.NewError(context, message)) |
| 3996 | } |
| 3997 | // string type = 1; |
| 3998 | v1 := compiler.MapValueForKey(m, "type") |
| 3999 | if v1 != nil { |
| 4000 | x.Type, ok = v1.(string) |
| 4001 | if !ok { |
| 4002 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 4003 | errors = append(errors, compiler.NewError(context, message)) |
| 4004 | } |
| 4005 | // check for valid enum values |
| 4006 | // [string number integer boolean array] |
| 4007 | if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "integer", "boolean", "array"}, x.Type) { |
| 4008 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) |
| 4009 | errors = append(errors, compiler.NewError(context, message)) |
| 4010 | } |
| 4011 | } |
| 4012 | // string format = 2; |
| 4013 | v2 := compiler.MapValueForKey(m, "format") |
| 4014 | if v2 != nil { |
| 4015 | x.Format, ok = v2.(string) |
| 4016 | if !ok { |
| 4017 | message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) |
| 4018 | errors = append(errors, compiler.NewError(context, message)) |
| 4019 | } |
| 4020 | } |
| 4021 | // PrimitivesItems items = 3; |
| 4022 | v3 := compiler.MapValueForKey(m, "items") |
| 4023 | if v3 != nil { |
| 4024 | var err error |
| 4025 | x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", context)) |
| 4026 | if err != nil { |
| 4027 | errors = append(errors, err) |
| 4028 | } |
| 4029 | } |
| 4030 | // string collection_format = 4; |
| 4031 | v4 := compiler.MapValueForKey(m, "collectionFormat") |
| 4032 | if v4 != nil { |
| 4033 | x.CollectionFormat, ok = v4.(string) |
| 4034 | if !ok { |
| 4035 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) |
| 4036 | errors = append(errors, compiler.NewError(context, message)) |
| 4037 | } |
| 4038 | // check for valid enum values |
| 4039 | // [csv ssv tsv pipes] |
| 4040 | if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { |
| 4041 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) |
| 4042 | errors = append(errors, compiler.NewError(context, message)) |
| 4043 | } |
| 4044 | } |
| 4045 | // Any default = 5; |
| 4046 | v5 := compiler.MapValueForKey(m, "default") |
| 4047 | if v5 != nil { |
| 4048 | var err error |
| 4049 | x.Default, err = NewAny(v5, compiler.NewContext("default", context)) |
| 4050 | if err != nil { |
| 4051 | errors = append(errors, err) |
| 4052 | } |
| 4053 | } |
| 4054 | // float maximum = 6; |
| 4055 | v6 := compiler.MapValueForKey(m, "maximum") |
| 4056 | if v6 != nil { |
| 4057 | switch v6 := v6.(type) { |
| 4058 | case float64: |
| 4059 | x.Maximum = v6 |
| 4060 | case float32: |
| 4061 | x.Maximum = float64(v6) |
| 4062 | case uint64: |
| 4063 | x.Maximum = float64(v6) |
| 4064 | case uint32: |
| 4065 | x.Maximum = float64(v6) |
| 4066 | case int64: |
| 4067 | x.Maximum = float64(v6) |
| 4068 | case int32: |
| 4069 | x.Maximum = float64(v6) |
| 4070 | case int: |
| 4071 | x.Maximum = float64(v6) |
| 4072 | default: |
| 4073 | message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v6, v6) |
| 4074 | errors = append(errors, compiler.NewError(context, message)) |
| 4075 | } |
| 4076 | } |
| 4077 | // bool exclusive_maximum = 7; |
| 4078 | v7 := compiler.MapValueForKey(m, "exclusiveMaximum") |
| 4079 | if v7 != nil { |
| 4080 | x.ExclusiveMaximum, ok = v7.(bool) |
| 4081 | if !ok { |
| 4082 | message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v7, v7) |
| 4083 | errors = append(errors, compiler.NewError(context, message)) |
| 4084 | } |
| 4085 | } |
| 4086 | // float minimum = 8; |
| 4087 | v8 := compiler.MapValueForKey(m, "minimum") |
| 4088 | if v8 != nil { |
| 4089 | switch v8 := v8.(type) { |
| 4090 | case float64: |
| 4091 | x.Minimum = v8 |
| 4092 | case float32: |
| 4093 | x.Minimum = float64(v8) |
| 4094 | case uint64: |
| 4095 | x.Minimum = float64(v8) |
| 4096 | case uint32: |
| 4097 | x.Minimum = float64(v8) |
| 4098 | case int64: |
| 4099 | x.Minimum = float64(v8) |
| 4100 | case int32: |
| 4101 | x.Minimum = float64(v8) |
| 4102 | case int: |
| 4103 | x.Minimum = float64(v8) |
| 4104 | default: |
| 4105 | message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8) |
| 4106 | errors = append(errors, compiler.NewError(context, message)) |
| 4107 | } |
| 4108 | } |
| 4109 | // bool exclusive_minimum = 9; |
| 4110 | v9 := compiler.MapValueForKey(m, "exclusiveMinimum") |
| 4111 | if v9 != nil { |
| 4112 | x.ExclusiveMinimum, ok = v9.(bool) |
| 4113 | if !ok { |
| 4114 | message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v9, v9) |
| 4115 | errors = append(errors, compiler.NewError(context, message)) |
| 4116 | } |
| 4117 | } |
| 4118 | // int64 max_length = 10; |
| 4119 | v10 := compiler.MapValueForKey(m, "maxLength") |
| 4120 | if v10 != nil { |
| 4121 | t, ok := v10.(int) |
| 4122 | if ok { |
| 4123 | x.MaxLength = int64(t) |
| 4124 | } else { |
| 4125 | message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v10, v10) |
| 4126 | errors = append(errors, compiler.NewError(context, message)) |
| 4127 | } |
| 4128 | } |
| 4129 | // int64 min_length = 11; |
| 4130 | v11 := compiler.MapValueForKey(m, "minLength") |
| 4131 | if v11 != nil { |
| 4132 | t, ok := v11.(int) |
| 4133 | if ok { |
| 4134 | x.MinLength = int64(t) |
| 4135 | } else { |
| 4136 | message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v11, v11) |
| 4137 | errors = append(errors, compiler.NewError(context, message)) |
| 4138 | } |
| 4139 | } |
| 4140 | // string pattern = 12; |
| 4141 | v12 := compiler.MapValueForKey(m, "pattern") |
| 4142 | if v12 != nil { |
| 4143 | x.Pattern, ok = v12.(string) |
| 4144 | if !ok { |
| 4145 | message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v12, v12) |
| 4146 | errors = append(errors, compiler.NewError(context, message)) |
| 4147 | } |
| 4148 | } |
| 4149 | // int64 max_items = 13; |
| 4150 | v13 := compiler.MapValueForKey(m, "maxItems") |
| 4151 | if v13 != nil { |
| 4152 | t, ok := v13.(int) |
| 4153 | if ok { |
| 4154 | x.MaxItems = int64(t) |
| 4155 | } else { |
| 4156 | message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v13, v13) |
| 4157 | errors = append(errors, compiler.NewError(context, message)) |
| 4158 | } |
| 4159 | } |
| 4160 | // int64 min_items = 14; |
| 4161 | v14 := compiler.MapValueForKey(m, "minItems") |
| 4162 | if v14 != nil { |
| 4163 | t, ok := v14.(int) |
| 4164 | if ok { |
| 4165 | x.MinItems = int64(t) |
| 4166 | } else { |
| 4167 | message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v14, v14) |
| 4168 | errors = append(errors, compiler.NewError(context, message)) |
| 4169 | } |
| 4170 | } |
| 4171 | // bool unique_items = 15; |
| 4172 | v15 := compiler.MapValueForKey(m, "uniqueItems") |
| 4173 | if v15 != nil { |
| 4174 | x.UniqueItems, ok = v15.(bool) |
| 4175 | if !ok { |
| 4176 | message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v15, v15) |
| 4177 | errors = append(errors, compiler.NewError(context, message)) |
| 4178 | } |
| 4179 | } |
| 4180 | // repeated Any enum = 16; |
| 4181 | v16 := compiler.MapValueForKey(m, "enum") |
| 4182 | if v16 != nil { |
| 4183 | // repeated Any |
| 4184 | x.Enum = make([]*Any, 0) |
| 4185 | a, ok := v16.([]interface{}) |
| 4186 | if ok { |
| 4187 | for _, item := range a { |
| 4188 | y, err := NewAny(item, compiler.NewContext("enum", context)) |
| 4189 | if err != nil { |
| 4190 | errors = append(errors, err) |
| 4191 | } |
| 4192 | x.Enum = append(x.Enum, y) |
| 4193 | } |
| 4194 | } |
| 4195 | } |
| 4196 | // float multiple_of = 17; |
| 4197 | v17 := compiler.MapValueForKey(m, "multipleOf") |
| 4198 | if v17 != nil { |
| 4199 | switch v17 := v17.(type) { |
| 4200 | case float64: |
| 4201 | x.MultipleOf = v17 |
| 4202 | case float32: |
| 4203 | x.MultipleOf = float64(v17) |
| 4204 | case uint64: |
| 4205 | x.MultipleOf = float64(v17) |
| 4206 | case uint32: |
| 4207 | x.MultipleOf = float64(v17) |
| 4208 | case int64: |
| 4209 | x.MultipleOf = float64(v17) |
| 4210 | case int32: |
| 4211 | x.MultipleOf = float64(v17) |
| 4212 | case int: |
| 4213 | x.MultipleOf = float64(v17) |
| 4214 | default: |
| 4215 | message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v17, v17) |
| 4216 | errors = append(errors, compiler.NewError(context, message)) |
| 4217 | } |
| 4218 | } |
| 4219 | // repeated NamedAny vendor_extension = 18; |
| 4220 | // MAP: Any ^x- |
| 4221 | x.VendorExtension = make([]*NamedAny, 0) |
| 4222 | for _, item := range m { |
| 4223 | k, ok := compiler.StringValue(item.Key) |
| 4224 | if ok { |
| 4225 | v := item.Value |
| 4226 | if strings.HasPrefix(k, "x-") { |
| 4227 | pair := &NamedAny{} |
| 4228 | pair.Name = k |
| 4229 | result := &Any{} |
| 4230 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 4231 | if handled { |
| 4232 | if err != nil { |
| 4233 | errors = append(errors, err) |
| 4234 | } else { |
| 4235 | bytes, _ := yaml.Marshal(v) |
| 4236 | result.Yaml = string(bytes) |
| 4237 | result.Value = resultFromExt |
| 4238 | pair.Value = result |
| 4239 | } |
| 4240 | } else { |
| 4241 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 4242 | if err != nil { |
| 4243 | errors = append(errors, err) |
| 4244 | } |
| 4245 | } |
| 4246 | x.VendorExtension = append(x.VendorExtension, pair) |
| 4247 | } |
| 4248 | } |
| 4249 | } |
| 4250 | } |
| 4251 | return x, compiler.NewErrorGroupOrNil(errors) |
| 4252 | } |
| 4253 | |
| 4254 | // NewProperties creates an object of type Properties if possible, returning an error if not. |
| 4255 | func NewProperties(in interface{}, context *compiler.Context) (*Properties, error) { |
| 4256 | errors := make([]error, 0) |
| 4257 | x := &Properties{} |
| 4258 | m, ok := compiler.UnpackMap(in) |
| 4259 | if !ok { |
| 4260 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 4261 | errors = append(errors, compiler.NewError(context, message)) |
| 4262 | } else { |
| 4263 | // repeated NamedSchema additional_properties = 1; |
| 4264 | // MAP: Schema |
| 4265 | x.AdditionalProperties = make([]*NamedSchema, 0) |
| 4266 | for _, item := range m { |
| 4267 | k, ok := compiler.StringValue(item.Key) |
| 4268 | if ok { |
| 4269 | v := item.Value |
| 4270 | pair := &NamedSchema{} |
| 4271 | pair.Name = k |
| 4272 | var err error |
| 4273 | pair.Value, err = NewSchema(v, compiler.NewContext(k, context)) |
| 4274 | if err != nil { |
| 4275 | errors = append(errors, err) |
| 4276 | } |
| 4277 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 4278 | } |
| 4279 | } |
| 4280 | } |
| 4281 | return x, compiler.NewErrorGroupOrNil(errors) |
| 4282 | } |
| 4283 | |
| 4284 | // NewQueryParameterSubSchema creates an object of type QueryParameterSubSchema if possible, returning an error if not. |
| 4285 | func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*QueryParameterSubSchema, error) { |
| 4286 | errors := make([]error, 0) |
| 4287 | x := &QueryParameterSubSchema{} |
| 4288 | m, ok := compiler.UnpackMap(in) |
| 4289 | if !ok { |
| 4290 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 4291 | errors = append(errors, compiler.NewError(context, message)) |
| 4292 | } else { |
| 4293 | allowedKeys := []string{"allowEmptyValue", "collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} |
| 4294 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 4295 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 4296 | if len(invalidKeys) > 0 { |
| 4297 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 4298 | errors = append(errors, compiler.NewError(context, message)) |
| 4299 | } |
| 4300 | // bool required = 1; |
| 4301 | v1 := compiler.MapValueForKey(m, "required") |
| 4302 | if v1 != nil { |
| 4303 | x.Required, ok = v1.(bool) |
| 4304 | if !ok { |
| 4305 | message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) |
| 4306 | errors = append(errors, compiler.NewError(context, message)) |
| 4307 | } |
| 4308 | } |
| 4309 | // string in = 2; |
| 4310 | v2 := compiler.MapValueForKey(m, "in") |
| 4311 | if v2 != nil { |
| 4312 | x.In, ok = v2.(string) |
| 4313 | if !ok { |
| 4314 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) |
| 4315 | errors = append(errors, compiler.NewError(context, message)) |
| 4316 | } |
| 4317 | // check for valid enum values |
| 4318 | // [query] |
| 4319 | if ok && !compiler.StringArrayContainsValue([]string{"query"}, x.In) { |
| 4320 | message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) |
| 4321 | errors = append(errors, compiler.NewError(context, message)) |
| 4322 | } |
| 4323 | } |
| 4324 | // string description = 3; |
| 4325 | v3 := compiler.MapValueForKey(m, "description") |
| 4326 | if v3 != nil { |
| 4327 | x.Description, ok = v3.(string) |
| 4328 | if !ok { |
| 4329 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) |
| 4330 | errors = append(errors, compiler.NewError(context, message)) |
| 4331 | } |
| 4332 | } |
| 4333 | // string name = 4; |
| 4334 | v4 := compiler.MapValueForKey(m, "name") |
| 4335 | if v4 != nil { |
| 4336 | x.Name, ok = v4.(string) |
| 4337 | if !ok { |
| 4338 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) |
| 4339 | errors = append(errors, compiler.NewError(context, message)) |
| 4340 | } |
| 4341 | } |
| 4342 | // bool allow_empty_value = 5; |
| 4343 | v5 := compiler.MapValueForKey(m, "allowEmptyValue") |
| 4344 | if v5 != nil { |
| 4345 | x.AllowEmptyValue, ok = v5.(bool) |
| 4346 | if !ok { |
| 4347 | message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v5, v5) |
| 4348 | errors = append(errors, compiler.NewError(context, message)) |
| 4349 | } |
| 4350 | } |
| 4351 | // string type = 6; |
| 4352 | v6 := compiler.MapValueForKey(m, "type") |
| 4353 | if v6 != nil { |
| 4354 | x.Type, ok = v6.(string) |
| 4355 | if !ok { |
| 4356 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) |
| 4357 | errors = append(errors, compiler.NewError(context, message)) |
| 4358 | } |
| 4359 | // check for valid enum values |
| 4360 | // [string number boolean integer array] |
| 4361 | if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { |
| 4362 | message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) |
| 4363 | errors = append(errors, compiler.NewError(context, message)) |
| 4364 | } |
| 4365 | } |
| 4366 | // string format = 7; |
| 4367 | v7 := compiler.MapValueForKey(m, "format") |
| 4368 | if v7 != nil { |
| 4369 | x.Format, ok = v7.(string) |
| 4370 | if !ok { |
| 4371 | message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7) |
| 4372 | errors = append(errors, compiler.NewError(context, message)) |
| 4373 | } |
| 4374 | } |
| 4375 | // PrimitivesItems items = 8; |
| 4376 | v8 := compiler.MapValueForKey(m, "items") |
| 4377 | if v8 != nil { |
| 4378 | var err error |
| 4379 | x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", context)) |
| 4380 | if err != nil { |
| 4381 | errors = append(errors, err) |
| 4382 | } |
| 4383 | } |
| 4384 | // string collection_format = 9; |
| 4385 | v9 := compiler.MapValueForKey(m, "collectionFormat") |
| 4386 | if v9 != nil { |
| 4387 | x.CollectionFormat, ok = v9.(string) |
| 4388 | if !ok { |
| 4389 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) |
| 4390 | errors = append(errors, compiler.NewError(context, message)) |
| 4391 | } |
| 4392 | // check for valid enum values |
| 4393 | // [csv ssv tsv pipes multi] |
| 4394 | if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes", "multi"}, x.CollectionFormat) { |
| 4395 | message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) |
| 4396 | errors = append(errors, compiler.NewError(context, message)) |
| 4397 | } |
| 4398 | } |
| 4399 | // Any default = 10; |
| 4400 | v10 := compiler.MapValueForKey(m, "default") |
| 4401 | if v10 != nil { |
| 4402 | var err error |
| 4403 | x.Default, err = NewAny(v10, compiler.NewContext("default", context)) |
| 4404 | if err != nil { |
| 4405 | errors = append(errors, err) |
| 4406 | } |
| 4407 | } |
| 4408 | // float maximum = 11; |
| 4409 | v11 := compiler.MapValueForKey(m, "maximum") |
| 4410 | if v11 != nil { |
| 4411 | switch v11 := v11.(type) { |
| 4412 | case float64: |
| 4413 | x.Maximum = v11 |
| 4414 | case float32: |
| 4415 | x.Maximum = float64(v11) |
| 4416 | case uint64: |
| 4417 | x.Maximum = float64(v11) |
| 4418 | case uint32: |
| 4419 | x.Maximum = float64(v11) |
| 4420 | case int64: |
| 4421 | x.Maximum = float64(v11) |
| 4422 | case int32: |
| 4423 | x.Maximum = float64(v11) |
| 4424 | case int: |
| 4425 | x.Maximum = float64(v11) |
| 4426 | default: |
| 4427 | message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11) |
| 4428 | errors = append(errors, compiler.NewError(context, message)) |
| 4429 | } |
| 4430 | } |
| 4431 | // bool exclusive_maximum = 12; |
| 4432 | v12 := compiler.MapValueForKey(m, "exclusiveMaximum") |
| 4433 | if v12 != nil { |
| 4434 | x.ExclusiveMaximum, ok = v12.(bool) |
| 4435 | if !ok { |
| 4436 | message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12) |
| 4437 | errors = append(errors, compiler.NewError(context, message)) |
| 4438 | } |
| 4439 | } |
| 4440 | // float minimum = 13; |
| 4441 | v13 := compiler.MapValueForKey(m, "minimum") |
| 4442 | if v13 != nil { |
| 4443 | switch v13 := v13.(type) { |
| 4444 | case float64: |
| 4445 | x.Minimum = v13 |
| 4446 | case float32: |
| 4447 | x.Minimum = float64(v13) |
| 4448 | case uint64: |
| 4449 | x.Minimum = float64(v13) |
| 4450 | case uint32: |
| 4451 | x.Minimum = float64(v13) |
| 4452 | case int64: |
| 4453 | x.Minimum = float64(v13) |
| 4454 | case int32: |
| 4455 | x.Minimum = float64(v13) |
| 4456 | case int: |
| 4457 | x.Minimum = float64(v13) |
| 4458 | default: |
| 4459 | message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13) |
| 4460 | errors = append(errors, compiler.NewError(context, message)) |
| 4461 | } |
| 4462 | } |
| 4463 | // bool exclusive_minimum = 14; |
| 4464 | v14 := compiler.MapValueForKey(m, "exclusiveMinimum") |
| 4465 | if v14 != nil { |
| 4466 | x.ExclusiveMinimum, ok = v14.(bool) |
| 4467 | if !ok { |
| 4468 | message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14) |
| 4469 | errors = append(errors, compiler.NewError(context, message)) |
| 4470 | } |
| 4471 | } |
| 4472 | // int64 max_length = 15; |
| 4473 | v15 := compiler.MapValueForKey(m, "maxLength") |
| 4474 | if v15 != nil { |
| 4475 | t, ok := v15.(int) |
| 4476 | if ok { |
| 4477 | x.MaxLength = int64(t) |
| 4478 | } else { |
| 4479 | message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v15, v15) |
| 4480 | errors = append(errors, compiler.NewError(context, message)) |
| 4481 | } |
| 4482 | } |
| 4483 | // int64 min_length = 16; |
| 4484 | v16 := compiler.MapValueForKey(m, "minLength") |
| 4485 | if v16 != nil { |
| 4486 | t, ok := v16.(int) |
| 4487 | if ok { |
| 4488 | x.MinLength = int64(t) |
| 4489 | } else { |
| 4490 | message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v16, v16) |
| 4491 | errors = append(errors, compiler.NewError(context, message)) |
| 4492 | } |
| 4493 | } |
| 4494 | // string pattern = 17; |
| 4495 | v17 := compiler.MapValueForKey(m, "pattern") |
| 4496 | if v17 != nil { |
| 4497 | x.Pattern, ok = v17.(string) |
| 4498 | if !ok { |
| 4499 | message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17) |
| 4500 | errors = append(errors, compiler.NewError(context, message)) |
| 4501 | } |
| 4502 | } |
| 4503 | // int64 max_items = 18; |
| 4504 | v18 := compiler.MapValueForKey(m, "maxItems") |
| 4505 | if v18 != nil { |
| 4506 | t, ok := v18.(int) |
| 4507 | if ok { |
| 4508 | x.MaxItems = int64(t) |
| 4509 | } else { |
| 4510 | message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v18, v18) |
| 4511 | errors = append(errors, compiler.NewError(context, message)) |
| 4512 | } |
| 4513 | } |
| 4514 | // int64 min_items = 19; |
| 4515 | v19 := compiler.MapValueForKey(m, "minItems") |
| 4516 | if v19 != nil { |
| 4517 | t, ok := v19.(int) |
| 4518 | if ok { |
| 4519 | x.MinItems = int64(t) |
| 4520 | } else { |
| 4521 | message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v19, v19) |
| 4522 | errors = append(errors, compiler.NewError(context, message)) |
| 4523 | } |
| 4524 | } |
| 4525 | // bool unique_items = 20; |
| 4526 | v20 := compiler.MapValueForKey(m, "uniqueItems") |
| 4527 | if v20 != nil { |
| 4528 | x.UniqueItems, ok = v20.(bool) |
| 4529 | if !ok { |
| 4530 | message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20) |
| 4531 | errors = append(errors, compiler.NewError(context, message)) |
| 4532 | } |
| 4533 | } |
| 4534 | // repeated Any enum = 21; |
| 4535 | v21 := compiler.MapValueForKey(m, "enum") |
| 4536 | if v21 != nil { |
| 4537 | // repeated Any |
| 4538 | x.Enum = make([]*Any, 0) |
| 4539 | a, ok := v21.([]interface{}) |
| 4540 | if ok { |
| 4541 | for _, item := range a { |
| 4542 | y, err := NewAny(item, compiler.NewContext("enum", context)) |
| 4543 | if err != nil { |
| 4544 | errors = append(errors, err) |
| 4545 | } |
| 4546 | x.Enum = append(x.Enum, y) |
| 4547 | } |
| 4548 | } |
| 4549 | } |
| 4550 | // float multiple_of = 22; |
| 4551 | v22 := compiler.MapValueForKey(m, "multipleOf") |
| 4552 | if v22 != nil { |
| 4553 | switch v22 := v22.(type) { |
| 4554 | case float64: |
| 4555 | x.MultipleOf = v22 |
| 4556 | case float32: |
| 4557 | x.MultipleOf = float64(v22) |
| 4558 | case uint64: |
| 4559 | x.MultipleOf = float64(v22) |
| 4560 | case uint32: |
| 4561 | x.MultipleOf = float64(v22) |
| 4562 | case int64: |
| 4563 | x.MultipleOf = float64(v22) |
| 4564 | case int32: |
| 4565 | x.MultipleOf = float64(v22) |
| 4566 | case int: |
| 4567 | x.MultipleOf = float64(v22) |
| 4568 | default: |
| 4569 | message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v22, v22) |
| 4570 | errors = append(errors, compiler.NewError(context, message)) |
| 4571 | } |
| 4572 | } |
| 4573 | // repeated NamedAny vendor_extension = 23; |
| 4574 | // MAP: Any ^x- |
| 4575 | x.VendorExtension = make([]*NamedAny, 0) |
| 4576 | for _, item := range m { |
| 4577 | k, ok := compiler.StringValue(item.Key) |
| 4578 | if ok { |
| 4579 | v := item.Value |
| 4580 | if strings.HasPrefix(k, "x-") { |
| 4581 | pair := &NamedAny{} |
| 4582 | pair.Name = k |
| 4583 | result := &Any{} |
| 4584 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 4585 | if handled { |
| 4586 | if err != nil { |
| 4587 | errors = append(errors, err) |
| 4588 | } else { |
| 4589 | bytes, _ := yaml.Marshal(v) |
| 4590 | result.Yaml = string(bytes) |
| 4591 | result.Value = resultFromExt |
| 4592 | pair.Value = result |
| 4593 | } |
| 4594 | } else { |
| 4595 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 4596 | if err != nil { |
| 4597 | errors = append(errors, err) |
| 4598 | } |
| 4599 | } |
| 4600 | x.VendorExtension = append(x.VendorExtension, pair) |
| 4601 | } |
| 4602 | } |
| 4603 | } |
| 4604 | } |
| 4605 | return x, compiler.NewErrorGroupOrNil(errors) |
| 4606 | } |
| 4607 | |
| 4608 | // NewResponse creates an object of type Response if possible, returning an error if not. |
| 4609 | func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { |
| 4610 | errors := make([]error, 0) |
| 4611 | x := &Response{} |
| 4612 | m, ok := compiler.UnpackMap(in) |
| 4613 | if !ok { |
| 4614 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 4615 | errors = append(errors, compiler.NewError(context, message)) |
| 4616 | } else { |
| 4617 | requiredKeys := []string{"description"} |
| 4618 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 4619 | if len(missingKeys) > 0 { |
| 4620 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 4621 | errors = append(errors, compiler.NewError(context, message)) |
| 4622 | } |
| 4623 | allowedKeys := []string{"description", "examples", "headers", "schema"} |
| 4624 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 4625 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 4626 | if len(invalidKeys) > 0 { |
| 4627 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 4628 | errors = append(errors, compiler.NewError(context, message)) |
| 4629 | } |
| 4630 | // string description = 1; |
| 4631 | v1 := compiler.MapValueForKey(m, "description") |
| 4632 | if v1 != nil { |
| 4633 | x.Description, ok = v1.(string) |
| 4634 | if !ok { |
| 4635 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) |
| 4636 | errors = append(errors, compiler.NewError(context, message)) |
| 4637 | } |
| 4638 | } |
| 4639 | // SchemaItem schema = 2; |
| 4640 | v2 := compiler.MapValueForKey(m, "schema") |
| 4641 | if v2 != nil { |
| 4642 | var err error |
| 4643 | x.Schema, err = NewSchemaItem(v2, compiler.NewContext("schema", context)) |
| 4644 | if err != nil { |
| 4645 | errors = append(errors, err) |
| 4646 | } |
| 4647 | } |
| 4648 | // Headers headers = 3; |
| 4649 | v3 := compiler.MapValueForKey(m, "headers") |
| 4650 | if v3 != nil { |
| 4651 | var err error |
| 4652 | x.Headers, err = NewHeaders(v3, compiler.NewContext("headers", context)) |
| 4653 | if err != nil { |
| 4654 | errors = append(errors, err) |
| 4655 | } |
| 4656 | } |
| 4657 | // Examples examples = 4; |
| 4658 | v4 := compiler.MapValueForKey(m, "examples") |
| 4659 | if v4 != nil { |
| 4660 | var err error |
| 4661 | x.Examples, err = NewExamples(v4, compiler.NewContext("examples", context)) |
| 4662 | if err != nil { |
| 4663 | errors = append(errors, err) |
| 4664 | } |
| 4665 | } |
| 4666 | // repeated NamedAny vendor_extension = 5; |
| 4667 | // MAP: Any ^x- |
| 4668 | x.VendorExtension = make([]*NamedAny, 0) |
| 4669 | for _, item := range m { |
| 4670 | k, ok := compiler.StringValue(item.Key) |
| 4671 | if ok { |
| 4672 | v := item.Value |
| 4673 | if strings.HasPrefix(k, "x-") { |
| 4674 | pair := &NamedAny{} |
| 4675 | pair.Name = k |
| 4676 | result := &Any{} |
| 4677 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 4678 | if handled { |
| 4679 | if err != nil { |
| 4680 | errors = append(errors, err) |
| 4681 | } else { |
| 4682 | bytes, _ := yaml.Marshal(v) |
| 4683 | result.Yaml = string(bytes) |
| 4684 | result.Value = resultFromExt |
| 4685 | pair.Value = result |
| 4686 | } |
| 4687 | } else { |
| 4688 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 4689 | if err != nil { |
| 4690 | errors = append(errors, err) |
| 4691 | } |
| 4692 | } |
| 4693 | x.VendorExtension = append(x.VendorExtension, pair) |
| 4694 | } |
| 4695 | } |
| 4696 | } |
| 4697 | } |
| 4698 | return x, compiler.NewErrorGroupOrNil(errors) |
| 4699 | } |
| 4700 | |
| 4701 | // NewResponseDefinitions creates an object of type ResponseDefinitions if possible, returning an error if not. |
| 4702 | func NewResponseDefinitions(in interface{}, context *compiler.Context) (*ResponseDefinitions, error) { |
| 4703 | errors := make([]error, 0) |
| 4704 | x := &ResponseDefinitions{} |
| 4705 | m, ok := compiler.UnpackMap(in) |
| 4706 | if !ok { |
| 4707 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 4708 | errors = append(errors, compiler.NewError(context, message)) |
| 4709 | } else { |
| 4710 | // repeated NamedResponse additional_properties = 1; |
| 4711 | // MAP: Response |
| 4712 | x.AdditionalProperties = make([]*NamedResponse, 0) |
| 4713 | for _, item := range m { |
| 4714 | k, ok := compiler.StringValue(item.Key) |
| 4715 | if ok { |
| 4716 | v := item.Value |
| 4717 | pair := &NamedResponse{} |
| 4718 | pair.Name = k |
| 4719 | var err error |
| 4720 | pair.Value, err = NewResponse(v, compiler.NewContext(k, context)) |
| 4721 | if err != nil { |
| 4722 | errors = append(errors, err) |
| 4723 | } |
| 4724 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 4725 | } |
| 4726 | } |
| 4727 | } |
| 4728 | return x, compiler.NewErrorGroupOrNil(errors) |
| 4729 | } |
| 4730 | |
| 4731 | // NewResponseValue creates an object of type ResponseValue if possible, returning an error if not. |
| 4732 | func NewResponseValue(in interface{}, context *compiler.Context) (*ResponseValue, error) { |
| 4733 | errors := make([]error, 0) |
| 4734 | x := &ResponseValue{} |
| 4735 | matched := false |
| 4736 | // Response response = 1; |
| 4737 | { |
| 4738 | m, ok := compiler.UnpackMap(in) |
| 4739 | if ok { |
| 4740 | // errors might be ok here, they mean we just don't have the right subtype |
| 4741 | t, matchingError := NewResponse(m, compiler.NewContext("response", context)) |
| 4742 | if matchingError == nil { |
| 4743 | x.Oneof = &ResponseValue_Response{Response: t} |
| 4744 | matched = true |
| 4745 | } else { |
| 4746 | errors = append(errors, matchingError) |
| 4747 | } |
| 4748 | } |
| 4749 | } |
| 4750 | // JsonReference json_reference = 2; |
| 4751 | { |
| 4752 | m, ok := compiler.UnpackMap(in) |
| 4753 | if ok { |
| 4754 | // errors might be ok here, they mean we just don't have the right subtype |
| 4755 | t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", context)) |
| 4756 | if matchingError == nil { |
| 4757 | x.Oneof = &ResponseValue_JsonReference{JsonReference: t} |
| 4758 | matched = true |
| 4759 | } else { |
| 4760 | errors = append(errors, matchingError) |
| 4761 | } |
| 4762 | } |
| 4763 | } |
| 4764 | if matched { |
| 4765 | // since the oneof matched one of its possibilities, discard any matching errors |
| 4766 | errors = make([]error, 0) |
| 4767 | } |
| 4768 | return x, compiler.NewErrorGroupOrNil(errors) |
| 4769 | } |
| 4770 | |
| 4771 | // NewResponses creates an object of type Responses if possible, returning an error if not. |
| 4772 | func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) { |
| 4773 | errors := make([]error, 0) |
| 4774 | x := &Responses{} |
| 4775 | m, ok := compiler.UnpackMap(in) |
| 4776 | if !ok { |
| 4777 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 4778 | errors = append(errors, compiler.NewError(context, message)) |
| 4779 | } else { |
| 4780 | allowedKeys := []string{} |
| 4781 | allowedPatterns := []*regexp.Regexp{pattern2, pattern0} |
| 4782 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 4783 | if len(invalidKeys) > 0 { |
| 4784 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 4785 | errors = append(errors, compiler.NewError(context, message)) |
| 4786 | } |
| 4787 | // repeated NamedResponseValue response_code = 1; |
| 4788 | // MAP: ResponseValue ^([0-9]{3})$|^(default)$ |
| 4789 | x.ResponseCode = make([]*NamedResponseValue, 0) |
| 4790 | for _, item := range m { |
| 4791 | k, ok := compiler.StringValue(item.Key) |
| 4792 | if ok { |
| 4793 | v := item.Value |
| 4794 | if pattern2.MatchString(k) { |
| 4795 | pair := &NamedResponseValue{} |
| 4796 | pair.Name = k |
| 4797 | var err error |
| 4798 | pair.Value, err = NewResponseValue(v, compiler.NewContext(k, context)) |
| 4799 | if err != nil { |
| 4800 | errors = append(errors, err) |
| 4801 | } |
| 4802 | x.ResponseCode = append(x.ResponseCode, pair) |
| 4803 | } |
| 4804 | } |
| 4805 | } |
| 4806 | // repeated NamedAny vendor_extension = 2; |
| 4807 | // MAP: Any ^x- |
| 4808 | x.VendorExtension = make([]*NamedAny, 0) |
| 4809 | for _, item := range m { |
| 4810 | k, ok := compiler.StringValue(item.Key) |
| 4811 | if ok { |
| 4812 | v := item.Value |
| 4813 | if strings.HasPrefix(k, "x-") { |
| 4814 | pair := &NamedAny{} |
| 4815 | pair.Name = k |
| 4816 | result := &Any{} |
| 4817 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 4818 | if handled { |
| 4819 | if err != nil { |
| 4820 | errors = append(errors, err) |
| 4821 | } else { |
| 4822 | bytes, _ := yaml.Marshal(v) |
| 4823 | result.Yaml = string(bytes) |
| 4824 | result.Value = resultFromExt |
| 4825 | pair.Value = result |
| 4826 | } |
| 4827 | } else { |
| 4828 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 4829 | if err != nil { |
| 4830 | errors = append(errors, err) |
| 4831 | } |
| 4832 | } |
| 4833 | x.VendorExtension = append(x.VendorExtension, pair) |
| 4834 | } |
| 4835 | } |
| 4836 | } |
| 4837 | } |
| 4838 | return x, compiler.NewErrorGroupOrNil(errors) |
| 4839 | } |
| 4840 | |
| 4841 | // NewSchema creates an object of type Schema if possible, returning an error if not. |
| 4842 | func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { |
| 4843 | errors := make([]error, 0) |
| 4844 | x := &Schema{} |
| 4845 | m, ok := compiler.UnpackMap(in) |
| 4846 | if !ok { |
| 4847 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 4848 | errors = append(errors, compiler.NewError(context, message)) |
| 4849 | } else { |
| 4850 | allowedKeys := []string{"$ref", "additionalProperties", "allOf", "default", "description", "discriminator", "enum", "example", "exclusiveMaximum", "exclusiveMinimum", "externalDocs", "format", "items", "maxItems", "maxLength", "maxProperties", "maximum", "minItems", "minLength", "minProperties", "minimum", "multipleOf", "pattern", "properties", "readOnly", "required", "title", "type", "uniqueItems", "xml"} |
| 4851 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 4852 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 4853 | if len(invalidKeys) > 0 { |
| 4854 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 4855 | errors = append(errors, compiler.NewError(context, message)) |
| 4856 | } |
| 4857 | // string _ref = 1; |
| 4858 | v1 := compiler.MapValueForKey(m, "$ref") |
| 4859 | if v1 != nil { |
| 4860 | x.XRef, ok = v1.(string) |
| 4861 | if !ok { |
| 4862 | message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) |
| 4863 | errors = append(errors, compiler.NewError(context, message)) |
| 4864 | } |
| 4865 | } |
| 4866 | // string format = 2; |
| 4867 | v2 := compiler.MapValueForKey(m, "format") |
| 4868 | if v2 != nil { |
| 4869 | x.Format, ok = v2.(string) |
| 4870 | if !ok { |
| 4871 | message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) |
| 4872 | errors = append(errors, compiler.NewError(context, message)) |
| 4873 | } |
| 4874 | } |
| 4875 | // string title = 3; |
| 4876 | v3 := compiler.MapValueForKey(m, "title") |
| 4877 | if v3 != nil { |
| 4878 | x.Title, ok = v3.(string) |
| 4879 | if !ok { |
| 4880 | message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v3, v3) |
| 4881 | errors = append(errors, compiler.NewError(context, message)) |
| 4882 | } |
| 4883 | } |
| 4884 | // string description = 4; |
| 4885 | v4 := compiler.MapValueForKey(m, "description") |
| 4886 | if v4 != nil { |
| 4887 | x.Description, ok = v4.(string) |
| 4888 | if !ok { |
| 4889 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) |
| 4890 | errors = append(errors, compiler.NewError(context, message)) |
| 4891 | } |
| 4892 | } |
| 4893 | // Any default = 5; |
| 4894 | v5 := compiler.MapValueForKey(m, "default") |
| 4895 | if v5 != nil { |
| 4896 | var err error |
| 4897 | x.Default, err = NewAny(v5, compiler.NewContext("default", context)) |
| 4898 | if err != nil { |
| 4899 | errors = append(errors, err) |
| 4900 | } |
| 4901 | } |
| 4902 | // float multiple_of = 6; |
| 4903 | v6 := compiler.MapValueForKey(m, "multipleOf") |
| 4904 | if v6 != nil { |
| 4905 | switch v6 := v6.(type) { |
| 4906 | case float64: |
| 4907 | x.MultipleOf = v6 |
| 4908 | case float32: |
| 4909 | x.MultipleOf = float64(v6) |
| 4910 | case uint64: |
| 4911 | x.MultipleOf = float64(v6) |
| 4912 | case uint32: |
| 4913 | x.MultipleOf = float64(v6) |
| 4914 | case int64: |
| 4915 | x.MultipleOf = float64(v6) |
| 4916 | case int32: |
| 4917 | x.MultipleOf = float64(v6) |
| 4918 | case int: |
| 4919 | x.MultipleOf = float64(v6) |
| 4920 | default: |
| 4921 | message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v6, v6) |
| 4922 | errors = append(errors, compiler.NewError(context, message)) |
| 4923 | } |
| 4924 | } |
| 4925 | // float maximum = 7; |
| 4926 | v7 := compiler.MapValueForKey(m, "maximum") |
| 4927 | if v7 != nil { |
| 4928 | switch v7 := v7.(type) { |
| 4929 | case float64: |
| 4930 | x.Maximum = v7 |
| 4931 | case float32: |
| 4932 | x.Maximum = float64(v7) |
| 4933 | case uint64: |
| 4934 | x.Maximum = float64(v7) |
| 4935 | case uint32: |
| 4936 | x.Maximum = float64(v7) |
| 4937 | case int64: |
| 4938 | x.Maximum = float64(v7) |
| 4939 | case int32: |
| 4940 | x.Maximum = float64(v7) |
| 4941 | case int: |
| 4942 | x.Maximum = float64(v7) |
| 4943 | default: |
| 4944 | message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v7, v7) |
| 4945 | errors = append(errors, compiler.NewError(context, message)) |
| 4946 | } |
| 4947 | } |
| 4948 | // bool exclusive_maximum = 8; |
| 4949 | v8 := compiler.MapValueForKey(m, "exclusiveMaximum") |
| 4950 | if v8 != nil { |
| 4951 | x.ExclusiveMaximum, ok = v8.(bool) |
| 4952 | if !ok { |
| 4953 | message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v8, v8) |
| 4954 | errors = append(errors, compiler.NewError(context, message)) |
| 4955 | } |
| 4956 | } |
| 4957 | // float minimum = 9; |
| 4958 | v9 := compiler.MapValueForKey(m, "minimum") |
| 4959 | if v9 != nil { |
| 4960 | switch v9 := v9.(type) { |
| 4961 | case float64: |
| 4962 | x.Minimum = v9 |
| 4963 | case float32: |
| 4964 | x.Minimum = float64(v9) |
| 4965 | case uint64: |
| 4966 | x.Minimum = float64(v9) |
| 4967 | case uint32: |
| 4968 | x.Minimum = float64(v9) |
| 4969 | case int64: |
| 4970 | x.Minimum = float64(v9) |
| 4971 | case int32: |
| 4972 | x.Minimum = float64(v9) |
| 4973 | case int: |
| 4974 | x.Minimum = float64(v9) |
| 4975 | default: |
| 4976 | message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v9, v9) |
| 4977 | errors = append(errors, compiler.NewError(context, message)) |
| 4978 | } |
| 4979 | } |
| 4980 | // bool exclusive_minimum = 10; |
| 4981 | v10 := compiler.MapValueForKey(m, "exclusiveMinimum") |
| 4982 | if v10 != nil { |
| 4983 | x.ExclusiveMinimum, ok = v10.(bool) |
| 4984 | if !ok { |
| 4985 | message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v10, v10) |
| 4986 | errors = append(errors, compiler.NewError(context, message)) |
| 4987 | } |
| 4988 | } |
| 4989 | // int64 max_length = 11; |
| 4990 | v11 := compiler.MapValueForKey(m, "maxLength") |
| 4991 | if v11 != nil { |
| 4992 | t, ok := v11.(int) |
| 4993 | if ok { |
| 4994 | x.MaxLength = int64(t) |
| 4995 | } else { |
| 4996 | message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v11, v11) |
| 4997 | errors = append(errors, compiler.NewError(context, message)) |
| 4998 | } |
| 4999 | } |
| 5000 | // int64 min_length = 12; |
| 5001 | v12 := compiler.MapValueForKey(m, "minLength") |
| 5002 | if v12 != nil { |
| 5003 | t, ok := v12.(int) |
| 5004 | if ok { |
| 5005 | x.MinLength = int64(t) |
| 5006 | } else { |
| 5007 | message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v12, v12) |
| 5008 | errors = append(errors, compiler.NewError(context, message)) |
| 5009 | } |
| 5010 | } |
| 5011 | // string pattern = 13; |
| 5012 | v13 := compiler.MapValueForKey(m, "pattern") |
| 5013 | if v13 != nil { |
| 5014 | x.Pattern, ok = v13.(string) |
| 5015 | if !ok { |
| 5016 | message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v13, v13) |
| 5017 | errors = append(errors, compiler.NewError(context, message)) |
| 5018 | } |
| 5019 | } |
| 5020 | // int64 max_items = 14; |
| 5021 | v14 := compiler.MapValueForKey(m, "maxItems") |
| 5022 | if v14 != nil { |
| 5023 | t, ok := v14.(int) |
| 5024 | if ok { |
| 5025 | x.MaxItems = int64(t) |
| 5026 | } else { |
| 5027 | message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v14, v14) |
| 5028 | errors = append(errors, compiler.NewError(context, message)) |
| 5029 | } |
| 5030 | } |
| 5031 | // int64 min_items = 15; |
| 5032 | v15 := compiler.MapValueForKey(m, "minItems") |
| 5033 | if v15 != nil { |
| 5034 | t, ok := v15.(int) |
| 5035 | if ok { |
| 5036 | x.MinItems = int64(t) |
| 5037 | } else { |
| 5038 | message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v15, v15) |
| 5039 | errors = append(errors, compiler.NewError(context, message)) |
| 5040 | } |
| 5041 | } |
| 5042 | // bool unique_items = 16; |
| 5043 | v16 := compiler.MapValueForKey(m, "uniqueItems") |
| 5044 | if v16 != nil { |
| 5045 | x.UniqueItems, ok = v16.(bool) |
| 5046 | if !ok { |
| 5047 | message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v16, v16) |
| 5048 | errors = append(errors, compiler.NewError(context, message)) |
| 5049 | } |
| 5050 | } |
| 5051 | // int64 max_properties = 17; |
| 5052 | v17 := compiler.MapValueForKey(m, "maxProperties") |
| 5053 | if v17 != nil { |
| 5054 | t, ok := v17.(int) |
| 5055 | if ok { |
| 5056 | x.MaxProperties = int64(t) |
| 5057 | } else { |
| 5058 | message := fmt.Sprintf("has unexpected value for maxProperties: %+v (%T)", v17, v17) |
| 5059 | errors = append(errors, compiler.NewError(context, message)) |
| 5060 | } |
| 5061 | } |
| 5062 | // int64 min_properties = 18; |
| 5063 | v18 := compiler.MapValueForKey(m, "minProperties") |
| 5064 | if v18 != nil { |
| 5065 | t, ok := v18.(int) |
| 5066 | if ok { |
| 5067 | x.MinProperties = int64(t) |
| 5068 | } else { |
| 5069 | message := fmt.Sprintf("has unexpected value for minProperties: %+v (%T)", v18, v18) |
| 5070 | errors = append(errors, compiler.NewError(context, message)) |
| 5071 | } |
| 5072 | } |
| 5073 | // repeated string required = 19; |
| 5074 | v19 := compiler.MapValueForKey(m, "required") |
| 5075 | if v19 != nil { |
| 5076 | v, ok := v19.([]interface{}) |
| 5077 | if ok { |
| 5078 | x.Required = compiler.ConvertInterfaceArrayToStringArray(v) |
| 5079 | } else { |
| 5080 | message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v19, v19) |
| 5081 | errors = append(errors, compiler.NewError(context, message)) |
| 5082 | } |
| 5083 | } |
| 5084 | // repeated Any enum = 20; |
| 5085 | v20 := compiler.MapValueForKey(m, "enum") |
| 5086 | if v20 != nil { |
| 5087 | // repeated Any |
| 5088 | x.Enum = make([]*Any, 0) |
| 5089 | a, ok := v20.([]interface{}) |
| 5090 | if ok { |
| 5091 | for _, item := range a { |
| 5092 | y, err := NewAny(item, compiler.NewContext("enum", context)) |
| 5093 | if err != nil { |
| 5094 | errors = append(errors, err) |
| 5095 | } |
| 5096 | x.Enum = append(x.Enum, y) |
| 5097 | } |
| 5098 | } |
| 5099 | } |
| 5100 | // AdditionalPropertiesItem additional_properties = 21; |
| 5101 | v21 := compiler.MapValueForKey(m, "additionalProperties") |
| 5102 | if v21 != nil { |
| 5103 | var err error |
| 5104 | x.AdditionalProperties, err = NewAdditionalPropertiesItem(v21, compiler.NewContext("additionalProperties", context)) |
| 5105 | if err != nil { |
| 5106 | errors = append(errors, err) |
| 5107 | } |
| 5108 | } |
| 5109 | // TypeItem type = 22; |
| 5110 | v22 := compiler.MapValueForKey(m, "type") |
| 5111 | if v22 != nil { |
| 5112 | var err error |
| 5113 | x.Type, err = NewTypeItem(v22, compiler.NewContext("type", context)) |
| 5114 | if err != nil { |
| 5115 | errors = append(errors, err) |
| 5116 | } |
| 5117 | } |
| 5118 | // ItemsItem items = 23; |
| 5119 | v23 := compiler.MapValueForKey(m, "items") |
| 5120 | if v23 != nil { |
| 5121 | var err error |
| 5122 | x.Items, err = NewItemsItem(v23, compiler.NewContext("items", context)) |
| 5123 | if err != nil { |
| 5124 | errors = append(errors, err) |
| 5125 | } |
| 5126 | } |
| 5127 | // repeated Schema all_of = 24; |
| 5128 | v24 := compiler.MapValueForKey(m, "allOf") |
| 5129 | if v24 != nil { |
| 5130 | // repeated Schema |
| 5131 | x.AllOf = make([]*Schema, 0) |
| 5132 | a, ok := v24.([]interface{}) |
| 5133 | if ok { |
| 5134 | for _, item := range a { |
| 5135 | y, err := NewSchema(item, compiler.NewContext("allOf", context)) |
| 5136 | if err != nil { |
| 5137 | errors = append(errors, err) |
| 5138 | } |
| 5139 | x.AllOf = append(x.AllOf, y) |
| 5140 | } |
| 5141 | } |
| 5142 | } |
| 5143 | // Properties properties = 25; |
| 5144 | v25 := compiler.MapValueForKey(m, "properties") |
| 5145 | if v25 != nil { |
| 5146 | var err error |
| 5147 | x.Properties, err = NewProperties(v25, compiler.NewContext("properties", context)) |
| 5148 | if err != nil { |
| 5149 | errors = append(errors, err) |
| 5150 | } |
| 5151 | } |
| 5152 | // string discriminator = 26; |
| 5153 | v26 := compiler.MapValueForKey(m, "discriminator") |
| 5154 | if v26 != nil { |
| 5155 | x.Discriminator, ok = v26.(string) |
| 5156 | if !ok { |
| 5157 | message := fmt.Sprintf("has unexpected value for discriminator: %+v (%T)", v26, v26) |
| 5158 | errors = append(errors, compiler.NewError(context, message)) |
| 5159 | } |
| 5160 | } |
| 5161 | // bool read_only = 27; |
| 5162 | v27 := compiler.MapValueForKey(m, "readOnly") |
| 5163 | if v27 != nil { |
| 5164 | x.ReadOnly, ok = v27.(bool) |
| 5165 | if !ok { |
| 5166 | message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v27, v27) |
| 5167 | errors = append(errors, compiler.NewError(context, message)) |
| 5168 | } |
| 5169 | } |
| 5170 | // Xml xml = 28; |
| 5171 | v28 := compiler.MapValueForKey(m, "xml") |
| 5172 | if v28 != nil { |
| 5173 | var err error |
| 5174 | x.Xml, err = NewXml(v28, compiler.NewContext("xml", context)) |
| 5175 | if err != nil { |
| 5176 | errors = append(errors, err) |
| 5177 | } |
| 5178 | } |
| 5179 | // ExternalDocs external_docs = 29; |
| 5180 | v29 := compiler.MapValueForKey(m, "externalDocs") |
| 5181 | if v29 != nil { |
| 5182 | var err error |
| 5183 | x.ExternalDocs, err = NewExternalDocs(v29, compiler.NewContext("externalDocs", context)) |
| 5184 | if err != nil { |
| 5185 | errors = append(errors, err) |
| 5186 | } |
| 5187 | } |
| 5188 | // Any example = 30; |
| 5189 | v30 := compiler.MapValueForKey(m, "example") |
| 5190 | if v30 != nil { |
| 5191 | var err error |
| 5192 | x.Example, err = NewAny(v30, compiler.NewContext("example", context)) |
| 5193 | if err != nil { |
| 5194 | errors = append(errors, err) |
| 5195 | } |
| 5196 | } |
| 5197 | // repeated NamedAny vendor_extension = 31; |
| 5198 | // MAP: Any ^x- |
| 5199 | x.VendorExtension = make([]*NamedAny, 0) |
| 5200 | for _, item := range m { |
| 5201 | k, ok := compiler.StringValue(item.Key) |
| 5202 | if ok { |
| 5203 | v := item.Value |
| 5204 | if strings.HasPrefix(k, "x-") { |
| 5205 | pair := &NamedAny{} |
| 5206 | pair.Name = k |
| 5207 | result := &Any{} |
| 5208 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 5209 | if handled { |
| 5210 | if err != nil { |
| 5211 | errors = append(errors, err) |
| 5212 | } else { |
| 5213 | bytes, _ := yaml.Marshal(v) |
| 5214 | result.Yaml = string(bytes) |
| 5215 | result.Value = resultFromExt |
| 5216 | pair.Value = result |
| 5217 | } |
| 5218 | } else { |
| 5219 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 5220 | if err != nil { |
| 5221 | errors = append(errors, err) |
| 5222 | } |
| 5223 | } |
| 5224 | x.VendorExtension = append(x.VendorExtension, pair) |
| 5225 | } |
| 5226 | } |
| 5227 | } |
| 5228 | } |
| 5229 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5230 | } |
| 5231 | |
| 5232 | // NewSchemaItem creates an object of type SchemaItem if possible, returning an error if not. |
| 5233 | func NewSchemaItem(in interface{}, context *compiler.Context) (*SchemaItem, error) { |
| 5234 | errors := make([]error, 0) |
| 5235 | x := &SchemaItem{} |
| 5236 | matched := false |
| 5237 | // Schema schema = 1; |
| 5238 | { |
| 5239 | m, ok := compiler.UnpackMap(in) |
| 5240 | if ok { |
| 5241 | // errors might be ok here, they mean we just don't have the right subtype |
| 5242 | t, matchingError := NewSchema(m, compiler.NewContext("schema", context)) |
| 5243 | if matchingError == nil { |
| 5244 | x.Oneof = &SchemaItem_Schema{Schema: t} |
| 5245 | matched = true |
| 5246 | } else { |
| 5247 | errors = append(errors, matchingError) |
| 5248 | } |
| 5249 | } |
| 5250 | } |
| 5251 | // FileSchema file_schema = 2; |
| 5252 | { |
| 5253 | m, ok := compiler.UnpackMap(in) |
| 5254 | if ok { |
| 5255 | // errors might be ok here, they mean we just don't have the right subtype |
| 5256 | t, matchingError := NewFileSchema(m, compiler.NewContext("fileSchema", context)) |
| 5257 | if matchingError == nil { |
| 5258 | x.Oneof = &SchemaItem_FileSchema{FileSchema: t} |
| 5259 | matched = true |
| 5260 | } else { |
| 5261 | errors = append(errors, matchingError) |
| 5262 | } |
| 5263 | } |
| 5264 | } |
| 5265 | if matched { |
| 5266 | // since the oneof matched one of its possibilities, discard any matching errors |
| 5267 | errors = make([]error, 0) |
| 5268 | } |
| 5269 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5270 | } |
| 5271 | |
| 5272 | // NewSecurityDefinitions creates an object of type SecurityDefinitions if possible, returning an error if not. |
| 5273 | func NewSecurityDefinitions(in interface{}, context *compiler.Context) (*SecurityDefinitions, error) { |
| 5274 | errors := make([]error, 0) |
| 5275 | x := &SecurityDefinitions{} |
| 5276 | m, ok := compiler.UnpackMap(in) |
| 5277 | if !ok { |
| 5278 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 5279 | errors = append(errors, compiler.NewError(context, message)) |
| 5280 | } else { |
| 5281 | // repeated NamedSecurityDefinitionsItem additional_properties = 1; |
| 5282 | // MAP: SecurityDefinitionsItem |
| 5283 | x.AdditionalProperties = make([]*NamedSecurityDefinitionsItem, 0) |
| 5284 | for _, item := range m { |
| 5285 | k, ok := compiler.StringValue(item.Key) |
| 5286 | if ok { |
| 5287 | v := item.Value |
| 5288 | pair := &NamedSecurityDefinitionsItem{} |
| 5289 | pair.Name = k |
| 5290 | var err error |
| 5291 | pair.Value, err = NewSecurityDefinitionsItem(v, compiler.NewContext(k, context)) |
| 5292 | if err != nil { |
| 5293 | errors = append(errors, err) |
| 5294 | } |
| 5295 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 5296 | } |
| 5297 | } |
| 5298 | } |
| 5299 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5300 | } |
| 5301 | |
| 5302 | // NewSecurityDefinitionsItem creates an object of type SecurityDefinitionsItem if possible, returning an error if not. |
| 5303 | func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*SecurityDefinitionsItem, error) { |
| 5304 | errors := make([]error, 0) |
| 5305 | x := &SecurityDefinitionsItem{} |
| 5306 | matched := false |
| 5307 | // BasicAuthenticationSecurity basic_authentication_security = 1; |
| 5308 | { |
| 5309 | m, ok := compiler.UnpackMap(in) |
| 5310 | if ok { |
| 5311 | // errors might be ok here, they mean we just don't have the right subtype |
| 5312 | t, matchingError := NewBasicAuthenticationSecurity(m, compiler.NewContext("basicAuthenticationSecurity", context)) |
| 5313 | if matchingError == nil { |
| 5314 | x.Oneof = &SecurityDefinitionsItem_BasicAuthenticationSecurity{BasicAuthenticationSecurity: t} |
| 5315 | matched = true |
| 5316 | } else { |
| 5317 | errors = append(errors, matchingError) |
| 5318 | } |
| 5319 | } |
| 5320 | } |
| 5321 | // ApiKeySecurity api_key_security = 2; |
| 5322 | { |
| 5323 | m, ok := compiler.UnpackMap(in) |
| 5324 | if ok { |
| 5325 | // errors might be ok here, they mean we just don't have the right subtype |
| 5326 | t, matchingError := NewApiKeySecurity(m, compiler.NewContext("apiKeySecurity", context)) |
| 5327 | if matchingError == nil { |
| 5328 | x.Oneof = &SecurityDefinitionsItem_ApiKeySecurity{ApiKeySecurity: t} |
| 5329 | matched = true |
| 5330 | } else { |
| 5331 | errors = append(errors, matchingError) |
| 5332 | } |
| 5333 | } |
| 5334 | } |
| 5335 | // Oauth2ImplicitSecurity oauth2_implicit_security = 3; |
| 5336 | { |
| 5337 | m, ok := compiler.UnpackMap(in) |
| 5338 | if ok { |
| 5339 | // errors might be ok here, they mean we just don't have the right subtype |
| 5340 | t, matchingError := NewOauth2ImplicitSecurity(m, compiler.NewContext("oauth2ImplicitSecurity", context)) |
| 5341 | if matchingError == nil { |
| 5342 | x.Oneof = &SecurityDefinitionsItem_Oauth2ImplicitSecurity{Oauth2ImplicitSecurity: t} |
| 5343 | matched = true |
| 5344 | } else { |
| 5345 | errors = append(errors, matchingError) |
| 5346 | } |
| 5347 | } |
| 5348 | } |
| 5349 | // Oauth2PasswordSecurity oauth2_password_security = 4; |
| 5350 | { |
| 5351 | m, ok := compiler.UnpackMap(in) |
| 5352 | if ok { |
| 5353 | // errors might be ok here, they mean we just don't have the right subtype |
| 5354 | t, matchingError := NewOauth2PasswordSecurity(m, compiler.NewContext("oauth2PasswordSecurity", context)) |
| 5355 | if matchingError == nil { |
| 5356 | x.Oneof = &SecurityDefinitionsItem_Oauth2PasswordSecurity{Oauth2PasswordSecurity: t} |
| 5357 | matched = true |
| 5358 | } else { |
| 5359 | errors = append(errors, matchingError) |
| 5360 | } |
| 5361 | } |
| 5362 | } |
| 5363 | // Oauth2ApplicationSecurity oauth2_application_security = 5; |
| 5364 | { |
| 5365 | m, ok := compiler.UnpackMap(in) |
| 5366 | if ok { |
| 5367 | // errors might be ok here, they mean we just don't have the right subtype |
| 5368 | t, matchingError := NewOauth2ApplicationSecurity(m, compiler.NewContext("oauth2ApplicationSecurity", context)) |
| 5369 | if matchingError == nil { |
| 5370 | x.Oneof = &SecurityDefinitionsItem_Oauth2ApplicationSecurity{Oauth2ApplicationSecurity: t} |
| 5371 | matched = true |
| 5372 | } else { |
| 5373 | errors = append(errors, matchingError) |
| 5374 | } |
| 5375 | } |
| 5376 | } |
| 5377 | // Oauth2AccessCodeSecurity oauth2_access_code_security = 6; |
| 5378 | { |
| 5379 | m, ok := compiler.UnpackMap(in) |
| 5380 | if ok { |
| 5381 | // errors might be ok here, they mean we just don't have the right subtype |
| 5382 | t, matchingError := NewOauth2AccessCodeSecurity(m, compiler.NewContext("oauth2AccessCodeSecurity", context)) |
| 5383 | if matchingError == nil { |
| 5384 | x.Oneof = &SecurityDefinitionsItem_Oauth2AccessCodeSecurity{Oauth2AccessCodeSecurity: t} |
| 5385 | matched = true |
| 5386 | } else { |
| 5387 | errors = append(errors, matchingError) |
| 5388 | } |
| 5389 | } |
| 5390 | } |
| 5391 | if matched { |
| 5392 | // since the oneof matched one of its possibilities, discard any matching errors |
| 5393 | errors = make([]error, 0) |
| 5394 | } |
| 5395 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5396 | } |
| 5397 | |
| 5398 | // NewSecurityRequirement creates an object of type SecurityRequirement if possible, returning an error if not. |
| 5399 | func NewSecurityRequirement(in interface{}, context *compiler.Context) (*SecurityRequirement, error) { |
| 5400 | errors := make([]error, 0) |
| 5401 | x := &SecurityRequirement{} |
| 5402 | m, ok := compiler.UnpackMap(in) |
| 5403 | if !ok { |
| 5404 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 5405 | errors = append(errors, compiler.NewError(context, message)) |
| 5406 | } else { |
| 5407 | // repeated NamedStringArray additional_properties = 1; |
| 5408 | // MAP: StringArray |
| 5409 | x.AdditionalProperties = make([]*NamedStringArray, 0) |
| 5410 | for _, item := range m { |
| 5411 | k, ok := compiler.StringValue(item.Key) |
| 5412 | if ok { |
| 5413 | v := item.Value |
| 5414 | pair := &NamedStringArray{} |
| 5415 | pair.Name = k |
| 5416 | var err error |
| 5417 | pair.Value, err = NewStringArray(v, compiler.NewContext(k, context)) |
| 5418 | if err != nil { |
| 5419 | errors = append(errors, err) |
| 5420 | } |
| 5421 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 5422 | } |
| 5423 | } |
| 5424 | } |
| 5425 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5426 | } |
| 5427 | |
| 5428 | // NewStringArray creates an object of type StringArray if possible, returning an error if not. |
| 5429 | func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, error) { |
| 5430 | errors := make([]error, 0) |
| 5431 | x := &StringArray{} |
| 5432 | a, ok := in.([]interface{}) |
| 5433 | if !ok { |
| 5434 | message := fmt.Sprintf("has unexpected value for StringArray: %+v (%T)", in, in) |
| 5435 | errors = append(errors, compiler.NewError(context, message)) |
| 5436 | } else { |
| 5437 | x.Value = make([]string, 0) |
| 5438 | for _, s := range a { |
| 5439 | x.Value = append(x.Value, s.(string)) |
| 5440 | } |
| 5441 | } |
| 5442 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5443 | } |
| 5444 | |
| 5445 | // NewTag creates an object of type Tag if possible, returning an error if not. |
| 5446 | func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { |
| 5447 | errors := make([]error, 0) |
| 5448 | x := &Tag{} |
| 5449 | m, ok := compiler.UnpackMap(in) |
| 5450 | if !ok { |
| 5451 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 5452 | errors = append(errors, compiler.NewError(context, message)) |
| 5453 | } else { |
| 5454 | requiredKeys := []string{"name"} |
| 5455 | missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 5456 | if len(missingKeys) > 0 { |
| 5457 | message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 5458 | errors = append(errors, compiler.NewError(context, message)) |
| 5459 | } |
| 5460 | allowedKeys := []string{"description", "externalDocs", "name"} |
| 5461 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 5462 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 5463 | if len(invalidKeys) > 0 { |
| 5464 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 5465 | errors = append(errors, compiler.NewError(context, message)) |
| 5466 | } |
| 5467 | // string name = 1; |
| 5468 | v1 := compiler.MapValueForKey(m, "name") |
| 5469 | if v1 != nil { |
| 5470 | x.Name, ok = v1.(string) |
| 5471 | if !ok { |
| 5472 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 5473 | errors = append(errors, compiler.NewError(context, message)) |
| 5474 | } |
| 5475 | } |
| 5476 | // string description = 2; |
| 5477 | v2 := compiler.MapValueForKey(m, "description") |
| 5478 | if v2 != nil { |
| 5479 | x.Description, ok = v2.(string) |
| 5480 | if !ok { |
| 5481 | message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) |
| 5482 | errors = append(errors, compiler.NewError(context, message)) |
| 5483 | } |
| 5484 | } |
| 5485 | // ExternalDocs external_docs = 3; |
| 5486 | v3 := compiler.MapValueForKey(m, "externalDocs") |
| 5487 | if v3 != nil { |
| 5488 | var err error |
| 5489 | x.ExternalDocs, err = NewExternalDocs(v3, compiler.NewContext("externalDocs", context)) |
| 5490 | if err != nil { |
| 5491 | errors = append(errors, err) |
| 5492 | } |
| 5493 | } |
| 5494 | // repeated NamedAny vendor_extension = 4; |
| 5495 | // MAP: Any ^x- |
| 5496 | x.VendorExtension = make([]*NamedAny, 0) |
| 5497 | for _, item := range m { |
| 5498 | k, ok := compiler.StringValue(item.Key) |
| 5499 | if ok { |
| 5500 | v := item.Value |
| 5501 | if strings.HasPrefix(k, "x-") { |
| 5502 | pair := &NamedAny{} |
| 5503 | pair.Name = k |
| 5504 | result := &Any{} |
| 5505 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 5506 | if handled { |
| 5507 | if err != nil { |
| 5508 | errors = append(errors, err) |
| 5509 | } else { |
| 5510 | bytes, _ := yaml.Marshal(v) |
| 5511 | result.Yaml = string(bytes) |
| 5512 | result.Value = resultFromExt |
| 5513 | pair.Value = result |
| 5514 | } |
| 5515 | } else { |
| 5516 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 5517 | if err != nil { |
| 5518 | errors = append(errors, err) |
| 5519 | } |
| 5520 | } |
| 5521 | x.VendorExtension = append(x.VendorExtension, pair) |
| 5522 | } |
| 5523 | } |
| 5524 | } |
| 5525 | } |
| 5526 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5527 | } |
| 5528 | |
| 5529 | // NewTypeItem creates an object of type TypeItem if possible, returning an error if not. |
| 5530 | func NewTypeItem(in interface{}, context *compiler.Context) (*TypeItem, error) { |
| 5531 | errors := make([]error, 0) |
| 5532 | x := &TypeItem{} |
| 5533 | switch in := in.(type) { |
| 5534 | case string: |
| 5535 | x.Value = make([]string, 0) |
| 5536 | x.Value = append(x.Value, in) |
| 5537 | case []interface{}: |
| 5538 | x.Value = make([]string, 0) |
| 5539 | for _, v := range in { |
| 5540 | value, ok := v.(string) |
| 5541 | if ok { |
| 5542 | x.Value = append(x.Value, value) |
| 5543 | } else { |
| 5544 | message := fmt.Sprintf("has unexpected value for string array element: %+v (%T)", value, value) |
| 5545 | errors = append(errors, compiler.NewError(context, message)) |
| 5546 | } |
| 5547 | } |
| 5548 | default: |
| 5549 | message := fmt.Sprintf("has unexpected value for string array: %+v (%T)", in, in) |
| 5550 | errors = append(errors, compiler.NewError(context, message)) |
| 5551 | } |
| 5552 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5553 | } |
| 5554 | |
| 5555 | // NewVendorExtension creates an object of type VendorExtension if possible, returning an error if not. |
| 5556 | func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExtension, error) { |
| 5557 | errors := make([]error, 0) |
| 5558 | x := &VendorExtension{} |
| 5559 | m, ok := compiler.UnpackMap(in) |
| 5560 | if !ok { |
| 5561 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 5562 | errors = append(errors, compiler.NewError(context, message)) |
| 5563 | } else { |
| 5564 | // repeated NamedAny additional_properties = 1; |
| 5565 | // MAP: Any |
| 5566 | x.AdditionalProperties = make([]*NamedAny, 0) |
| 5567 | for _, item := range m { |
| 5568 | k, ok := compiler.StringValue(item.Key) |
| 5569 | if ok { |
| 5570 | v := item.Value |
| 5571 | pair := &NamedAny{} |
| 5572 | pair.Name = k |
| 5573 | result := &Any{} |
| 5574 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 5575 | if handled { |
| 5576 | if err != nil { |
| 5577 | errors = append(errors, err) |
| 5578 | } else { |
| 5579 | bytes, _ := yaml.Marshal(v) |
| 5580 | result.Yaml = string(bytes) |
| 5581 | result.Value = resultFromExt |
| 5582 | pair.Value = result |
| 5583 | } |
| 5584 | } else { |
| 5585 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 5586 | if err != nil { |
| 5587 | errors = append(errors, err) |
| 5588 | } |
| 5589 | } |
| 5590 | x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 5591 | } |
| 5592 | } |
| 5593 | } |
| 5594 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5595 | } |
| 5596 | |
| 5597 | // NewXml creates an object of type Xml if possible, returning an error if not. |
| 5598 | func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { |
| 5599 | errors := make([]error, 0) |
| 5600 | x := &Xml{} |
| 5601 | m, ok := compiler.UnpackMap(in) |
| 5602 | if !ok { |
| 5603 | message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 5604 | errors = append(errors, compiler.NewError(context, message)) |
| 5605 | } else { |
| 5606 | allowedKeys := []string{"attribute", "name", "namespace", "prefix", "wrapped"} |
| 5607 | allowedPatterns := []*regexp.Regexp{pattern0} |
| 5608 | invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 5609 | if len(invalidKeys) > 0 { |
| 5610 | message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 5611 | errors = append(errors, compiler.NewError(context, message)) |
| 5612 | } |
| 5613 | // string name = 1; |
| 5614 | v1 := compiler.MapValueForKey(m, "name") |
| 5615 | if v1 != nil { |
| 5616 | x.Name, ok = v1.(string) |
| 5617 | if !ok { |
| 5618 | message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) |
| 5619 | errors = append(errors, compiler.NewError(context, message)) |
| 5620 | } |
| 5621 | } |
| 5622 | // string namespace = 2; |
| 5623 | v2 := compiler.MapValueForKey(m, "namespace") |
| 5624 | if v2 != nil { |
| 5625 | x.Namespace, ok = v2.(string) |
| 5626 | if !ok { |
| 5627 | message := fmt.Sprintf("has unexpected value for namespace: %+v (%T)", v2, v2) |
| 5628 | errors = append(errors, compiler.NewError(context, message)) |
| 5629 | } |
| 5630 | } |
| 5631 | // string prefix = 3; |
| 5632 | v3 := compiler.MapValueForKey(m, "prefix") |
| 5633 | if v3 != nil { |
| 5634 | x.Prefix, ok = v3.(string) |
| 5635 | if !ok { |
| 5636 | message := fmt.Sprintf("has unexpected value for prefix: %+v (%T)", v3, v3) |
| 5637 | errors = append(errors, compiler.NewError(context, message)) |
| 5638 | } |
| 5639 | } |
| 5640 | // bool attribute = 4; |
| 5641 | v4 := compiler.MapValueForKey(m, "attribute") |
| 5642 | if v4 != nil { |
| 5643 | x.Attribute, ok = v4.(bool) |
| 5644 | if !ok { |
| 5645 | message := fmt.Sprintf("has unexpected value for attribute: %+v (%T)", v4, v4) |
| 5646 | errors = append(errors, compiler.NewError(context, message)) |
| 5647 | } |
| 5648 | } |
| 5649 | // bool wrapped = 5; |
| 5650 | v5 := compiler.MapValueForKey(m, "wrapped") |
| 5651 | if v5 != nil { |
| 5652 | x.Wrapped, ok = v5.(bool) |
| 5653 | if !ok { |
| 5654 | message := fmt.Sprintf("has unexpected value for wrapped: %+v (%T)", v5, v5) |
| 5655 | errors = append(errors, compiler.NewError(context, message)) |
| 5656 | } |
| 5657 | } |
| 5658 | // repeated NamedAny vendor_extension = 6; |
| 5659 | // MAP: Any ^x- |
| 5660 | x.VendorExtension = make([]*NamedAny, 0) |
| 5661 | for _, item := range m { |
| 5662 | k, ok := compiler.StringValue(item.Key) |
| 5663 | if ok { |
| 5664 | v := item.Value |
| 5665 | if strings.HasPrefix(k, "x-") { |
| 5666 | pair := &NamedAny{} |
| 5667 | pair.Name = k |
| 5668 | result := &Any{} |
| 5669 | handled, resultFromExt, err := compiler.HandleExtension(context, v, k) |
| 5670 | if handled { |
| 5671 | if err != nil { |
| 5672 | errors = append(errors, err) |
| 5673 | } else { |
| 5674 | bytes, _ := yaml.Marshal(v) |
| 5675 | result.Yaml = string(bytes) |
| 5676 | result.Value = resultFromExt |
| 5677 | pair.Value = result |
| 5678 | } |
| 5679 | } else { |
| 5680 | pair.Value, err = NewAny(v, compiler.NewContext(k, context)) |
| 5681 | if err != nil { |
| 5682 | errors = append(errors, err) |
| 5683 | } |
| 5684 | } |
| 5685 | x.VendorExtension = append(x.VendorExtension, pair) |
| 5686 | } |
| 5687 | } |
| 5688 | } |
| 5689 | } |
| 5690 | return x, compiler.NewErrorGroupOrNil(errors) |
| 5691 | } |
| 5692 | |
| 5693 | // ResolveReferences resolves references found inside AdditionalPropertiesItem objects. |
| 5694 | func (m *AdditionalPropertiesItem) ResolveReferences(root string) (interface{}, error) { |
| 5695 | errors := make([]error, 0) |
| 5696 | { |
| 5697 | p, ok := m.Oneof.(*AdditionalPropertiesItem_Schema) |
| 5698 | if ok { |
| 5699 | _, err := p.Schema.ResolveReferences(root) |
| 5700 | if err != nil { |
| 5701 | return nil, err |
| 5702 | } |
| 5703 | } |
| 5704 | } |
| 5705 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5706 | } |
| 5707 | |
| 5708 | // ResolveReferences resolves references found inside Any objects. |
| 5709 | func (m *Any) ResolveReferences(root string) (interface{}, error) { |
| 5710 | errors := make([]error, 0) |
| 5711 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5712 | } |
| 5713 | |
| 5714 | // ResolveReferences resolves references found inside ApiKeySecurity objects. |
| 5715 | func (m *ApiKeySecurity) ResolveReferences(root string) (interface{}, error) { |
| 5716 | errors := make([]error, 0) |
| 5717 | for _, item := range m.VendorExtension { |
| 5718 | if item != nil { |
| 5719 | _, err := item.ResolveReferences(root) |
| 5720 | if err != nil { |
| 5721 | errors = append(errors, err) |
| 5722 | } |
| 5723 | } |
| 5724 | } |
| 5725 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5726 | } |
| 5727 | |
| 5728 | // ResolveReferences resolves references found inside BasicAuthenticationSecurity objects. |
| 5729 | func (m *BasicAuthenticationSecurity) ResolveReferences(root string) (interface{}, error) { |
| 5730 | errors := make([]error, 0) |
| 5731 | for _, item := range m.VendorExtension { |
| 5732 | if item != nil { |
| 5733 | _, err := item.ResolveReferences(root) |
| 5734 | if err != nil { |
| 5735 | errors = append(errors, err) |
| 5736 | } |
| 5737 | } |
| 5738 | } |
| 5739 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5740 | } |
| 5741 | |
| 5742 | // ResolveReferences resolves references found inside BodyParameter objects. |
| 5743 | func (m *BodyParameter) ResolveReferences(root string) (interface{}, error) { |
| 5744 | errors := make([]error, 0) |
| 5745 | if m.Schema != nil { |
| 5746 | _, err := m.Schema.ResolveReferences(root) |
| 5747 | if err != nil { |
| 5748 | errors = append(errors, err) |
| 5749 | } |
| 5750 | } |
| 5751 | for _, item := range m.VendorExtension { |
| 5752 | if item != nil { |
| 5753 | _, err := item.ResolveReferences(root) |
| 5754 | if err != nil { |
| 5755 | errors = append(errors, err) |
| 5756 | } |
| 5757 | } |
| 5758 | } |
| 5759 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5760 | } |
| 5761 | |
| 5762 | // ResolveReferences resolves references found inside Contact objects. |
| 5763 | func (m *Contact) ResolveReferences(root string) (interface{}, error) { |
| 5764 | errors := make([]error, 0) |
| 5765 | for _, item := range m.VendorExtension { |
| 5766 | if item != nil { |
| 5767 | _, err := item.ResolveReferences(root) |
| 5768 | if err != nil { |
| 5769 | errors = append(errors, err) |
| 5770 | } |
| 5771 | } |
| 5772 | } |
| 5773 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5774 | } |
| 5775 | |
| 5776 | // ResolveReferences resolves references found inside Default objects. |
| 5777 | func (m *Default) ResolveReferences(root string) (interface{}, error) { |
| 5778 | errors := make([]error, 0) |
| 5779 | for _, item := range m.AdditionalProperties { |
| 5780 | if item != nil { |
| 5781 | _, err := item.ResolveReferences(root) |
| 5782 | if err != nil { |
| 5783 | errors = append(errors, err) |
| 5784 | } |
| 5785 | } |
| 5786 | } |
| 5787 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5788 | } |
| 5789 | |
| 5790 | // ResolveReferences resolves references found inside Definitions objects. |
| 5791 | func (m *Definitions) ResolveReferences(root string) (interface{}, error) { |
| 5792 | errors := make([]error, 0) |
| 5793 | for _, item := range m.AdditionalProperties { |
| 5794 | if item != nil { |
| 5795 | _, err := item.ResolveReferences(root) |
| 5796 | if err != nil { |
| 5797 | errors = append(errors, err) |
| 5798 | } |
| 5799 | } |
| 5800 | } |
| 5801 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5802 | } |
| 5803 | |
| 5804 | // ResolveReferences resolves references found inside Document objects. |
| 5805 | func (m *Document) ResolveReferences(root string) (interface{}, error) { |
| 5806 | errors := make([]error, 0) |
| 5807 | if m.Info != nil { |
| 5808 | _, err := m.Info.ResolveReferences(root) |
| 5809 | if err != nil { |
| 5810 | errors = append(errors, err) |
| 5811 | } |
| 5812 | } |
| 5813 | if m.Paths != nil { |
| 5814 | _, err := m.Paths.ResolveReferences(root) |
| 5815 | if err != nil { |
| 5816 | errors = append(errors, err) |
| 5817 | } |
| 5818 | } |
| 5819 | if m.Definitions != nil { |
| 5820 | _, err := m.Definitions.ResolveReferences(root) |
| 5821 | if err != nil { |
| 5822 | errors = append(errors, err) |
| 5823 | } |
| 5824 | } |
| 5825 | if m.Parameters != nil { |
| 5826 | _, err := m.Parameters.ResolveReferences(root) |
| 5827 | if err != nil { |
| 5828 | errors = append(errors, err) |
| 5829 | } |
| 5830 | } |
| 5831 | if m.Responses != nil { |
| 5832 | _, err := m.Responses.ResolveReferences(root) |
| 5833 | if err != nil { |
| 5834 | errors = append(errors, err) |
| 5835 | } |
| 5836 | } |
| 5837 | for _, item := range m.Security { |
| 5838 | if item != nil { |
| 5839 | _, err := item.ResolveReferences(root) |
| 5840 | if err != nil { |
| 5841 | errors = append(errors, err) |
| 5842 | } |
| 5843 | } |
| 5844 | } |
| 5845 | if m.SecurityDefinitions != nil { |
| 5846 | _, err := m.SecurityDefinitions.ResolveReferences(root) |
| 5847 | if err != nil { |
| 5848 | errors = append(errors, err) |
| 5849 | } |
| 5850 | } |
| 5851 | for _, item := range m.Tags { |
| 5852 | if item != nil { |
| 5853 | _, err := item.ResolveReferences(root) |
| 5854 | if err != nil { |
| 5855 | errors = append(errors, err) |
| 5856 | } |
| 5857 | } |
| 5858 | } |
| 5859 | if m.ExternalDocs != nil { |
| 5860 | _, err := m.ExternalDocs.ResolveReferences(root) |
| 5861 | if err != nil { |
| 5862 | errors = append(errors, err) |
| 5863 | } |
| 5864 | } |
| 5865 | for _, item := range m.VendorExtension { |
| 5866 | if item != nil { |
| 5867 | _, err := item.ResolveReferences(root) |
| 5868 | if err != nil { |
| 5869 | errors = append(errors, err) |
| 5870 | } |
| 5871 | } |
| 5872 | } |
| 5873 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5874 | } |
| 5875 | |
| 5876 | // ResolveReferences resolves references found inside Examples objects. |
| 5877 | func (m *Examples) ResolveReferences(root string) (interface{}, error) { |
| 5878 | errors := make([]error, 0) |
| 5879 | for _, item := range m.AdditionalProperties { |
| 5880 | if item != nil { |
| 5881 | _, err := item.ResolveReferences(root) |
| 5882 | if err != nil { |
| 5883 | errors = append(errors, err) |
| 5884 | } |
| 5885 | } |
| 5886 | } |
| 5887 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5888 | } |
| 5889 | |
| 5890 | // ResolveReferences resolves references found inside ExternalDocs objects. |
| 5891 | func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) { |
| 5892 | errors := make([]error, 0) |
| 5893 | for _, item := range m.VendorExtension { |
| 5894 | if item != nil { |
| 5895 | _, err := item.ResolveReferences(root) |
| 5896 | if err != nil { |
| 5897 | errors = append(errors, err) |
| 5898 | } |
| 5899 | } |
| 5900 | } |
| 5901 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5902 | } |
| 5903 | |
| 5904 | // ResolveReferences resolves references found inside FileSchema objects. |
| 5905 | func (m *FileSchema) ResolveReferences(root string) (interface{}, error) { |
| 5906 | errors := make([]error, 0) |
| 5907 | if m.Default != nil { |
| 5908 | _, err := m.Default.ResolveReferences(root) |
| 5909 | if err != nil { |
| 5910 | errors = append(errors, err) |
| 5911 | } |
| 5912 | } |
| 5913 | if m.ExternalDocs != nil { |
| 5914 | _, err := m.ExternalDocs.ResolveReferences(root) |
| 5915 | if err != nil { |
| 5916 | errors = append(errors, err) |
| 5917 | } |
| 5918 | } |
| 5919 | if m.Example != nil { |
| 5920 | _, err := m.Example.ResolveReferences(root) |
| 5921 | if err != nil { |
| 5922 | errors = append(errors, err) |
| 5923 | } |
| 5924 | } |
| 5925 | for _, item := range m.VendorExtension { |
| 5926 | if item != nil { |
| 5927 | _, err := item.ResolveReferences(root) |
| 5928 | if err != nil { |
| 5929 | errors = append(errors, err) |
| 5930 | } |
| 5931 | } |
| 5932 | } |
| 5933 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5934 | } |
| 5935 | |
| 5936 | // ResolveReferences resolves references found inside FormDataParameterSubSchema objects. |
| 5937 | func (m *FormDataParameterSubSchema) ResolveReferences(root string) (interface{}, error) { |
| 5938 | errors := make([]error, 0) |
| 5939 | if m.Items != nil { |
| 5940 | _, err := m.Items.ResolveReferences(root) |
| 5941 | if err != nil { |
| 5942 | errors = append(errors, err) |
| 5943 | } |
| 5944 | } |
| 5945 | if m.Default != nil { |
| 5946 | _, err := m.Default.ResolveReferences(root) |
| 5947 | if err != nil { |
| 5948 | errors = append(errors, err) |
| 5949 | } |
| 5950 | } |
| 5951 | for _, item := range m.Enum { |
| 5952 | if item != nil { |
| 5953 | _, err := item.ResolveReferences(root) |
| 5954 | if err != nil { |
| 5955 | errors = append(errors, err) |
| 5956 | } |
| 5957 | } |
| 5958 | } |
| 5959 | for _, item := range m.VendorExtension { |
| 5960 | if item != nil { |
| 5961 | _, err := item.ResolveReferences(root) |
| 5962 | if err != nil { |
| 5963 | errors = append(errors, err) |
| 5964 | } |
| 5965 | } |
| 5966 | } |
| 5967 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 5968 | } |
| 5969 | |
| 5970 | // ResolveReferences resolves references found inside Header objects. |
| 5971 | func (m *Header) ResolveReferences(root string) (interface{}, error) { |
| 5972 | errors := make([]error, 0) |
| 5973 | if m.Items != nil { |
| 5974 | _, err := m.Items.ResolveReferences(root) |
| 5975 | if err != nil { |
| 5976 | errors = append(errors, err) |
| 5977 | } |
| 5978 | } |
| 5979 | if m.Default != nil { |
| 5980 | _, err := m.Default.ResolveReferences(root) |
| 5981 | if err != nil { |
| 5982 | errors = append(errors, err) |
| 5983 | } |
| 5984 | } |
| 5985 | for _, item := range m.Enum { |
| 5986 | if item != nil { |
| 5987 | _, err := item.ResolveReferences(root) |
| 5988 | if err != nil { |
| 5989 | errors = append(errors, err) |
| 5990 | } |
| 5991 | } |
| 5992 | } |
| 5993 | for _, item := range m.VendorExtension { |
| 5994 | if item != nil { |
| 5995 | _, err := item.ResolveReferences(root) |
| 5996 | if err != nil { |
| 5997 | errors = append(errors, err) |
| 5998 | } |
| 5999 | } |
| 6000 | } |
| 6001 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6002 | } |
| 6003 | |
| 6004 | // ResolveReferences resolves references found inside HeaderParameterSubSchema objects. |
| 6005 | func (m *HeaderParameterSubSchema) ResolveReferences(root string) (interface{}, error) { |
| 6006 | errors := make([]error, 0) |
| 6007 | if m.Items != nil { |
| 6008 | _, err := m.Items.ResolveReferences(root) |
| 6009 | if err != nil { |
| 6010 | errors = append(errors, err) |
| 6011 | } |
| 6012 | } |
| 6013 | if m.Default != nil { |
| 6014 | _, err := m.Default.ResolveReferences(root) |
| 6015 | if err != nil { |
| 6016 | errors = append(errors, err) |
| 6017 | } |
| 6018 | } |
| 6019 | for _, item := range m.Enum { |
| 6020 | if item != nil { |
| 6021 | _, err := item.ResolveReferences(root) |
| 6022 | if err != nil { |
| 6023 | errors = append(errors, err) |
| 6024 | } |
| 6025 | } |
| 6026 | } |
| 6027 | for _, item := range m.VendorExtension { |
| 6028 | if item != nil { |
| 6029 | _, err := item.ResolveReferences(root) |
| 6030 | if err != nil { |
| 6031 | errors = append(errors, err) |
| 6032 | } |
| 6033 | } |
| 6034 | } |
| 6035 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6036 | } |
| 6037 | |
| 6038 | // ResolveReferences resolves references found inside Headers objects. |
| 6039 | func (m *Headers) ResolveReferences(root string) (interface{}, error) { |
| 6040 | errors := make([]error, 0) |
| 6041 | for _, item := range m.AdditionalProperties { |
| 6042 | if item != nil { |
| 6043 | _, err := item.ResolveReferences(root) |
| 6044 | if err != nil { |
| 6045 | errors = append(errors, err) |
| 6046 | } |
| 6047 | } |
| 6048 | } |
| 6049 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6050 | } |
| 6051 | |
| 6052 | // ResolveReferences resolves references found inside Info objects. |
| 6053 | func (m *Info) ResolveReferences(root string) (interface{}, error) { |
| 6054 | errors := make([]error, 0) |
| 6055 | if m.Contact != nil { |
| 6056 | _, err := m.Contact.ResolveReferences(root) |
| 6057 | if err != nil { |
| 6058 | errors = append(errors, err) |
| 6059 | } |
| 6060 | } |
| 6061 | if m.License != nil { |
| 6062 | _, err := m.License.ResolveReferences(root) |
| 6063 | if err != nil { |
| 6064 | errors = append(errors, err) |
| 6065 | } |
| 6066 | } |
| 6067 | for _, item := range m.VendorExtension { |
| 6068 | if item != nil { |
| 6069 | _, err := item.ResolveReferences(root) |
| 6070 | if err != nil { |
| 6071 | errors = append(errors, err) |
| 6072 | } |
| 6073 | } |
| 6074 | } |
| 6075 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6076 | } |
| 6077 | |
| 6078 | // ResolveReferences resolves references found inside ItemsItem objects. |
| 6079 | func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) { |
| 6080 | errors := make([]error, 0) |
| 6081 | for _, item := range m.Schema { |
| 6082 | if item != nil { |
| 6083 | _, err := item.ResolveReferences(root) |
| 6084 | if err != nil { |
| 6085 | errors = append(errors, err) |
| 6086 | } |
| 6087 | } |
| 6088 | } |
| 6089 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6090 | } |
| 6091 | |
| 6092 | // ResolveReferences resolves references found inside JsonReference objects. |
| 6093 | func (m *JsonReference) ResolveReferences(root string) (interface{}, error) { |
| 6094 | errors := make([]error, 0) |
| 6095 | if m.XRef != "" { |
| 6096 | info, err := compiler.ReadInfoForRef(root, m.XRef) |
| 6097 | if err != nil { |
| 6098 | return nil, err |
| 6099 | } |
| 6100 | if info != nil { |
| 6101 | replacement, err := NewJsonReference(info, nil) |
| 6102 | if err == nil { |
| 6103 | *m = *replacement |
| 6104 | return m.ResolveReferences(root) |
| 6105 | } |
| 6106 | } |
| 6107 | return info, nil |
| 6108 | } |
| 6109 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6110 | } |
| 6111 | |
| 6112 | // ResolveReferences resolves references found inside License objects. |
| 6113 | func (m *License) ResolveReferences(root string) (interface{}, error) { |
| 6114 | errors := make([]error, 0) |
| 6115 | for _, item := range m.VendorExtension { |
| 6116 | if item != nil { |
| 6117 | _, err := item.ResolveReferences(root) |
| 6118 | if err != nil { |
| 6119 | errors = append(errors, err) |
| 6120 | } |
| 6121 | } |
| 6122 | } |
| 6123 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6124 | } |
| 6125 | |
| 6126 | // ResolveReferences resolves references found inside NamedAny objects. |
| 6127 | func (m *NamedAny) ResolveReferences(root string) (interface{}, error) { |
| 6128 | errors := make([]error, 0) |
| 6129 | if m.Value != nil { |
| 6130 | _, err := m.Value.ResolveReferences(root) |
| 6131 | if err != nil { |
| 6132 | errors = append(errors, err) |
| 6133 | } |
| 6134 | } |
| 6135 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6136 | } |
| 6137 | |
| 6138 | // ResolveReferences resolves references found inside NamedHeader objects. |
| 6139 | func (m *NamedHeader) ResolveReferences(root string) (interface{}, error) { |
| 6140 | errors := make([]error, 0) |
| 6141 | if m.Value != nil { |
| 6142 | _, err := m.Value.ResolveReferences(root) |
| 6143 | if err != nil { |
| 6144 | errors = append(errors, err) |
| 6145 | } |
| 6146 | } |
| 6147 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6148 | } |
| 6149 | |
| 6150 | // ResolveReferences resolves references found inside NamedParameter objects. |
| 6151 | func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) { |
| 6152 | errors := make([]error, 0) |
| 6153 | if m.Value != nil { |
| 6154 | _, err := m.Value.ResolveReferences(root) |
| 6155 | if err != nil { |
| 6156 | errors = append(errors, err) |
| 6157 | } |
| 6158 | } |
| 6159 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6160 | } |
| 6161 | |
| 6162 | // ResolveReferences resolves references found inside NamedPathItem objects. |
| 6163 | func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) { |
| 6164 | errors := make([]error, 0) |
| 6165 | if m.Value != nil { |
| 6166 | _, err := m.Value.ResolveReferences(root) |
| 6167 | if err != nil { |
| 6168 | errors = append(errors, err) |
| 6169 | } |
| 6170 | } |
| 6171 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6172 | } |
| 6173 | |
| 6174 | // ResolveReferences resolves references found inside NamedResponse objects. |
| 6175 | func (m *NamedResponse) ResolveReferences(root string) (interface{}, error) { |
| 6176 | errors := make([]error, 0) |
| 6177 | if m.Value != nil { |
| 6178 | _, err := m.Value.ResolveReferences(root) |
| 6179 | if err != nil { |
| 6180 | errors = append(errors, err) |
| 6181 | } |
| 6182 | } |
| 6183 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6184 | } |
| 6185 | |
| 6186 | // ResolveReferences resolves references found inside NamedResponseValue objects. |
| 6187 | func (m *NamedResponseValue) ResolveReferences(root string) (interface{}, error) { |
| 6188 | errors := make([]error, 0) |
| 6189 | if m.Value != nil { |
| 6190 | _, err := m.Value.ResolveReferences(root) |
| 6191 | if err != nil { |
| 6192 | errors = append(errors, err) |
| 6193 | } |
| 6194 | } |
| 6195 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6196 | } |
| 6197 | |
| 6198 | // ResolveReferences resolves references found inside NamedSchema objects. |
| 6199 | func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) { |
| 6200 | errors := make([]error, 0) |
| 6201 | if m.Value != nil { |
| 6202 | _, err := m.Value.ResolveReferences(root) |
| 6203 | if err != nil { |
| 6204 | errors = append(errors, err) |
| 6205 | } |
| 6206 | } |
| 6207 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6208 | } |
| 6209 | |
| 6210 | // ResolveReferences resolves references found inside NamedSecurityDefinitionsItem objects. |
| 6211 | func (m *NamedSecurityDefinitionsItem) ResolveReferences(root string) (interface{}, error) { |
| 6212 | errors := make([]error, 0) |
| 6213 | if m.Value != nil { |
| 6214 | _, err := m.Value.ResolveReferences(root) |
| 6215 | if err != nil { |
| 6216 | errors = append(errors, err) |
| 6217 | } |
| 6218 | } |
| 6219 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6220 | } |
| 6221 | |
| 6222 | // ResolveReferences resolves references found inside NamedString objects. |
| 6223 | func (m *NamedString) ResolveReferences(root string) (interface{}, error) { |
| 6224 | errors := make([]error, 0) |
| 6225 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6226 | } |
| 6227 | |
| 6228 | // ResolveReferences resolves references found inside NamedStringArray objects. |
| 6229 | func (m *NamedStringArray) ResolveReferences(root string) (interface{}, error) { |
| 6230 | errors := make([]error, 0) |
| 6231 | if m.Value != nil { |
| 6232 | _, err := m.Value.ResolveReferences(root) |
| 6233 | if err != nil { |
| 6234 | errors = append(errors, err) |
| 6235 | } |
| 6236 | } |
| 6237 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6238 | } |
| 6239 | |
| 6240 | // ResolveReferences resolves references found inside NonBodyParameter objects. |
| 6241 | func (m *NonBodyParameter) ResolveReferences(root string) (interface{}, error) { |
| 6242 | errors := make([]error, 0) |
| 6243 | { |
| 6244 | p, ok := m.Oneof.(*NonBodyParameter_HeaderParameterSubSchema) |
| 6245 | if ok { |
| 6246 | _, err := p.HeaderParameterSubSchema.ResolveReferences(root) |
| 6247 | if err != nil { |
| 6248 | return nil, err |
| 6249 | } |
| 6250 | } |
| 6251 | } |
| 6252 | { |
| 6253 | p, ok := m.Oneof.(*NonBodyParameter_FormDataParameterSubSchema) |
| 6254 | if ok { |
| 6255 | _, err := p.FormDataParameterSubSchema.ResolveReferences(root) |
| 6256 | if err != nil { |
| 6257 | return nil, err |
| 6258 | } |
| 6259 | } |
| 6260 | } |
| 6261 | { |
| 6262 | p, ok := m.Oneof.(*NonBodyParameter_QueryParameterSubSchema) |
| 6263 | if ok { |
| 6264 | _, err := p.QueryParameterSubSchema.ResolveReferences(root) |
| 6265 | if err != nil { |
| 6266 | return nil, err |
| 6267 | } |
| 6268 | } |
| 6269 | } |
| 6270 | { |
| 6271 | p, ok := m.Oneof.(*NonBodyParameter_PathParameterSubSchema) |
| 6272 | if ok { |
| 6273 | _, err := p.PathParameterSubSchema.ResolveReferences(root) |
| 6274 | if err != nil { |
| 6275 | return nil, err |
| 6276 | } |
| 6277 | } |
| 6278 | } |
| 6279 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6280 | } |
| 6281 | |
| 6282 | // ResolveReferences resolves references found inside Oauth2AccessCodeSecurity objects. |
| 6283 | func (m *Oauth2AccessCodeSecurity) ResolveReferences(root string) (interface{}, error) { |
| 6284 | errors := make([]error, 0) |
| 6285 | if m.Scopes != nil { |
| 6286 | _, err := m.Scopes.ResolveReferences(root) |
| 6287 | if err != nil { |
| 6288 | errors = append(errors, err) |
| 6289 | } |
| 6290 | } |
| 6291 | for _, item := range m.VendorExtension { |
| 6292 | if item != nil { |
| 6293 | _, err := item.ResolveReferences(root) |
| 6294 | if err != nil { |
| 6295 | errors = append(errors, err) |
| 6296 | } |
| 6297 | } |
| 6298 | } |
| 6299 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6300 | } |
| 6301 | |
| 6302 | // ResolveReferences resolves references found inside Oauth2ApplicationSecurity objects. |
| 6303 | func (m *Oauth2ApplicationSecurity) ResolveReferences(root string) (interface{}, error) { |
| 6304 | errors := make([]error, 0) |
| 6305 | if m.Scopes != nil { |
| 6306 | _, err := m.Scopes.ResolveReferences(root) |
| 6307 | if err != nil { |
| 6308 | errors = append(errors, err) |
| 6309 | } |
| 6310 | } |
| 6311 | for _, item := range m.VendorExtension { |
| 6312 | if item != nil { |
| 6313 | _, err := item.ResolveReferences(root) |
| 6314 | if err != nil { |
| 6315 | errors = append(errors, err) |
| 6316 | } |
| 6317 | } |
| 6318 | } |
| 6319 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6320 | } |
| 6321 | |
| 6322 | // ResolveReferences resolves references found inside Oauth2ImplicitSecurity objects. |
| 6323 | func (m *Oauth2ImplicitSecurity) ResolveReferences(root string) (interface{}, error) { |
| 6324 | errors := make([]error, 0) |
| 6325 | if m.Scopes != nil { |
| 6326 | _, err := m.Scopes.ResolveReferences(root) |
| 6327 | if err != nil { |
| 6328 | errors = append(errors, err) |
| 6329 | } |
| 6330 | } |
| 6331 | for _, item := range m.VendorExtension { |
| 6332 | if item != nil { |
| 6333 | _, err := item.ResolveReferences(root) |
| 6334 | if err != nil { |
| 6335 | errors = append(errors, err) |
| 6336 | } |
| 6337 | } |
| 6338 | } |
| 6339 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6340 | } |
| 6341 | |
| 6342 | // ResolveReferences resolves references found inside Oauth2PasswordSecurity objects. |
| 6343 | func (m *Oauth2PasswordSecurity) ResolveReferences(root string) (interface{}, error) { |
| 6344 | errors := make([]error, 0) |
| 6345 | if m.Scopes != nil { |
| 6346 | _, err := m.Scopes.ResolveReferences(root) |
| 6347 | if err != nil { |
| 6348 | errors = append(errors, err) |
| 6349 | } |
| 6350 | } |
| 6351 | for _, item := range m.VendorExtension { |
| 6352 | if item != nil { |
| 6353 | _, err := item.ResolveReferences(root) |
| 6354 | if err != nil { |
| 6355 | errors = append(errors, err) |
| 6356 | } |
| 6357 | } |
| 6358 | } |
| 6359 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6360 | } |
| 6361 | |
| 6362 | // ResolveReferences resolves references found inside Oauth2Scopes objects. |
| 6363 | func (m *Oauth2Scopes) ResolveReferences(root string) (interface{}, error) { |
| 6364 | errors := make([]error, 0) |
| 6365 | for _, item := range m.AdditionalProperties { |
| 6366 | if item != nil { |
| 6367 | _, err := item.ResolveReferences(root) |
| 6368 | if err != nil { |
| 6369 | errors = append(errors, err) |
| 6370 | } |
| 6371 | } |
| 6372 | } |
| 6373 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6374 | } |
| 6375 | |
| 6376 | // ResolveReferences resolves references found inside Operation objects. |
| 6377 | func (m *Operation) ResolveReferences(root string) (interface{}, error) { |
| 6378 | errors := make([]error, 0) |
| 6379 | if m.ExternalDocs != nil { |
| 6380 | _, err := m.ExternalDocs.ResolveReferences(root) |
| 6381 | if err != nil { |
| 6382 | errors = append(errors, err) |
| 6383 | } |
| 6384 | } |
| 6385 | for _, item := range m.Parameters { |
| 6386 | if item != nil { |
| 6387 | _, err := item.ResolveReferences(root) |
| 6388 | if err != nil { |
| 6389 | errors = append(errors, err) |
| 6390 | } |
| 6391 | } |
| 6392 | } |
| 6393 | if m.Responses != nil { |
| 6394 | _, err := m.Responses.ResolveReferences(root) |
| 6395 | if err != nil { |
| 6396 | errors = append(errors, err) |
| 6397 | } |
| 6398 | } |
| 6399 | for _, item := range m.Security { |
| 6400 | if item != nil { |
| 6401 | _, err := item.ResolveReferences(root) |
| 6402 | if err != nil { |
| 6403 | errors = append(errors, err) |
| 6404 | } |
| 6405 | } |
| 6406 | } |
| 6407 | for _, item := range m.VendorExtension { |
| 6408 | if item != nil { |
| 6409 | _, err := item.ResolveReferences(root) |
| 6410 | if err != nil { |
| 6411 | errors = append(errors, err) |
| 6412 | } |
| 6413 | } |
| 6414 | } |
| 6415 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6416 | } |
| 6417 | |
| 6418 | // ResolveReferences resolves references found inside Parameter objects. |
| 6419 | func (m *Parameter) ResolveReferences(root string) (interface{}, error) { |
| 6420 | errors := make([]error, 0) |
| 6421 | { |
| 6422 | p, ok := m.Oneof.(*Parameter_BodyParameter) |
| 6423 | if ok { |
| 6424 | _, err := p.BodyParameter.ResolveReferences(root) |
| 6425 | if err != nil { |
| 6426 | return nil, err |
| 6427 | } |
| 6428 | } |
| 6429 | } |
| 6430 | { |
| 6431 | p, ok := m.Oneof.(*Parameter_NonBodyParameter) |
| 6432 | if ok { |
| 6433 | _, err := p.NonBodyParameter.ResolveReferences(root) |
| 6434 | if err != nil { |
| 6435 | return nil, err |
| 6436 | } |
| 6437 | } |
| 6438 | } |
| 6439 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6440 | } |
| 6441 | |
| 6442 | // ResolveReferences resolves references found inside ParameterDefinitions objects. |
| 6443 | func (m *ParameterDefinitions) ResolveReferences(root string) (interface{}, error) { |
| 6444 | errors := make([]error, 0) |
| 6445 | for _, item := range m.AdditionalProperties { |
| 6446 | if item != nil { |
| 6447 | _, err := item.ResolveReferences(root) |
| 6448 | if err != nil { |
| 6449 | errors = append(errors, err) |
| 6450 | } |
| 6451 | } |
| 6452 | } |
| 6453 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6454 | } |
| 6455 | |
| 6456 | // ResolveReferences resolves references found inside ParametersItem objects. |
| 6457 | func (m *ParametersItem) ResolveReferences(root string) (interface{}, error) { |
| 6458 | errors := make([]error, 0) |
| 6459 | { |
| 6460 | p, ok := m.Oneof.(*ParametersItem_Parameter) |
| 6461 | if ok { |
| 6462 | _, err := p.Parameter.ResolveReferences(root) |
| 6463 | if err != nil { |
| 6464 | return nil, err |
| 6465 | } |
| 6466 | } |
| 6467 | } |
| 6468 | { |
| 6469 | p, ok := m.Oneof.(*ParametersItem_JsonReference) |
| 6470 | if ok { |
| 6471 | info, err := p.JsonReference.ResolveReferences(root) |
| 6472 | if err != nil { |
| 6473 | return nil, err |
| 6474 | } else if info != nil { |
| 6475 | n, err := NewParametersItem(info, nil) |
| 6476 | if err != nil { |
| 6477 | return nil, err |
| 6478 | } else if n != nil { |
| 6479 | *m = *n |
| 6480 | return nil, nil |
| 6481 | } |
| 6482 | } |
| 6483 | } |
| 6484 | } |
| 6485 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6486 | } |
| 6487 | |
| 6488 | // ResolveReferences resolves references found inside PathItem objects. |
| 6489 | func (m *PathItem) ResolveReferences(root string) (interface{}, error) { |
| 6490 | errors := make([]error, 0) |
| 6491 | if m.XRef != "" { |
| 6492 | info, err := compiler.ReadInfoForRef(root, m.XRef) |
| 6493 | if err != nil { |
| 6494 | return nil, err |
| 6495 | } |
| 6496 | if info != nil { |
| 6497 | replacement, err := NewPathItem(info, nil) |
| 6498 | if err == nil { |
| 6499 | *m = *replacement |
| 6500 | return m.ResolveReferences(root) |
| 6501 | } |
| 6502 | } |
| 6503 | return info, nil |
| 6504 | } |
| 6505 | if m.Get != nil { |
| 6506 | _, err := m.Get.ResolveReferences(root) |
| 6507 | if err != nil { |
| 6508 | errors = append(errors, err) |
| 6509 | } |
| 6510 | } |
| 6511 | if m.Put != nil { |
| 6512 | _, err := m.Put.ResolveReferences(root) |
| 6513 | if err != nil { |
| 6514 | errors = append(errors, err) |
| 6515 | } |
| 6516 | } |
| 6517 | if m.Post != nil { |
| 6518 | _, err := m.Post.ResolveReferences(root) |
| 6519 | if err != nil { |
| 6520 | errors = append(errors, err) |
| 6521 | } |
| 6522 | } |
| 6523 | if m.Delete != nil { |
| 6524 | _, err := m.Delete.ResolveReferences(root) |
| 6525 | if err != nil { |
| 6526 | errors = append(errors, err) |
| 6527 | } |
| 6528 | } |
| 6529 | if m.Options != nil { |
| 6530 | _, err := m.Options.ResolveReferences(root) |
| 6531 | if err != nil { |
| 6532 | errors = append(errors, err) |
| 6533 | } |
| 6534 | } |
| 6535 | if m.Head != nil { |
| 6536 | _, err := m.Head.ResolveReferences(root) |
| 6537 | if err != nil { |
| 6538 | errors = append(errors, err) |
| 6539 | } |
| 6540 | } |
| 6541 | if m.Patch != nil { |
| 6542 | _, err := m.Patch.ResolveReferences(root) |
| 6543 | if err != nil { |
| 6544 | errors = append(errors, err) |
| 6545 | } |
| 6546 | } |
| 6547 | for _, item := range m.Parameters { |
| 6548 | if item != nil { |
| 6549 | _, err := item.ResolveReferences(root) |
| 6550 | if err != nil { |
| 6551 | errors = append(errors, err) |
| 6552 | } |
| 6553 | } |
| 6554 | } |
| 6555 | for _, item := range m.VendorExtension { |
| 6556 | if item != nil { |
| 6557 | _, err := item.ResolveReferences(root) |
| 6558 | if err != nil { |
| 6559 | errors = append(errors, err) |
| 6560 | } |
| 6561 | } |
| 6562 | } |
| 6563 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6564 | } |
| 6565 | |
| 6566 | // ResolveReferences resolves references found inside PathParameterSubSchema objects. |
| 6567 | func (m *PathParameterSubSchema) ResolveReferences(root string) (interface{}, error) { |
| 6568 | errors := make([]error, 0) |
| 6569 | if m.Items != nil { |
| 6570 | _, err := m.Items.ResolveReferences(root) |
| 6571 | if err != nil { |
| 6572 | errors = append(errors, err) |
| 6573 | } |
| 6574 | } |
| 6575 | if m.Default != nil { |
| 6576 | _, err := m.Default.ResolveReferences(root) |
| 6577 | if err != nil { |
| 6578 | errors = append(errors, err) |
| 6579 | } |
| 6580 | } |
| 6581 | for _, item := range m.Enum { |
| 6582 | if item != nil { |
| 6583 | _, err := item.ResolveReferences(root) |
| 6584 | if err != nil { |
| 6585 | errors = append(errors, err) |
| 6586 | } |
| 6587 | } |
| 6588 | } |
| 6589 | for _, item := range m.VendorExtension { |
| 6590 | if item != nil { |
| 6591 | _, err := item.ResolveReferences(root) |
| 6592 | if err != nil { |
| 6593 | errors = append(errors, err) |
| 6594 | } |
| 6595 | } |
| 6596 | } |
| 6597 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6598 | } |
| 6599 | |
| 6600 | // ResolveReferences resolves references found inside Paths objects. |
| 6601 | func (m *Paths) ResolveReferences(root string) (interface{}, error) { |
| 6602 | errors := make([]error, 0) |
| 6603 | for _, item := range m.VendorExtension { |
| 6604 | if item != nil { |
| 6605 | _, err := item.ResolveReferences(root) |
| 6606 | if err != nil { |
| 6607 | errors = append(errors, err) |
| 6608 | } |
| 6609 | } |
| 6610 | } |
| 6611 | for _, item := range m.Path { |
| 6612 | if item != nil { |
| 6613 | _, err := item.ResolveReferences(root) |
| 6614 | if err != nil { |
| 6615 | errors = append(errors, err) |
| 6616 | } |
| 6617 | } |
| 6618 | } |
| 6619 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6620 | } |
| 6621 | |
| 6622 | // ResolveReferences resolves references found inside PrimitivesItems objects. |
| 6623 | func (m *PrimitivesItems) ResolveReferences(root string) (interface{}, error) { |
| 6624 | errors := make([]error, 0) |
| 6625 | if m.Items != nil { |
| 6626 | _, err := m.Items.ResolveReferences(root) |
| 6627 | if err != nil { |
| 6628 | errors = append(errors, err) |
| 6629 | } |
| 6630 | } |
| 6631 | if m.Default != nil { |
| 6632 | _, err := m.Default.ResolveReferences(root) |
| 6633 | if err != nil { |
| 6634 | errors = append(errors, err) |
| 6635 | } |
| 6636 | } |
| 6637 | for _, item := range m.Enum { |
| 6638 | if item != nil { |
| 6639 | _, err := item.ResolveReferences(root) |
| 6640 | if err != nil { |
| 6641 | errors = append(errors, err) |
| 6642 | } |
| 6643 | } |
| 6644 | } |
| 6645 | for _, item := range m.VendorExtension { |
| 6646 | if item != nil { |
| 6647 | _, err := item.ResolveReferences(root) |
| 6648 | if err != nil { |
| 6649 | errors = append(errors, err) |
| 6650 | } |
| 6651 | } |
| 6652 | } |
| 6653 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6654 | } |
| 6655 | |
| 6656 | // ResolveReferences resolves references found inside Properties objects. |
| 6657 | func (m *Properties) ResolveReferences(root string) (interface{}, error) { |
| 6658 | errors := make([]error, 0) |
| 6659 | for _, item := range m.AdditionalProperties { |
| 6660 | if item != nil { |
| 6661 | _, err := item.ResolveReferences(root) |
| 6662 | if err != nil { |
| 6663 | errors = append(errors, err) |
| 6664 | } |
| 6665 | } |
| 6666 | } |
| 6667 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6668 | } |
| 6669 | |
| 6670 | // ResolveReferences resolves references found inside QueryParameterSubSchema objects. |
| 6671 | func (m *QueryParameterSubSchema) ResolveReferences(root string) (interface{}, error) { |
| 6672 | errors := make([]error, 0) |
| 6673 | if m.Items != nil { |
| 6674 | _, err := m.Items.ResolveReferences(root) |
| 6675 | if err != nil { |
| 6676 | errors = append(errors, err) |
| 6677 | } |
| 6678 | } |
| 6679 | if m.Default != nil { |
| 6680 | _, err := m.Default.ResolveReferences(root) |
| 6681 | if err != nil { |
| 6682 | errors = append(errors, err) |
| 6683 | } |
| 6684 | } |
| 6685 | for _, item := range m.Enum { |
| 6686 | if item != nil { |
| 6687 | _, err := item.ResolveReferences(root) |
| 6688 | if err != nil { |
| 6689 | errors = append(errors, err) |
| 6690 | } |
| 6691 | } |
| 6692 | } |
| 6693 | for _, item := range m.VendorExtension { |
| 6694 | if item != nil { |
| 6695 | _, err := item.ResolveReferences(root) |
| 6696 | if err != nil { |
| 6697 | errors = append(errors, err) |
| 6698 | } |
| 6699 | } |
| 6700 | } |
| 6701 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6702 | } |
| 6703 | |
| 6704 | // ResolveReferences resolves references found inside Response objects. |
| 6705 | func (m *Response) ResolveReferences(root string) (interface{}, error) { |
| 6706 | errors := make([]error, 0) |
| 6707 | if m.Schema != nil { |
| 6708 | _, err := m.Schema.ResolveReferences(root) |
| 6709 | if err != nil { |
| 6710 | errors = append(errors, err) |
| 6711 | } |
| 6712 | } |
| 6713 | if m.Headers != nil { |
| 6714 | _, err := m.Headers.ResolveReferences(root) |
| 6715 | if err != nil { |
| 6716 | errors = append(errors, err) |
| 6717 | } |
| 6718 | } |
| 6719 | if m.Examples != nil { |
| 6720 | _, err := m.Examples.ResolveReferences(root) |
| 6721 | if err != nil { |
| 6722 | errors = append(errors, err) |
| 6723 | } |
| 6724 | } |
| 6725 | for _, item := range m.VendorExtension { |
| 6726 | if item != nil { |
| 6727 | _, err := item.ResolveReferences(root) |
| 6728 | if err != nil { |
| 6729 | errors = append(errors, err) |
| 6730 | } |
| 6731 | } |
| 6732 | } |
| 6733 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6734 | } |
| 6735 | |
| 6736 | // ResolveReferences resolves references found inside ResponseDefinitions objects. |
| 6737 | func (m *ResponseDefinitions) ResolveReferences(root string) (interface{}, error) { |
| 6738 | errors := make([]error, 0) |
| 6739 | for _, item := range m.AdditionalProperties { |
| 6740 | if item != nil { |
| 6741 | _, err := item.ResolveReferences(root) |
| 6742 | if err != nil { |
| 6743 | errors = append(errors, err) |
| 6744 | } |
| 6745 | } |
| 6746 | } |
| 6747 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6748 | } |
| 6749 | |
| 6750 | // ResolveReferences resolves references found inside ResponseValue objects. |
| 6751 | func (m *ResponseValue) ResolveReferences(root string) (interface{}, error) { |
| 6752 | errors := make([]error, 0) |
| 6753 | { |
| 6754 | p, ok := m.Oneof.(*ResponseValue_Response) |
| 6755 | if ok { |
| 6756 | _, err := p.Response.ResolveReferences(root) |
| 6757 | if err != nil { |
| 6758 | return nil, err |
| 6759 | } |
| 6760 | } |
| 6761 | } |
| 6762 | { |
| 6763 | p, ok := m.Oneof.(*ResponseValue_JsonReference) |
| 6764 | if ok { |
| 6765 | info, err := p.JsonReference.ResolveReferences(root) |
| 6766 | if err != nil { |
| 6767 | return nil, err |
| 6768 | } else if info != nil { |
| 6769 | n, err := NewResponseValue(info, nil) |
| 6770 | if err != nil { |
| 6771 | return nil, err |
| 6772 | } else if n != nil { |
| 6773 | *m = *n |
| 6774 | return nil, nil |
| 6775 | } |
| 6776 | } |
| 6777 | } |
| 6778 | } |
| 6779 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6780 | } |
| 6781 | |
| 6782 | // ResolveReferences resolves references found inside Responses objects. |
| 6783 | func (m *Responses) ResolveReferences(root string) (interface{}, error) { |
| 6784 | errors := make([]error, 0) |
| 6785 | for _, item := range m.ResponseCode { |
| 6786 | if item != nil { |
| 6787 | _, err := item.ResolveReferences(root) |
| 6788 | if err != nil { |
| 6789 | errors = append(errors, err) |
| 6790 | } |
| 6791 | } |
| 6792 | } |
| 6793 | for _, item := range m.VendorExtension { |
| 6794 | if item != nil { |
| 6795 | _, err := item.ResolveReferences(root) |
| 6796 | if err != nil { |
| 6797 | errors = append(errors, err) |
| 6798 | } |
| 6799 | } |
| 6800 | } |
| 6801 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6802 | } |
| 6803 | |
| 6804 | // ResolveReferences resolves references found inside Schema objects. |
| 6805 | func (m *Schema) ResolveReferences(root string) (interface{}, error) { |
| 6806 | errors := make([]error, 0) |
| 6807 | if m.XRef != "" { |
| 6808 | info, err := compiler.ReadInfoForRef(root, m.XRef) |
| 6809 | if err != nil { |
| 6810 | return nil, err |
| 6811 | } |
| 6812 | if info != nil { |
| 6813 | replacement, err := NewSchema(info, nil) |
| 6814 | if err == nil { |
| 6815 | *m = *replacement |
| 6816 | return m.ResolveReferences(root) |
| 6817 | } |
| 6818 | } |
| 6819 | return info, nil |
| 6820 | } |
| 6821 | if m.Default != nil { |
| 6822 | _, err := m.Default.ResolveReferences(root) |
| 6823 | if err != nil { |
| 6824 | errors = append(errors, err) |
| 6825 | } |
| 6826 | } |
| 6827 | for _, item := range m.Enum { |
| 6828 | if item != nil { |
| 6829 | _, err := item.ResolveReferences(root) |
| 6830 | if err != nil { |
| 6831 | errors = append(errors, err) |
| 6832 | } |
| 6833 | } |
| 6834 | } |
| 6835 | if m.AdditionalProperties != nil { |
| 6836 | _, err := m.AdditionalProperties.ResolveReferences(root) |
| 6837 | if err != nil { |
| 6838 | errors = append(errors, err) |
| 6839 | } |
| 6840 | } |
| 6841 | if m.Type != nil { |
| 6842 | _, err := m.Type.ResolveReferences(root) |
| 6843 | if err != nil { |
| 6844 | errors = append(errors, err) |
| 6845 | } |
| 6846 | } |
| 6847 | if m.Items != nil { |
| 6848 | _, err := m.Items.ResolveReferences(root) |
| 6849 | if err != nil { |
| 6850 | errors = append(errors, err) |
| 6851 | } |
| 6852 | } |
| 6853 | for _, item := range m.AllOf { |
| 6854 | if item != nil { |
| 6855 | _, err := item.ResolveReferences(root) |
| 6856 | if err != nil { |
| 6857 | errors = append(errors, err) |
| 6858 | } |
| 6859 | } |
| 6860 | } |
| 6861 | if m.Properties != nil { |
| 6862 | _, err := m.Properties.ResolveReferences(root) |
| 6863 | if err != nil { |
| 6864 | errors = append(errors, err) |
| 6865 | } |
| 6866 | } |
| 6867 | if m.Xml != nil { |
| 6868 | _, err := m.Xml.ResolveReferences(root) |
| 6869 | if err != nil { |
| 6870 | errors = append(errors, err) |
| 6871 | } |
| 6872 | } |
| 6873 | if m.ExternalDocs != nil { |
| 6874 | _, err := m.ExternalDocs.ResolveReferences(root) |
| 6875 | if err != nil { |
| 6876 | errors = append(errors, err) |
| 6877 | } |
| 6878 | } |
| 6879 | if m.Example != nil { |
| 6880 | _, err := m.Example.ResolveReferences(root) |
| 6881 | if err != nil { |
| 6882 | errors = append(errors, err) |
| 6883 | } |
| 6884 | } |
| 6885 | for _, item := range m.VendorExtension { |
| 6886 | if item != nil { |
| 6887 | _, err := item.ResolveReferences(root) |
| 6888 | if err != nil { |
| 6889 | errors = append(errors, err) |
| 6890 | } |
| 6891 | } |
| 6892 | } |
| 6893 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6894 | } |
| 6895 | |
| 6896 | // ResolveReferences resolves references found inside SchemaItem objects. |
| 6897 | func (m *SchemaItem) ResolveReferences(root string) (interface{}, error) { |
| 6898 | errors := make([]error, 0) |
| 6899 | { |
| 6900 | p, ok := m.Oneof.(*SchemaItem_Schema) |
| 6901 | if ok { |
| 6902 | _, err := p.Schema.ResolveReferences(root) |
| 6903 | if err != nil { |
| 6904 | return nil, err |
| 6905 | } |
| 6906 | } |
| 6907 | } |
| 6908 | { |
| 6909 | p, ok := m.Oneof.(*SchemaItem_FileSchema) |
| 6910 | if ok { |
| 6911 | _, err := p.FileSchema.ResolveReferences(root) |
| 6912 | if err != nil { |
| 6913 | return nil, err |
| 6914 | } |
| 6915 | } |
| 6916 | } |
| 6917 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6918 | } |
| 6919 | |
| 6920 | // ResolveReferences resolves references found inside SecurityDefinitions objects. |
| 6921 | func (m *SecurityDefinitions) ResolveReferences(root string) (interface{}, error) { |
| 6922 | errors := make([]error, 0) |
| 6923 | for _, item := range m.AdditionalProperties { |
| 6924 | if item != nil { |
| 6925 | _, err := item.ResolveReferences(root) |
| 6926 | if err != nil { |
| 6927 | errors = append(errors, err) |
| 6928 | } |
| 6929 | } |
| 6930 | } |
| 6931 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6932 | } |
| 6933 | |
| 6934 | // ResolveReferences resolves references found inside SecurityDefinitionsItem objects. |
| 6935 | func (m *SecurityDefinitionsItem) ResolveReferences(root string) (interface{}, error) { |
| 6936 | errors := make([]error, 0) |
| 6937 | { |
| 6938 | p, ok := m.Oneof.(*SecurityDefinitionsItem_BasicAuthenticationSecurity) |
| 6939 | if ok { |
| 6940 | _, err := p.BasicAuthenticationSecurity.ResolveReferences(root) |
| 6941 | if err != nil { |
| 6942 | return nil, err |
| 6943 | } |
| 6944 | } |
| 6945 | } |
| 6946 | { |
| 6947 | p, ok := m.Oneof.(*SecurityDefinitionsItem_ApiKeySecurity) |
| 6948 | if ok { |
| 6949 | _, err := p.ApiKeySecurity.ResolveReferences(root) |
| 6950 | if err != nil { |
| 6951 | return nil, err |
| 6952 | } |
| 6953 | } |
| 6954 | } |
| 6955 | { |
| 6956 | p, ok := m.Oneof.(*SecurityDefinitionsItem_Oauth2ImplicitSecurity) |
| 6957 | if ok { |
| 6958 | _, err := p.Oauth2ImplicitSecurity.ResolveReferences(root) |
| 6959 | if err != nil { |
| 6960 | return nil, err |
| 6961 | } |
| 6962 | } |
| 6963 | } |
| 6964 | { |
| 6965 | p, ok := m.Oneof.(*SecurityDefinitionsItem_Oauth2PasswordSecurity) |
| 6966 | if ok { |
| 6967 | _, err := p.Oauth2PasswordSecurity.ResolveReferences(root) |
| 6968 | if err != nil { |
| 6969 | return nil, err |
| 6970 | } |
| 6971 | } |
| 6972 | } |
| 6973 | { |
| 6974 | p, ok := m.Oneof.(*SecurityDefinitionsItem_Oauth2ApplicationSecurity) |
| 6975 | if ok { |
| 6976 | _, err := p.Oauth2ApplicationSecurity.ResolveReferences(root) |
| 6977 | if err != nil { |
| 6978 | return nil, err |
| 6979 | } |
| 6980 | } |
| 6981 | } |
| 6982 | { |
| 6983 | p, ok := m.Oneof.(*SecurityDefinitionsItem_Oauth2AccessCodeSecurity) |
| 6984 | if ok { |
| 6985 | _, err := p.Oauth2AccessCodeSecurity.ResolveReferences(root) |
| 6986 | if err != nil { |
| 6987 | return nil, err |
| 6988 | } |
| 6989 | } |
| 6990 | } |
| 6991 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 6992 | } |
| 6993 | |
| 6994 | // ResolveReferences resolves references found inside SecurityRequirement objects. |
| 6995 | func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error) { |
| 6996 | errors := make([]error, 0) |
| 6997 | for _, item := range m.AdditionalProperties { |
| 6998 | if item != nil { |
| 6999 | _, err := item.ResolveReferences(root) |
| 7000 | if err != nil { |
| 7001 | errors = append(errors, err) |
| 7002 | } |
| 7003 | } |
| 7004 | } |
| 7005 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 7006 | } |
| 7007 | |
| 7008 | // ResolveReferences resolves references found inside StringArray objects. |
| 7009 | func (m *StringArray) ResolveReferences(root string) (interface{}, error) { |
| 7010 | errors := make([]error, 0) |
| 7011 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 7012 | } |
| 7013 | |
| 7014 | // ResolveReferences resolves references found inside Tag objects. |
| 7015 | func (m *Tag) ResolveReferences(root string) (interface{}, error) { |
| 7016 | errors := make([]error, 0) |
| 7017 | if m.ExternalDocs != nil { |
| 7018 | _, err := m.ExternalDocs.ResolveReferences(root) |
| 7019 | if err != nil { |
| 7020 | errors = append(errors, err) |
| 7021 | } |
| 7022 | } |
| 7023 | for _, item := range m.VendorExtension { |
| 7024 | if item != nil { |
| 7025 | _, err := item.ResolveReferences(root) |
| 7026 | if err != nil { |
| 7027 | errors = append(errors, err) |
| 7028 | } |
| 7029 | } |
| 7030 | } |
| 7031 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 7032 | } |
| 7033 | |
| 7034 | // ResolveReferences resolves references found inside TypeItem objects. |
| 7035 | func (m *TypeItem) ResolveReferences(root string) (interface{}, error) { |
| 7036 | errors := make([]error, 0) |
| 7037 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 7038 | } |
| 7039 | |
| 7040 | // ResolveReferences resolves references found inside VendorExtension objects. |
| 7041 | func (m *VendorExtension) ResolveReferences(root string) (interface{}, error) { |
| 7042 | errors := make([]error, 0) |
| 7043 | for _, item := range m.AdditionalProperties { |
| 7044 | if item != nil { |
| 7045 | _, err := item.ResolveReferences(root) |
| 7046 | if err != nil { |
| 7047 | errors = append(errors, err) |
| 7048 | } |
| 7049 | } |
| 7050 | } |
| 7051 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 7052 | } |
| 7053 | |
| 7054 | // ResolveReferences resolves references found inside Xml objects. |
| 7055 | func (m *Xml) ResolveReferences(root string) (interface{}, error) { |
| 7056 | errors := make([]error, 0) |
| 7057 | for _, item := range m.VendorExtension { |
| 7058 | if item != nil { |
| 7059 | _, err := item.ResolveReferences(root) |
| 7060 | if err != nil { |
| 7061 | errors = append(errors, err) |
| 7062 | } |
| 7063 | } |
| 7064 | } |
| 7065 | return nil, compiler.NewErrorGroupOrNil(errors) |
| 7066 | } |
| 7067 | |
| 7068 | // ToRawInfo returns a description of AdditionalPropertiesItem suitable for JSON or YAML export. |
| 7069 | func (m *AdditionalPropertiesItem) ToRawInfo() interface{} { |
| 7070 | // ONE OF WRAPPER |
| 7071 | // AdditionalPropertiesItem |
| 7072 | // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7073 | v0 := m.GetSchema() |
| 7074 | if v0 != nil { |
| 7075 | return v0.ToRawInfo() |
| 7076 | } |
| 7077 | // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7078 | if v1, ok := m.GetOneof().(*AdditionalPropertiesItem_Boolean); ok { |
| 7079 | return v1.Boolean |
| 7080 | } |
| 7081 | return nil |
| 7082 | } |
| 7083 | |
| 7084 | // ToRawInfo returns a description of Any suitable for JSON or YAML export. |
| 7085 | func (m *Any) ToRawInfo() interface{} { |
| 7086 | var err error |
| 7087 | var info1 []yaml.MapSlice |
| 7088 | err = yaml.Unmarshal([]byte(m.Yaml), &info1) |
| 7089 | if err == nil { |
| 7090 | return info1 |
| 7091 | } |
| 7092 | var info2 yaml.MapSlice |
| 7093 | err = yaml.Unmarshal([]byte(m.Yaml), &info2) |
| 7094 | if err == nil { |
| 7095 | return info2 |
| 7096 | } |
| 7097 | var info3 interface{} |
| 7098 | err = yaml.Unmarshal([]byte(m.Yaml), &info3) |
| 7099 | if err == nil { |
| 7100 | return info3 |
| 7101 | } |
| 7102 | return nil |
| 7103 | } |
| 7104 | |
| 7105 | // ToRawInfo returns a description of ApiKeySecurity suitable for JSON or YAML export. |
| 7106 | func (m *ApiKeySecurity) ToRawInfo() interface{} { |
| 7107 | info := yaml.MapSlice{} |
| 7108 | if m.Type != "" { |
| 7109 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7110 | } |
| 7111 | if m.Name != "" { |
| 7112 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7113 | } |
| 7114 | if m.In != "" { |
| 7115 | info = append(info, yaml.MapItem{Key: "in", Value: m.In}) |
| 7116 | } |
| 7117 | if m.Description != "" { |
| 7118 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7119 | } |
| 7120 | if m.VendorExtension != nil { |
| 7121 | for _, item := range m.VendorExtension { |
| 7122 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7123 | } |
| 7124 | } |
| 7125 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7126 | return info |
| 7127 | } |
| 7128 | |
| 7129 | // ToRawInfo returns a description of BasicAuthenticationSecurity suitable for JSON or YAML export. |
| 7130 | func (m *BasicAuthenticationSecurity) ToRawInfo() interface{} { |
| 7131 | info := yaml.MapSlice{} |
| 7132 | if m.Type != "" { |
| 7133 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7134 | } |
| 7135 | if m.Description != "" { |
| 7136 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7137 | } |
| 7138 | if m.VendorExtension != nil { |
| 7139 | for _, item := range m.VendorExtension { |
| 7140 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7141 | } |
| 7142 | } |
| 7143 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7144 | return info |
| 7145 | } |
| 7146 | |
| 7147 | // ToRawInfo returns a description of BodyParameter suitable for JSON or YAML export. |
| 7148 | func (m *BodyParameter) ToRawInfo() interface{} { |
| 7149 | info := yaml.MapSlice{} |
| 7150 | if m.Description != "" { |
| 7151 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7152 | } |
| 7153 | if m.Name != "" { |
| 7154 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7155 | } |
| 7156 | if m.In != "" { |
| 7157 | info = append(info, yaml.MapItem{Key: "in", Value: m.In}) |
| 7158 | } |
| 7159 | if m.Required != false { |
| 7160 | info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) |
| 7161 | } |
| 7162 | if m.Schema != nil { |
| 7163 | info = append(info, yaml.MapItem{Key: "schema", Value: m.Schema.ToRawInfo()}) |
| 7164 | } |
| 7165 | // &{Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7166 | if m.VendorExtension != nil { |
| 7167 | for _, item := range m.VendorExtension { |
| 7168 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7169 | } |
| 7170 | } |
| 7171 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7172 | return info |
| 7173 | } |
| 7174 | |
| 7175 | // ToRawInfo returns a description of Contact suitable for JSON or YAML export. |
| 7176 | func (m *Contact) ToRawInfo() interface{} { |
| 7177 | info := yaml.MapSlice{} |
| 7178 | if m.Name != "" { |
| 7179 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7180 | } |
| 7181 | if m.Url != "" { |
| 7182 | info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) |
| 7183 | } |
| 7184 | if m.Email != "" { |
| 7185 | info = append(info, yaml.MapItem{Key: "email", Value: m.Email}) |
| 7186 | } |
| 7187 | if m.VendorExtension != nil { |
| 7188 | for _, item := range m.VendorExtension { |
| 7189 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7190 | } |
| 7191 | } |
| 7192 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7193 | return info |
| 7194 | } |
| 7195 | |
| 7196 | // ToRawInfo returns a description of Default suitable for JSON or YAML export. |
| 7197 | func (m *Default) ToRawInfo() interface{} { |
| 7198 | info := yaml.MapSlice{} |
| 7199 | if m.AdditionalProperties != nil { |
| 7200 | for _, item := range m.AdditionalProperties { |
| 7201 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7202 | } |
| 7203 | } |
| 7204 | // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:false Description:} |
| 7205 | return info |
| 7206 | } |
| 7207 | |
| 7208 | // ToRawInfo returns a description of Definitions suitable for JSON or YAML export. |
| 7209 | func (m *Definitions) ToRawInfo() interface{} { |
| 7210 | info := yaml.MapSlice{} |
| 7211 | if m.AdditionalProperties != nil { |
| 7212 | for _, item := range m.AdditionalProperties { |
| 7213 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7214 | } |
| 7215 | } |
| 7216 | // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:} |
| 7217 | return info |
| 7218 | } |
| 7219 | |
| 7220 | // ToRawInfo returns a description of Document suitable for JSON or YAML export. |
| 7221 | func (m *Document) ToRawInfo() interface{} { |
| 7222 | info := yaml.MapSlice{} |
| 7223 | if m.Swagger != "" { |
| 7224 | info = append(info, yaml.MapItem{Key: "swagger", Value: m.Swagger}) |
| 7225 | } |
| 7226 | if m.Info != nil { |
| 7227 | info = append(info, yaml.MapItem{Key: "info", Value: m.Info.ToRawInfo()}) |
| 7228 | } |
| 7229 | // &{Name:info Type:Info StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7230 | if m.Host != "" { |
| 7231 | info = append(info, yaml.MapItem{Key: "host", Value: m.Host}) |
| 7232 | } |
| 7233 | if m.BasePath != "" { |
| 7234 | info = append(info, yaml.MapItem{Key: "basePath", Value: m.BasePath}) |
| 7235 | } |
| 7236 | if len(m.Schemes) != 0 { |
| 7237 | info = append(info, yaml.MapItem{Key: "schemes", Value: m.Schemes}) |
| 7238 | } |
| 7239 | if len(m.Consumes) != 0 { |
| 7240 | info = append(info, yaml.MapItem{Key: "consumes", Value: m.Consumes}) |
| 7241 | } |
| 7242 | if len(m.Produces) != 0 { |
| 7243 | info = append(info, yaml.MapItem{Key: "produces", Value: m.Produces}) |
| 7244 | } |
| 7245 | if m.Paths != nil { |
| 7246 | info = append(info, yaml.MapItem{Key: "paths", Value: m.Paths.ToRawInfo()}) |
| 7247 | } |
| 7248 | // &{Name:paths Type:Paths StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7249 | if m.Definitions != nil { |
| 7250 | info = append(info, yaml.MapItem{Key: "definitions", Value: m.Definitions.ToRawInfo()}) |
| 7251 | } |
| 7252 | // &{Name:definitions Type:Definitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7253 | if m.Parameters != nil { |
| 7254 | info = append(info, yaml.MapItem{Key: "parameters", Value: m.Parameters.ToRawInfo()}) |
| 7255 | } |
| 7256 | // &{Name:parameters Type:ParameterDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7257 | if m.Responses != nil { |
| 7258 | info = append(info, yaml.MapItem{Key: "responses", Value: m.Responses.ToRawInfo()}) |
| 7259 | } |
| 7260 | // &{Name:responses Type:ResponseDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7261 | if len(m.Security) != 0 { |
| 7262 | items := make([]interface{}, 0) |
| 7263 | for _, item := range m.Security { |
| 7264 | items = append(items, item.ToRawInfo()) |
| 7265 | } |
| 7266 | info = append(info, yaml.MapItem{Key: "security", Value: items}) |
| 7267 | } |
| 7268 | // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 7269 | if m.SecurityDefinitions != nil { |
| 7270 | info = append(info, yaml.MapItem{Key: "securityDefinitions", Value: m.SecurityDefinitions.ToRawInfo()}) |
| 7271 | } |
| 7272 | // &{Name:securityDefinitions Type:SecurityDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7273 | if len(m.Tags) != 0 { |
| 7274 | items := make([]interface{}, 0) |
| 7275 | for _, item := range m.Tags { |
| 7276 | items = append(items, item.ToRawInfo()) |
| 7277 | } |
| 7278 | info = append(info, yaml.MapItem{Key: "tags", Value: items}) |
| 7279 | } |
| 7280 | // &{Name:tags Type:Tag StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 7281 | if m.ExternalDocs != nil { |
| 7282 | info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) |
| 7283 | } |
| 7284 | // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7285 | if m.VendorExtension != nil { |
| 7286 | for _, item := range m.VendorExtension { |
| 7287 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7288 | } |
| 7289 | } |
| 7290 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7291 | return info |
| 7292 | } |
| 7293 | |
| 7294 | // ToRawInfo returns a description of Examples suitable for JSON or YAML export. |
| 7295 | func (m *Examples) ToRawInfo() interface{} { |
| 7296 | info := yaml.MapSlice{} |
| 7297 | if m.AdditionalProperties != nil { |
| 7298 | for _, item := range m.AdditionalProperties { |
| 7299 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7300 | } |
| 7301 | } |
| 7302 | // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:} |
| 7303 | return info |
| 7304 | } |
| 7305 | |
| 7306 | // ToRawInfo returns a description of ExternalDocs suitable for JSON or YAML export. |
| 7307 | func (m *ExternalDocs) ToRawInfo() interface{} { |
| 7308 | info := yaml.MapSlice{} |
| 7309 | if m.Description != "" { |
| 7310 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7311 | } |
| 7312 | if m.Url != "" { |
| 7313 | info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) |
| 7314 | } |
| 7315 | if m.VendorExtension != nil { |
| 7316 | for _, item := range m.VendorExtension { |
| 7317 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7318 | } |
| 7319 | } |
| 7320 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7321 | return info |
| 7322 | } |
| 7323 | |
| 7324 | // ToRawInfo returns a description of FileSchema suitable for JSON or YAML export. |
| 7325 | func (m *FileSchema) ToRawInfo() interface{} { |
| 7326 | info := yaml.MapSlice{} |
| 7327 | if m.Format != "" { |
| 7328 | info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) |
| 7329 | } |
| 7330 | if m.Title != "" { |
| 7331 | info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) |
| 7332 | } |
| 7333 | if m.Description != "" { |
| 7334 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7335 | } |
| 7336 | if m.Default != nil { |
| 7337 | info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) |
| 7338 | } |
| 7339 | // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7340 | if len(m.Required) != 0 { |
| 7341 | info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) |
| 7342 | } |
| 7343 | if m.Type != "" { |
| 7344 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7345 | } |
| 7346 | if m.ReadOnly != false { |
| 7347 | info = append(info, yaml.MapItem{Key: "readOnly", Value: m.ReadOnly}) |
| 7348 | } |
| 7349 | if m.ExternalDocs != nil { |
| 7350 | info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) |
| 7351 | } |
| 7352 | // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7353 | if m.Example != nil { |
| 7354 | info = append(info, yaml.MapItem{Key: "example", Value: m.Example.ToRawInfo()}) |
| 7355 | } |
| 7356 | // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7357 | if m.VendorExtension != nil { |
| 7358 | for _, item := range m.VendorExtension { |
| 7359 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7360 | } |
| 7361 | } |
| 7362 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7363 | return info |
| 7364 | } |
| 7365 | |
| 7366 | // ToRawInfo returns a description of FormDataParameterSubSchema suitable for JSON or YAML export. |
| 7367 | func (m *FormDataParameterSubSchema) ToRawInfo() interface{} { |
| 7368 | info := yaml.MapSlice{} |
| 7369 | if m.Required != false { |
| 7370 | info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) |
| 7371 | } |
| 7372 | if m.In != "" { |
| 7373 | info = append(info, yaml.MapItem{Key: "in", Value: m.In}) |
| 7374 | } |
| 7375 | if m.Description != "" { |
| 7376 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7377 | } |
| 7378 | if m.Name != "" { |
| 7379 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7380 | } |
| 7381 | if m.AllowEmptyValue != false { |
| 7382 | info = append(info, yaml.MapItem{Key: "allowEmptyValue", Value: m.AllowEmptyValue}) |
| 7383 | } |
| 7384 | if m.Type != "" { |
| 7385 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7386 | } |
| 7387 | if m.Format != "" { |
| 7388 | info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) |
| 7389 | } |
| 7390 | if m.Items != nil { |
| 7391 | info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) |
| 7392 | } |
| 7393 | // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7394 | if m.CollectionFormat != "" { |
| 7395 | info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) |
| 7396 | } |
| 7397 | if m.Default != nil { |
| 7398 | info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) |
| 7399 | } |
| 7400 | // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7401 | if m.Maximum != 0.0 { |
| 7402 | info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) |
| 7403 | } |
| 7404 | if m.ExclusiveMaximum != false { |
| 7405 | info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) |
| 7406 | } |
| 7407 | if m.Minimum != 0.0 { |
| 7408 | info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) |
| 7409 | } |
| 7410 | if m.ExclusiveMinimum != false { |
| 7411 | info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) |
| 7412 | } |
| 7413 | if m.MaxLength != 0 { |
| 7414 | info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) |
| 7415 | } |
| 7416 | if m.MinLength != 0 { |
| 7417 | info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) |
| 7418 | } |
| 7419 | if m.Pattern != "" { |
| 7420 | info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) |
| 7421 | } |
| 7422 | if m.MaxItems != 0 { |
| 7423 | info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) |
| 7424 | } |
| 7425 | if m.MinItems != 0 { |
| 7426 | info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) |
| 7427 | } |
| 7428 | if m.UniqueItems != false { |
| 7429 | info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) |
| 7430 | } |
| 7431 | if len(m.Enum) != 0 { |
| 7432 | items := make([]interface{}, 0) |
| 7433 | for _, item := range m.Enum { |
| 7434 | items = append(items, item.ToRawInfo()) |
| 7435 | } |
| 7436 | info = append(info, yaml.MapItem{Key: "enum", Value: items}) |
| 7437 | } |
| 7438 | // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 7439 | if m.MultipleOf != 0.0 { |
| 7440 | info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) |
| 7441 | } |
| 7442 | if m.VendorExtension != nil { |
| 7443 | for _, item := range m.VendorExtension { |
| 7444 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7445 | } |
| 7446 | } |
| 7447 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7448 | return info |
| 7449 | } |
| 7450 | |
| 7451 | // ToRawInfo returns a description of Header suitable for JSON or YAML export. |
| 7452 | func (m *Header) ToRawInfo() interface{} { |
| 7453 | info := yaml.MapSlice{} |
| 7454 | if m.Type != "" { |
| 7455 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7456 | } |
| 7457 | if m.Format != "" { |
| 7458 | info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) |
| 7459 | } |
| 7460 | if m.Items != nil { |
| 7461 | info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) |
| 7462 | } |
| 7463 | // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7464 | if m.CollectionFormat != "" { |
| 7465 | info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) |
| 7466 | } |
| 7467 | if m.Default != nil { |
| 7468 | info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) |
| 7469 | } |
| 7470 | // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7471 | if m.Maximum != 0.0 { |
| 7472 | info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) |
| 7473 | } |
| 7474 | if m.ExclusiveMaximum != false { |
| 7475 | info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) |
| 7476 | } |
| 7477 | if m.Minimum != 0.0 { |
| 7478 | info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) |
| 7479 | } |
| 7480 | if m.ExclusiveMinimum != false { |
| 7481 | info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) |
| 7482 | } |
| 7483 | if m.MaxLength != 0 { |
| 7484 | info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) |
| 7485 | } |
| 7486 | if m.MinLength != 0 { |
| 7487 | info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) |
| 7488 | } |
| 7489 | if m.Pattern != "" { |
| 7490 | info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) |
| 7491 | } |
| 7492 | if m.MaxItems != 0 { |
| 7493 | info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) |
| 7494 | } |
| 7495 | if m.MinItems != 0 { |
| 7496 | info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) |
| 7497 | } |
| 7498 | if m.UniqueItems != false { |
| 7499 | info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) |
| 7500 | } |
| 7501 | if len(m.Enum) != 0 { |
| 7502 | items := make([]interface{}, 0) |
| 7503 | for _, item := range m.Enum { |
| 7504 | items = append(items, item.ToRawInfo()) |
| 7505 | } |
| 7506 | info = append(info, yaml.MapItem{Key: "enum", Value: items}) |
| 7507 | } |
| 7508 | // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 7509 | if m.MultipleOf != 0.0 { |
| 7510 | info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) |
| 7511 | } |
| 7512 | if m.Description != "" { |
| 7513 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7514 | } |
| 7515 | if m.VendorExtension != nil { |
| 7516 | for _, item := range m.VendorExtension { |
| 7517 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7518 | } |
| 7519 | } |
| 7520 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7521 | return info |
| 7522 | } |
| 7523 | |
| 7524 | // ToRawInfo returns a description of HeaderParameterSubSchema suitable for JSON or YAML export. |
| 7525 | func (m *HeaderParameterSubSchema) ToRawInfo() interface{} { |
| 7526 | info := yaml.MapSlice{} |
| 7527 | if m.Required != false { |
| 7528 | info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) |
| 7529 | } |
| 7530 | if m.In != "" { |
| 7531 | info = append(info, yaml.MapItem{Key: "in", Value: m.In}) |
| 7532 | } |
| 7533 | if m.Description != "" { |
| 7534 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7535 | } |
| 7536 | if m.Name != "" { |
| 7537 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7538 | } |
| 7539 | if m.Type != "" { |
| 7540 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7541 | } |
| 7542 | if m.Format != "" { |
| 7543 | info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) |
| 7544 | } |
| 7545 | if m.Items != nil { |
| 7546 | info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) |
| 7547 | } |
| 7548 | // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7549 | if m.CollectionFormat != "" { |
| 7550 | info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) |
| 7551 | } |
| 7552 | if m.Default != nil { |
| 7553 | info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) |
| 7554 | } |
| 7555 | // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7556 | if m.Maximum != 0.0 { |
| 7557 | info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) |
| 7558 | } |
| 7559 | if m.ExclusiveMaximum != false { |
| 7560 | info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) |
| 7561 | } |
| 7562 | if m.Minimum != 0.0 { |
| 7563 | info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) |
| 7564 | } |
| 7565 | if m.ExclusiveMinimum != false { |
| 7566 | info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) |
| 7567 | } |
| 7568 | if m.MaxLength != 0 { |
| 7569 | info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) |
| 7570 | } |
| 7571 | if m.MinLength != 0 { |
| 7572 | info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) |
| 7573 | } |
| 7574 | if m.Pattern != "" { |
| 7575 | info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) |
| 7576 | } |
| 7577 | if m.MaxItems != 0 { |
| 7578 | info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) |
| 7579 | } |
| 7580 | if m.MinItems != 0 { |
| 7581 | info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) |
| 7582 | } |
| 7583 | if m.UniqueItems != false { |
| 7584 | info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) |
| 7585 | } |
| 7586 | if len(m.Enum) != 0 { |
| 7587 | items := make([]interface{}, 0) |
| 7588 | for _, item := range m.Enum { |
| 7589 | items = append(items, item.ToRawInfo()) |
| 7590 | } |
| 7591 | info = append(info, yaml.MapItem{Key: "enum", Value: items}) |
| 7592 | } |
| 7593 | // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 7594 | if m.MultipleOf != 0.0 { |
| 7595 | info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) |
| 7596 | } |
| 7597 | if m.VendorExtension != nil { |
| 7598 | for _, item := range m.VendorExtension { |
| 7599 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7600 | } |
| 7601 | } |
| 7602 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7603 | return info |
| 7604 | } |
| 7605 | |
| 7606 | // ToRawInfo returns a description of Headers suitable for JSON or YAML export. |
| 7607 | func (m *Headers) ToRawInfo() interface{} { |
| 7608 | info := yaml.MapSlice{} |
| 7609 | if m.AdditionalProperties != nil { |
| 7610 | for _, item := range m.AdditionalProperties { |
| 7611 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7612 | } |
| 7613 | } |
| 7614 | // &{Name:additionalProperties Type:NamedHeader StringEnumValues:[] MapType:Header Repeated:true Pattern: Implicit:true Description:} |
| 7615 | return info |
| 7616 | } |
| 7617 | |
| 7618 | // ToRawInfo returns a description of Info suitable for JSON or YAML export. |
| 7619 | func (m *Info) ToRawInfo() interface{} { |
| 7620 | info := yaml.MapSlice{} |
| 7621 | if m.Title != "" { |
| 7622 | info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) |
| 7623 | } |
| 7624 | if m.Version != "" { |
| 7625 | info = append(info, yaml.MapItem{Key: "version", Value: m.Version}) |
| 7626 | } |
| 7627 | if m.Description != "" { |
| 7628 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7629 | } |
| 7630 | if m.TermsOfService != "" { |
| 7631 | info = append(info, yaml.MapItem{Key: "termsOfService", Value: m.TermsOfService}) |
| 7632 | } |
| 7633 | if m.Contact != nil { |
| 7634 | info = append(info, yaml.MapItem{Key: "contact", Value: m.Contact.ToRawInfo()}) |
| 7635 | } |
| 7636 | // &{Name:contact Type:Contact StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7637 | if m.License != nil { |
| 7638 | info = append(info, yaml.MapItem{Key: "license", Value: m.License.ToRawInfo()}) |
| 7639 | } |
| 7640 | // &{Name:license Type:License StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7641 | if m.VendorExtension != nil { |
| 7642 | for _, item := range m.VendorExtension { |
| 7643 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7644 | } |
| 7645 | } |
| 7646 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7647 | return info |
| 7648 | } |
| 7649 | |
| 7650 | // ToRawInfo returns a description of ItemsItem suitable for JSON or YAML export. |
| 7651 | func (m *ItemsItem) ToRawInfo() interface{} { |
| 7652 | info := yaml.MapSlice{} |
| 7653 | if len(m.Schema) != 0 { |
| 7654 | items := make([]interface{}, 0) |
| 7655 | for _, item := range m.Schema { |
| 7656 | items = append(items, item.ToRawInfo()) |
| 7657 | } |
| 7658 | info = append(info, yaml.MapItem{Key: "schema", Value: items}) |
| 7659 | } |
| 7660 | // &{Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 7661 | return info |
| 7662 | } |
| 7663 | |
| 7664 | // ToRawInfo returns a description of JsonReference suitable for JSON or YAML export. |
| 7665 | func (m *JsonReference) ToRawInfo() interface{} { |
| 7666 | info := yaml.MapSlice{} |
| 7667 | if m.XRef != "" { |
| 7668 | info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) |
| 7669 | } |
| 7670 | if m.Description != "" { |
| 7671 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7672 | } |
| 7673 | return info |
| 7674 | } |
| 7675 | |
| 7676 | // ToRawInfo returns a description of License suitable for JSON or YAML export. |
| 7677 | func (m *License) ToRawInfo() interface{} { |
| 7678 | info := yaml.MapSlice{} |
| 7679 | if m.Name != "" { |
| 7680 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7681 | } |
| 7682 | if m.Url != "" { |
| 7683 | info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) |
| 7684 | } |
| 7685 | if m.VendorExtension != nil { |
| 7686 | for _, item := range m.VendorExtension { |
| 7687 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7688 | } |
| 7689 | } |
| 7690 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7691 | return info |
| 7692 | } |
| 7693 | |
| 7694 | // ToRawInfo returns a description of NamedAny suitable for JSON or YAML export. |
| 7695 | func (m *NamedAny) ToRawInfo() interface{} { |
| 7696 | info := yaml.MapSlice{} |
| 7697 | if m.Name != "" { |
| 7698 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7699 | } |
| 7700 | // &{Name:value Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7701 | return info |
| 7702 | } |
| 7703 | |
| 7704 | // ToRawInfo returns a description of NamedHeader suitable for JSON or YAML export. |
| 7705 | func (m *NamedHeader) ToRawInfo() interface{} { |
| 7706 | info := yaml.MapSlice{} |
| 7707 | if m.Name != "" { |
| 7708 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7709 | } |
| 7710 | // &{Name:value Type:Header StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7711 | return info |
| 7712 | } |
| 7713 | |
| 7714 | // ToRawInfo returns a description of NamedParameter suitable for JSON or YAML export. |
| 7715 | func (m *NamedParameter) ToRawInfo() interface{} { |
| 7716 | info := yaml.MapSlice{} |
| 7717 | if m.Name != "" { |
| 7718 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7719 | } |
| 7720 | // &{Name:value Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7721 | return info |
| 7722 | } |
| 7723 | |
| 7724 | // ToRawInfo returns a description of NamedPathItem suitable for JSON or YAML export. |
| 7725 | func (m *NamedPathItem) ToRawInfo() interface{} { |
| 7726 | info := yaml.MapSlice{} |
| 7727 | if m.Name != "" { |
| 7728 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7729 | } |
| 7730 | // &{Name:value Type:PathItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7731 | return info |
| 7732 | } |
| 7733 | |
| 7734 | // ToRawInfo returns a description of NamedResponse suitable for JSON or YAML export. |
| 7735 | func (m *NamedResponse) ToRawInfo() interface{} { |
| 7736 | info := yaml.MapSlice{} |
| 7737 | if m.Name != "" { |
| 7738 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7739 | } |
| 7740 | // &{Name:value Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7741 | return info |
| 7742 | } |
| 7743 | |
| 7744 | // ToRawInfo returns a description of NamedResponseValue suitable for JSON or YAML export. |
| 7745 | func (m *NamedResponseValue) ToRawInfo() interface{} { |
| 7746 | info := yaml.MapSlice{} |
| 7747 | if m.Name != "" { |
| 7748 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7749 | } |
| 7750 | // &{Name:value Type:ResponseValue StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7751 | return info |
| 7752 | } |
| 7753 | |
| 7754 | // ToRawInfo returns a description of NamedSchema suitable for JSON or YAML export. |
| 7755 | func (m *NamedSchema) ToRawInfo() interface{} { |
| 7756 | info := yaml.MapSlice{} |
| 7757 | if m.Name != "" { |
| 7758 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7759 | } |
| 7760 | // &{Name:value Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7761 | return info |
| 7762 | } |
| 7763 | |
| 7764 | // ToRawInfo returns a description of NamedSecurityDefinitionsItem suitable for JSON or YAML export. |
| 7765 | func (m *NamedSecurityDefinitionsItem) ToRawInfo() interface{} { |
| 7766 | info := yaml.MapSlice{} |
| 7767 | if m.Name != "" { |
| 7768 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7769 | } |
| 7770 | // &{Name:value Type:SecurityDefinitionsItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7771 | return info |
| 7772 | } |
| 7773 | |
| 7774 | // ToRawInfo returns a description of NamedString suitable for JSON or YAML export. |
| 7775 | func (m *NamedString) ToRawInfo() interface{} { |
| 7776 | info := yaml.MapSlice{} |
| 7777 | if m.Name != "" { |
| 7778 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7779 | } |
| 7780 | if m.Value != "" { |
| 7781 | info = append(info, yaml.MapItem{Key: "value", Value: m.Value}) |
| 7782 | } |
| 7783 | return info |
| 7784 | } |
| 7785 | |
| 7786 | // ToRawInfo returns a description of NamedStringArray suitable for JSON or YAML export. |
| 7787 | func (m *NamedStringArray) ToRawInfo() interface{} { |
| 7788 | info := yaml.MapSlice{} |
| 7789 | if m.Name != "" { |
| 7790 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 7791 | } |
| 7792 | // &{Name:value Type:StringArray StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 7793 | return info |
| 7794 | } |
| 7795 | |
| 7796 | // ToRawInfo returns a description of NonBodyParameter suitable for JSON or YAML export. |
| 7797 | func (m *NonBodyParameter) ToRawInfo() interface{} { |
| 7798 | // ONE OF WRAPPER |
| 7799 | // NonBodyParameter |
| 7800 | // {Name:headerParameterSubSchema Type:HeaderParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7801 | v0 := m.GetHeaderParameterSubSchema() |
| 7802 | if v0 != nil { |
| 7803 | return v0.ToRawInfo() |
| 7804 | } |
| 7805 | // {Name:formDataParameterSubSchema Type:FormDataParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7806 | v1 := m.GetFormDataParameterSubSchema() |
| 7807 | if v1 != nil { |
| 7808 | return v1.ToRawInfo() |
| 7809 | } |
| 7810 | // {Name:queryParameterSubSchema Type:QueryParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7811 | v2 := m.GetQueryParameterSubSchema() |
| 7812 | if v2 != nil { |
| 7813 | return v2.ToRawInfo() |
| 7814 | } |
| 7815 | // {Name:pathParameterSubSchema Type:PathParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7816 | v3 := m.GetPathParameterSubSchema() |
| 7817 | if v3 != nil { |
| 7818 | return v3.ToRawInfo() |
| 7819 | } |
| 7820 | return nil |
| 7821 | } |
| 7822 | |
| 7823 | // ToRawInfo returns a description of Oauth2AccessCodeSecurity suitable for JSON or YAML export. |
| 7824 | func (m *Oauth2AccessCodeSecurity) ToRawInfo() interface{} { |
| 7825 | info := yaml.MapSlice{} |
| 7826 | if m.Type != "" { |
| 7827 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7828 | } |
| 7829 | if m.Flow != "" { |
| 7830 | info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow}) |
| 7831 | } |
| 7832 | if m.Scopes != nil { |
| 7833 | info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) |
| 7834 | } |
| 7835 | // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7836 | if m.AuthorizationUrl != "" { |
| 7837 | info = append(info, yaml.MapItem{Key: "authorizationUrl", Value: m.AuthorizationUrl}) |
| 7838 | } |
| 7839 | if m.TokenUrl != "" { |
| 7840 | info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl}) |
| 7841 | } |
| 7842 | if m.Description != "" { |
| 7843 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7844 | } |
| 7845 | if m.VendorExtension != nil { |
| 7846 | for _, item := range m.VendorExtension { |
| 7847 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7848 | } |
| 7849 | } |
| 7850 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7851 | return info |
| 7852 | } |
| 7853 | |
| 7854 | // ToRawInfo returns a description of Oauth2ApplicationSecurity suitable for JSON or YAML export. |
| 7855 | func (m *Oauth2ApplicationSecurity) ToRawInfo() interface{} { |
| 7856 | info := yaml.MapSlice{} |
| 7857 | if m.Type != "" { |
| 7858 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7859 | } |
| 7860 | if m.Flow != "" { |
| 7861 | info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow}) |
| 7862 | } |
| 7863 | if m.Scopes != nil { |
| 7864 | info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) |
| 7865 | } |
| 7866 | // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7867 | if m.TokenUrl != "" { |
| 7868 | info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl}) |
| 7869 | } |
| 7870 | if m.Description != "" { |
| 7871 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7872 | } |
| 7873 | if m.VendorExtension != nil { |
| 7874 | for _, item := range m.VendorExtension { |
| 7875 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7876 | } |
| 7877 | } |
| 7878 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7879 | return info |
| 7880 | } |
| 7881 | |
| 7882 | // ToRawInfo returns a description of Oauth2ImplicitSecurity suitable for JSON or YAML export. |
| 7883 | func (m *Oauth2ImplicitSecurity) ToRawInfo() interface{} { |
| 7884 | info := yaml.MapSlice{} |
| 7885 | if m.Type != "" { |
| 7886 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7887 | } |
| 7888 | if m.Flow != "" { |
| 7889 | info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow}) |
| 7890 | } |
| 7891 | if m.Scopes != nil { |
| 7892 | info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) |
| 7893 | } |
| 7894 | // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7895 | if m.AuthorizationUrl != "" { |
| 7896 | info = append(info, yaml.MapItem{Key: "authorizationUrl", Value: m.AuthorizationUrl}) |
| 7897 | } |
| 7898 | if m.Description != "" { |
| 7899 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7900 | } |
| 7901 | if m.VendorExtension != nil { |
| 7902 | for _, item := range m.VendorExtension { |
| 7903 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7904 | } |
| 7905 | } |
| 7906 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7907 | return info |
| 7908 | } |
| 7909 | |
| 7910 | // ToRawInfo returns a description of Oauth2PasswordSecurity suitable for JSON or YAML export. |
| 7911 | func (m *Oauth2PasswordSecurity) ToRawInfo() interface{} { |
| 7912 | info := yaml.MapSlice{} |
| 7913 | if m.Type != "" { |
| 7914 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 7915 | } |
| 7916 | if m.Flow != "" { |
| 7917 | info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow}) |
| 7918 | } |
| 7919 | if m.Scopes != nil { |
| 7920 | info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) |
| 7921 | } |
| 7922 | // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7923 | if m.TokenUrl != "" { |
| 7924 | info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl}) |
| 7925 | } |
| 7926 | if m.Description != "" { |
| 7927 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7928 | } |
| 7929 | if m.VendorExtension != nil { |
| 7930 | for _, item := range m.VendorExtension { |
| 7931 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7932 | } |
| 7933 | } |
| 7934 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 7935 | return info |
| 7936 | } |
| 7937 | |
| 7938 | // ToRawInfo returns a description of Oauth2Scopes suitable for JSON or YAML export. |
| 7939 | func (m *Oauth2Scopes) ToRawInfo() interface{} { |
| 7940 | info := yaml.MapSlice{} |
| 7941 | // &{Name:additionalProperties Type:NamedString StringEnumValues:[] MapType:string Repeated:true Pattern: Implicit:true Description:} |
| 7942 | return info |
| 7943 | } |
| 7944 | |
| 7945 | // ToRawInfo returns a description of Operation suitable for JSON or YAML export. |
| 7946 | func (m *Operation) ToRawInfo() interface{} { |
| 7947 | info := yaml.MapSlice{} |
| 7948 | if len(m.Tags) != 0 { |
| 7949 | info = append(info, yaml.MapItem{Key: "tags", Value: m.Tags}) |
| 7950 | } |
| 7951 | if m.Summary != "" { |
| 7952 | info = append(info, yaml.MapItem{Key: "summary", Value: m.Summary}) |
| 7953 | } |
| 7954 | if m.Description != "" { |
| 7955 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 7956 | } |
| 7957 | if m.ExternalDocs != nil { |
| 7958 | info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) |
| 7959 | } |
| 7960 | // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7961 | if m.OperationId != "" { |
| 7962 | info = append(info, yaml.MapItem{Key: "operationId", Value: m.OperationId}) |
| 7963 | } |
| 7964 | if len(m.Produces) != 0 { |
| 7965 | info = append(info, yaml.MapItem{Key: "produces", Value: m.Produces}) |
| 7966 | } |
| 7967 | if len(m.Consumes) != 0 { |
| 7968 | info = append(info, yaml.MapItem{Key: "consumes", Value: m.Consumes}) |
| 7969 | } |
| 7970 | if len(m.Parameters) != 0 { |
| 7971 | items := make([]interface{}, 0) |
| 7972 | for _, item := range m.Parameters { |
| 7973 | items = append(items, item.ToRawInfo()) |
| 7974 | } |
| 7975 | info = append(info, yaml.MapItem{Key: "parameters", Value: items}) |
| 7976 | } |
| 7977 | // &{Name:parameters Type:ParametersItem StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:The parameters needed to send a valid API call.} |
| 7978 | if m.Responses != nil { |
| 7979 | info = append(info, yaml.MapItem{Key: "responses", Value: m.Responses.ToRawInfo()}) |
| 7980 | } |
| 7981 | // &{Name:responses Type:Responses StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 7982 | if len(m.Schemes) != 0 { |
| 7983 | info = append(info, yaml.MapItem{Key: "schemes", Value: m.Schemes}) |
| 7984 | } |
| 7985 | if m.Deprecated != false { |
| 7986 | info = append(info, yaml.MapItem{Key: "deprecated", Value: m.Deprecated}) |
| 7987 | } |
| 7988 | if len(m.Security) != 0 { |
| 7989 | items := make([]interface{}, 0) |
| 7990 | for _, item := range m.Security { |
| 7991 | items = append(items, item.ToRawInfo()) |
| 7992 | } |
| 7993 | info = append(info, yaml.MapItem{Key: "security", Value: items}) |
| 7994 | } |
| 7995 | // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 7996 | if m.VendorExtension != nil { |
| 7997 | for _, item := range m.VendorExtension { |
| 7998 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 7999 | } |
| 8000 | } |
| 8001 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8002 | return info |
| 8003 | } |
| 8004 | |
| 8005 | // ToRawInfo returns a description of Parameter suitable for JSON or YAML export. |
| 8006 | func (m *Parameter) ToRawInfo() interface{} { |
| 8007 | // ONE OF WRAPPER |
| 8008 | // Parameter |
| 8009 | // {Name:bodyParameter Type:BodyParameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8010 | v0 := m.GetBodyParameter() |
| 8011 | if v0 != nil { |
| 8012 | return v0.ToRawInfo() |
| 8013 | } |
| 8014 | // {Name:nonBodyParameter Type:NonBodyParameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8015 | v1 := m.GetNonBodyParameter() |
| 8016 | if v1 != nil { |
| 8017 | return v1.ToRawInfo() |
| 8018 | } |
| 8019 | return nil |
| 8020 | } |
| 8021 | |
| 8022 | // ToRawInfo returns a description of ParameterDefinitions suitable for JSON or YAML export. |
| 8023 | func (m *ParameterDefinitions) ToRawInfo() interface{} { |
| 8024 | info := yaml.MapSlice{} |
| 8025 | if m.AdditionalProperties != nil { |
| 8026 | for _, item := range m.AdditionalProperties { |
| 8027 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8028 | } |
| 8029 | } |
| 8030 | // &{Name:additionalProperties Type:NamedParameter StringEnumValues:[] MapType:Parameter Repeated:true Pattern: Implicit:true Description:} |
| 8031 | return info |
| 8032 | } |
| 8033 | |
| 8034 | // ToRawInfo returns a description of ParametersItem suitable for JSON or YAML export. |
| 8035 | func (m *ParametersItem) ToRawInfo() interface{} { |
| 8036 | // ONE OF WRAPPER |
| 8037 | // ParametersItem |
| 8038 | // {Name:parameter Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8039 | v0 := m.GetParameter() |
| 8040 | if v0 != nil { |
| 8041 | return v0.ToRawInfo() |
| 8042 | } |
| 8043 | // {Name:jsonReference Type:JsonReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8044 | v1 := m.GetJsonReference() |
| 8045 | if v1 != nil { |
| 8046 | return v1.ToRawInfo() |
| 8047 | } |
| 8048 | return nil |
| 8049 | } |
| 8050 | |
| 8051 | // ToRawInfo returns a description of PathItem suitable for JSON or YAML export. |
| 8052 | func (m *PathItem) ToRawInfo() interface{} { |
| 8053 | info := yaml.MapSlice{} |
| 8054 | if m.XRef != "" { |
| 8055 | info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) |
| 8056 | } |
| 8057 | if m.Get != nil { |
| 8058 | info = append(info, yaml.MapItem{Key: "get", Value: m.Get.ToRawInfo()}) |
| 8059 | } |
| 8060 | // &{Name:get Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8061 | if m.Put != nil { |
| 8062 | info = append(info, yaml.MapItem{Key: "put", Value: m.Put.ToRawInfo()}) |
| 8063 | } |
| 8064 | // &{Name:put Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8065 | if m.Post != nil { |
| 8066 | info = append(info, yaml.MapItem{Key: "post", Value: m.Post.ToRawInfo()}) |
| 8067 | } |
| 8068 | // &{Name:post Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8069 | if m.Delete != nil { |
| 8070 | info = append(info, yaml.MapItem{Key: "delete", Value: m.Delete.ToRawInfo()}) |
| 8071 | } |
| 8072 | // &{Name:delete Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8073 | if m.Options != nil { |
| 8074 | info = append(info, yaml.MapItem{Key: "options", Value: m.Options.ToRawInfo()}) |
| 8075 | } |
| 8076 | // &{Name:options Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8077 | if m.Head != nil { |
| 8078 | info = append(info, yaml.MapItem{Key: "head", Value: m.Head.ToRawInfo()}) |
| 8079 | } |
| 8080 | // &{Name:head Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8081 | if m.Patch != nil { |
| 8082 | info = append(info, yaml.MapItem{Key: "patch", Value: m.Patch.ToRawInfo()}) |
| 8083 | } |
| 8084 | // &{Name:patch Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8085 | if len(m.Parameters) != 0 { |
| 8086 | items := make([]interface{}, 0) |
| 8087 | for _, item := range m.Parameters { |
| 8088 | items = append(items, item.ToRawInfo()) |
| 8089 | } |
| 8090 | info = append(info, yaml.MapItem{Key: "parameters", Value: items}) |
| 8091 | } |
| 8092 | // &{Name:parameters Type:ParametersItem StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:The parameters needed to send a valid API call.} |
| 8093 | if m.VendorExtension != nil { |
| 8094 | for _, item := range m.VendorExtension { |
| 8095 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8096 | } |
| 8097 | } |
| 8098 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8099 | return info |
| 8100 | } |
| 8101 | |
| 8102 | // ToRawInfo returns a description of PathParameterSubSchema suitable for JSON or YAML export. |
| 8103 | func (m *PathParameterSubSchema) ToRawInfo() interface{} { |
| 8104 | info := yaml.MapSlice{} |
| 8105 | if m.Required != false { |
| 8106 | info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) |
| 8107 | } |
| 8108 | if m.In != "" { |
| 8109 | info = append(info, yaml.MapItem{Key: "in", Value: m.In}) |
| 8110 | } |
| 8111 | if m.Description != "" { |
| 8112 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 8113 | } |
| 8114 | if m.Name != "" { |
| 8115 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 8116 | } |
| 8117 | if m.Type != "" { |
| 8118 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 8119 | } |
| 8120 | if m.Format != "" { |
| 8121 | info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) |
| 8122 | } |
| 8123 | if m.Items != nil { |
| 8124 | info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) |
| 8125 | } |
| 8126 | // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8127 | if m.CollectionFormat != "" { |
| 8128 | info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) |
| 8129 | } |
| 8130 | if m.Default != nil { |
| 8131 | info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) |
| 8132 | } |
| 8133 | // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8134 | if m.Maximum != 0.0 { |
| 8135 | info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) |
| 8136 | } |
| 8137 | if m.ExclusiveMaximum != false { |
| 8138 | info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) |
| 8139 | } |
| 8140 | if m.Minimum != 0.0 { |
| 8141 | info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) |
| 8142 | } |
| 8143 | if m.ExclusiveMinimum != false { |
| 8144 | info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) |
| 8145 | } |
| 8146 | if m.MaxLength != 0 { |
| 8147 | info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) |
| 8148 | } |
| 8149 | if m.MinLength != 0 { |
| 8150 | info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) |
| 8151 | } |
| 8152 | if m.Pattern != "" { |
| 8153 | info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) |
| 8154 | } |
| 8155 | if m.MaxItems != 0 { |
| 8156 | info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) |
| 8157 | } |
| 8158 | if m.MinItems != 0 { |
| 8159 | info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) |
| 8160 | } |
| 8161 | if m.UniqueItems != false { |
| 8162 | info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) |
| 8163 | } |
| 8164 | if len(m.Enum) != 0 { |
| 8165 | items := make([]interface{}, 0) |
| 8166 | for _, item := range m.Enum { |
| 8167 | items = append(items, item.ToRawInfo()) |
| 8168 | } |
| 8169 | info = append(info, yaml.MapItem{Key: "enum", Value: items}) |
| 8170 | } |
| 8171 | // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 8172 | if m.MultipleOf != 0.0 { |
| 8173 | info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) |
| 8174 | } |
| 8175 | if m.VendorExtension != nil { |
| 8176 | for _, item := range m.VendorExtension { |
| 8177 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8178 | } |
| 8179 | } |
| 8180 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8181 | return info |
| 8182 | } |
| 8183 | |
| 8184 | // ToRawInfo returns a description of Paths suitable for JSON or YAML export. |
| 8185 | func (m *Paths) ToRawInfo() interface{} { |
| 8186 | info := yaml.MapSlice{} |
| 8187 | if m.VendorExtension != nil { |
| 8188 | for _, item := range m.VendorExtension { |
| 8189 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8190 | } |
| 8191 | } |
| 8192 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8193 | if m.Path != nil { |
| 8194 | for _, item := range m.Path { |
| 8195 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8196 | } |
| 8197 | } |
| 8198 | // &{Name:Path Type:NamedPathItem StringEnumValues:[] MapType:PathItem Repeated:true Pattern:^/ Implicit:true Description:} |
| 8199 | return info |
| 8200 | } |
| 8201 | |
| 8202 | // ToRawInfo returns a description of PrimitivesItems suitable for JSON or YAML export. |
| 8203 | func (m *PrimitivesItems) ToRawInfo() interface{} { |
| 8204 | info := yaml.MapSlice{} |
| 8205 | if m.Type != "" { |
| 8206 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 8207 | } |
| 8208 | if m.Format != "" { |
| 8209 | info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) |
| 8210 | } |
| 8211 | if m.Items != nil { |
| 8212 | info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) |
| 8213 | } |
| 8214 | // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8215 | if m.CollectionFormat != "" { |
| 8216 | info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) |
| 8217 | } |
| 8218 | if m.Default != nil { |
| 8219 | info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) |
| 8220 | } |
| 8221 | // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8222 | if m.Maximum != 0.0 { |
| 8223 | info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) |
| 8224 | } |
| 8225 | if m.ExclusiveMaximum != false { |
| 8226 | info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) |
| 8227 | } |
| 8228 | if m.Minimum != 0.0 { |
| 8229 | info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) |
| 8230 | } |
| 8231 | if m.ExclusiveMinimum != false { |
| 8232 | info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) |
| 8233 | } |
| 8234 | if m.MaxLength != 0 { |
| 8235 | info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) |
| 8236 | } |
| 8237 | if m.MinLength != 0 { |
| 8238 | info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) |
| 8239 | } |
| 8240 | if m.Pattern != "" { |
| 8241 | info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) |
| 8242 | } |
| 8243 | if m.MaxItems != 0 { |
| 8244 | info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) |
| 8245 | } |
| 8246 | if m.MinItems != 0 { |
| 8247 | info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) |
| 8248 | } |
| 8249 | if m.UniqueItems != false { |
| 8250 | info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) |
| 8251 | } |
| 8252 | if len(m.Enum) != 0 { |
| 8253 | items := make([]interface{}, 0) |
| 8254 | for _, item := range m.Enum { |
| 8255 | items = append(items, item.ToRawInfo()) |
| 8256 | } |
| 8257 | info = append(info, yaml.MapItem{Key: "enum", Value: items}) |
| 8258 | } |
| 8259 | // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 8260 | if m.MultipleOf != 0.0 { |
| 8261 | info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) |
| 8262 | } |
| 8263 | if m.VendorExtension != nil { |
| 8264 | for _, item := range m.VendorExtension { |
| 8265 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8266 | } |
| 8267 | } |
| 8268 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8269 | return info |
| 8270 | } |
| 8271 | |
| 8272 | // ToRawInfo returns a description of Properties suitable for JSON or YAML export. |
| 8273 | func (m *Properties) ToRawInfo() interface{} { |
| 8274 | info := yaml.MapSlice{} |
| 8275 | if m.AdditionalProperties != nil { |
| 8276 | for _, item := range m.AdditionalProperties { |
| 8277 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8278 | } |
| 8279 | } |
| 8280 | // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:} |
| 8281 | return info |
| 8282 | } |
| 8283 | |
| 8284 | // ToRawInfo returns a description of QueryParameterSubSchema suitable for JSON or YAML export. |
| 8285 | func (m *QueryParameterSubSchema) ToRawInfo() interface{} { |
| 8286 | info := yaml.MapSlice{} |
| 8287 | if m.Required != false { |
| 8288 | info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) |
| 8289 | } |
| 8290 | if m.In != "" { |
| 8291 | info = append(info, yaml.MapItem{Key: "in", Value: m.In}) |
| 8292 | } |
| 8293 | if m.Description != "" { |
| 8294 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 8295 | } |
| 8296 | if m.Name != "" { |
| 8297 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 8298 | } |
| 8299 | if m.AllowEmptyValue != false { |
| 8300 | info = append(info, yaml.MapItem{Key: "allowEmptyValue", Value: m.AllowEmptyValue}) |
| 8301 | } |
| 8302 | if m.Type != "" { |
| 8303 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) |
| 8304 | } |
| 8305 | if m.Format != "" { |
| 8306 | info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) |
| 8307 | } |
| 8308 | if m.Items != nil { |
| 8309 | info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) |
| 8310 | } |
| 8311 | // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8312 | if m.CollectionFormat != "" { |
| 8313 | info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) |
| 8314 | } |
| 8315 | if m.Default != nil { |
| 8316 | info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) |
| 8317 | } |
| 8318 | // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8319 | if m.Maximum != 0.0 { |
| 8320 | info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) |
| 8321 | } |
| 8322 | if m.ExclusiveMaximum != false { |
| 8323 | info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) |
| 8324 | } |
| 8325 | if m.Minimum != 0.0 { |
| 8326 | info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) |
| 8327 | } |
| 8328 | if m.ExclusiveMinimum != false { |
| 8329 | info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) |
| 8330 | } |
| 8331 | if m.MaxLength != 0 { |
| 8332 | info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) |
| 8333 | } |
| 8334 | if m.MinLength != 0 { |
| 8335 | info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) |
| 8336 | } |
| 8337 | if m.Pattern != "" { |
| 8338 | info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) |
| 8339 | } |
| 8340 | if m.MaxItems != 0 { |
| 8341 | info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) |
| 8342 | } |
| 8343 | if m.MinItems != 0 { |
| 8344 | info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) |
| 8345 | } |
| 8346 | if m.UniqueItems != false { |
| 8347 | info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) |
| 8348 | } |
| 8349 | if len(m.Enum) != 0 { |
| 8350 | items := make([]interface{}, 0) |
| 8351 | for _, item := range m.Enum { |
| 8352 | items = append(items, item.ToRawInfo()) |
| 8353 | } |
| 8354 | info = append(info, yaml.MapItem{Key: "enum", Value: items}) |
| 8355 | } |
| 8356 | // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 8357 | if m.MultipleOf != 0.0 { |
| 8358 | info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) |
| 8359 | } |
| 8360 | if m.VendorExtension != nil { |
| 8361 | for _, item := range m.VendorExtension { |
| 8362 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8363 | } |
| 8364 | } |
| 8365 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8366 | return info |
| 8367 | } |
| 8368 | |
| 8369 | // ToRawInfo returns a description of Response suitable for JSON or YAML export. |
| 8370 | func (m *Response) ToRawInfo() interface{} { |
| 8371 | info := yaml.MapSlice{} |
| 8372 | if m.Description != "" { |
| 8373 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 8374 | } |
| 8375 | if m.Schema != nil { |
| 8376 | info = append(info, yaml.MapItem{Key: "schema", Value: m.Schema.ToRawInfo()}) |
| 8377 | } |
| 8378 | // &{Name:schema Type:SchemaItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8379 | if m.Headers != nil { |
| 8380 | info = append(info, yaml.MapItem{Key: "headers", Value: m.Headers.ToRawInfo()}) |
| 8381 | } |
| 8382 | // &{Name:headers Type:Headers StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8383 | if m.Examples != nil { |
| 8384 | info = append(info, yaml.MapItem{Key: "examples", Value: m.Examples.ToRawInfo()}) |
| 8385 | } |
| 8386 | // &{Name:examples Type:Examples StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8387 | if m.VendorExtension != nil { |
| 8388 | for _, item := range m.VendorExtension { |
| 8389 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8390 | } |
| 8391 | } |
| 8392 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8393 | return info |
| 8394 | } |
| 8395 | |
| 8396 | // ToRawInfo returns a description of ResponseDefinitions suitable for JSON or YAML export. |
| 8397 | func (m *ResponseDefinitions) ToRawInfo() interface{} { |
| 8398 | info := yaml.MapSlice{} |
| 8399 | if m.AdditionalProperties != nil { |
| 8400 | for _, item := range m.AdditionalProperties { |
| 8401 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8402 | } |
| 8403 | } |
| 8404 | // &{Name:additionalProperties Type:NamedResponse StringEnumValues:[] MapType:Response Repeated:true Pattern: Implicit:true Description:} |
| 8405 | return info |
| 8406 | } |
| 8407 | |
| 8408 | // ToRawInfo returns a description of ResponseValue suitable for JSON or YAML export. |
| 8409 | func (m *ResponseValue) ToRawInfo() interface{} { |
| 8410 | // ONE OF WRAPPER |
| 8411 | // ResponseValue |
| 8412 | // {Name:response Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8413 | v0 := m.GetResponse() |
| 8414 | if v0 != nil { |
| 8415 | return v0.ToRawInfo() |
| 8416 | } |
| 8417 | // {Name:jsonReference Type:JsonReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8418 | v1 := m.GetJsonReference() |
| 8419 | if v1 != nil { |
| 8420 | return v1.ToRawInfo() |
| 8421 | } |
| 8422 | return nil |
| 8423 | } |
| 8424 | |
| 8425 | // ToRawInfo returns a description of Responses suitable for JSON or YAML export. |
| 8426 | func (m *Responses) ToRawInfo() interface{} { |
| 8427 | info := yaml.MapSlice{} |
| 8428 | if m.ResponseCode != nil { |
| 8429 | for _, item := range m.ResponseCode { |
| 8430 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8431 | } |
| 8432 | } |
| 8433 | // &{Name:ResponseCode Type:NamedResponseValue StringEnumValues:[] MapType:ResponseValue Repeated:true Pattern:^([0-9]{3})$|^(default)$ Implicit:true Description:} |
| 8434 | if m.VendorExtension != nil { |
| 8435 | for _, item := range m.VendorExtension { |
| 8436 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8437 | } |
| 8438 | } |
| 8439 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8440 | return info |
| 8441 | } |
| 8442 | |
| 8443 | // ToRawInfo returns a description of Schema suitable for JSON or YAML export. |
| 8444 | func (m *Schema) ToRawInfo() interface{} { |
| 8445 | info := yaml.MapSlice{} |
| 8446 | if m.XRef != "" { |
| 8447 | info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) |
| 8448 | } |
| 8449 | if m.Format != "" { |
| 8450 | info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) |
| 8451 | } |
| 8452 | if m.Title != "" { |
| 8453 | info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) |
| 8454 | } |
| 8455 | if m.Description != "" { |
| 8456 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 8457 | } |
| 8458 | if m.Default != nil { |
| 8459 | info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) |
| 8460 | } |
| 8461 | // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8462 | if m.MultipleOf != 0.0 { |
| 8463 | info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) |
| 8464 | } |
| 8465 | if m.Maximum != 0.0 { |
| 8466 | info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) |
| 8467 | } |
| 8468 | if m.ExclusiveMaximum != false { |
| 8469 | info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) |
| 8470 | } |
| 8471 | if m.Minimum != 0.0 { |
| 8472 | info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) |
| 8473 | } |
| 8474 | if m.ExclusiveMinimum != false { |
| 8475 | info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) |
| 8476 | } |
| 8477 | if m.MaxLength != 0 { |
| 8478 | info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) |
| 8479 | } |
| 8480 | if m.MinLength != 0 { |
| 8481 | info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) |
| 8482 | } |
| 8483 | if m.Pattern != "" { |
| 8484 | info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) |
| 8485 | } |
| 8486 | if m.MaxItems != 0 { |
| 8487 | info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) |
| 8488 | } |
| 8489 | if m.MinItems != 0 { |
| 8490 | info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) |
| 8491 | } |
| 8492 | if m.UniqueItems != false { |
| 8493 | info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) |
| 8494 | } |
| 8495 | if m.MaxProperties != 0 { |
| 8496 | info = append(info, yaml.MapItem{Key: "maxProperties", Value: m.MaxProperties}) |
| 8497 | } |
| 8498 | if m.MinProperties != 0 { |
| 8499 | info = append(info, yaml.MapItem{Key: "minProperties", Value: m.MinProperties}) |
| 8500 | } |
| 8501 | if len(m.Required) != 0 { |
| 8502 | info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) |
| 8503 | } |
| 8504 | if len(m.Enum) != 0 { |
| 8505 | items := make([]interface{}, 0) |
| 8506 | for _, item := range m.Enum { |
| 8507 | items = append(items, item.ToRawInfo()) |
| 8508 | } |
| 8509 | info = append(info, yaml.MapItem{Key: "enum", Value: items}) |
| 8510 | } |
| 8511 | // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 8512 | if m.AdditionalProperties != nil { |
| 8513 | info = append(info, yaml.MapItem{Key: "additionalProperties", Value: m.AdditionalProperties.ToRawInfo()}) |
| 8514 | } |
| 8515 | // &{Name:additionalProperties Type:AdditionalPropertiesItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8516 | if m.Type != nil { |
| 8517 | if len(m.Type.Value) == 1 { |
| 8518 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type.Value[0]}) |
| 8519 | } else { |
| 8520 | info = append(info, yaml.MapItem{Key: "type", Value: m.Type.Value}) |
| 8521 | } |
| 8522 | } |
| 8523 | // &{Name:type Type:TypeItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8524 | if m.Items != nil { |
| 8525 | items := make([]interface{}, 0) |
| 8526 | for _, item := range m.Items.Schema { |
| 8527 | items = append(items, item.ToRawInfo()) |
| 8528 | } |
| 8529 | info = append(info, yaml.MapItem{Key: "items", Value: items[0]}) |
| 8530 | } |
| 8531 | // &{Name:items Type:ItemsItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8532 | if len(m.AllOf) != 0 { |
| 8533 | items := make([]interface{}, 0) |
| 8534 | for _, item := range m.AllOf { |
| 8535 | items = append(items, item.ToRawInfo()) |
| 8536 | } |
| 8537 | info = append(info, yaml.MapItem{Key: "allOf", Value: items}) |
| 8538 | } |
| 8539 | // &{Name:allOf Type:Schema StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} |
| 8540 | if m.Properties != nil { |
| 8541 | info = append(info, yaml.MapItem{Key: "properties", Value: m.Properties.ToRawInfo()}) |
| 8542 | } |
| 8543 | // &{Name:properties Type:Properties StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8544 | if m.Discriminator != "" { |
| 8545 | info = append(info, yaml.MapItem{Key: "discriminator", Value: m.Discriminator}) |
| 8546 | } |
| 8547 | if m.ReadOnly != false { |
| 8548 | info = append(info, yaml.MapItem{Key: "readOnly", Value: m.ReadOnly}) |
| 8549 | } |
| 8550 | if m.Xml != nil { |
| 8551 | info = append(info, yaml.MapItem{Key: "xml", Value: m.Xml.ToRawInfo()}) |
| 8552 | } |
| 8553 | // &{Name:xml Type:Xml StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8554 | if m.ExternalDocs != nil { |
| 8555 | info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) |
| 8556 | } |
| 8557 | // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8558 | if m.Example != nil { |
| 8559 | info = append(info, yaml.MapItem{Key: "example", Value: m.Example.ToRawInfo()}) |
| 8560 | } |
| 8561 | // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8562 | if m.VendorExtension != nil { |
| 8563 | for _, item := range m.VendorExtension { |
| 8564 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8565 | } |
| 8566 | } |
| 8567 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8568 | return info |
| 8569 | } |
| 8570 | |
| 8571 | // ToRawInfo returns a description of SchemaItem suitable for JSON or YAML export. |
| 8572 | func (m *SchemaItem) ToRawInfo() interface{} { |
| 8573 | // ONE OF WRAPPER |
| 8574 | // SchemaItem |
| 8575 | // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8576 | v0 := m.GetSchema() |
| 8577 | if v0 != nil { |
| 8578 | return v0.ToRawInfo() |
| 8579 | } |
| 8580 | // {Name:fileSchema Type:FileSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8581 | v1 := m.GetFileSchema() |
| 8582 | if v1 != nil { |
| 8583 | return v1.ToRawInfo() |
| 8584 | } |
| 8585 | return nil |
| 8586 | } |
| 8587 | |
| 8588 | // ToRawInfo returns a description of SecurityDefinitions suitable for JSON or YAML export. |
| 8589 | func (m *SecurityDefinitions) ToRawInfo() interface{} { |
| 8590 | info := yaml.MapSlice{} |
| 8591 | if m.AdditionalProperties != nil { |
| 8592 | for _, item := range m.AdditionalProperties { |
| 8593 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8594 | } |
| 8595 | } |
| 8596 | // &{Name:additionalProperties Type:NamedSecurityDefinitionsItem StringEnumValues:[] MapType:SecurityDefinitionsItem Repeated:true Pattern: Implicit:true Description:} |
| 8597 | return info |
| 8598 | } |
| 8599 | |
| 8600 | // ToRawInfo returns a description of SecurityDefinitionsItem suitable for JSON or YAML export. |
| 8601 | func (m *SecurityDefinitionsItem) ToRawInfo() interface{} { |
| 8602 | // ONE OF WRAPPER |
| 8603 | // SecurityDefinitionsItem |
| 8604 | // {Name:basicAuthenticationSecurity Type:BasicAuthenticationSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8605 | v0 := m.GetBasicAuthenticationSecurity() |
| 8606 | if v0 != nil { |
| 8607 | return v0.ToRawInfo() |
| 8608 | } |
| 8609 | // {Name:apiKeySecurity Type:ApiKeySecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8610 | v1 := m.GetApiKeySecurity() |
| 8611 | if v1 != nil { |
| 8612 | return v1.ToRawInfo() |
| 8613 | } |
| 8614 | // {Name:oauth2ImplicitSecurity Type:Oauth2ImplicitSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8615 | v2 := m.GetOauth2ImplicitSecurity() |
| 8616 | if v2 != nil { |
| 8617 | return v2.ToRawInfo() |
| 8618 | } |
| 8619 | // {Name:oauth2PasswordSecurity Type:Oauth2PasswordSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8620 | v3 := m.GetOauth2PasswordSecurity() |
| 8621 | if v3 != nil { |
| 8622 | return v3.ToRawInfo() |
| 8623 | } |
| 8624 | // {Name:oauth2ApplicationSecurity Type:Oauth2ApplicationSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8625 | v4 := m.GetOauth2ApplicationSecurity() |
| 8626 | if v4 != nil { |
| 8627 | return v4.ToRawInfo() |
| 8628 | } |
| 8629 | // {Name:oauth2AccessCodeSecurity Type:Oauth2AccessCodeSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8630 | v5 := m.GetOauth2AccessCodeSecurity() |
| 8631 | if v5 != nil { |
| 8632 | return v5.ToRawInfo() |
| 8633 | } |
| 8634 | return nil |
| 8635 | } |
| 8636 | |
| 8637 | // ToRawInfo returns a description of SecurityRequirement suitable for JSON or YAML export. |
| 8638 | func (m *SecurityRequirement) ToRawInfo() interface{} { |
| 8639 | info := yaml.MapSlice{} |
| 8640 | if m.AdditionalProperties != nil { |
| 8641 | for _, item := range m.AdditionalProperties { |
| 8642 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8643 | } |
| 8644 | } |
| 8645 | // &{Name:additionalProperties Type:NamedStringArray StringEnumValues:[] MapType:StringArray Repeated:true Pattern: Implicit:true Description:} |
| 8646 | return info |
| 8647 | } |
| 8648 | |
| 8649 | // ToRawInfo returns a description of StringArray suitable for JSON or YAML export. |
| 8650 | func (m *StringArray) ToRawInfo() interface{} { |
| 8651 | return m.Value |
| 8652 | } |
| 8653 | |
| 8654 | // ToRawInfo returns a description of Tag suitable for JSON or YAML export. |
| 8655 | func (m *Tag) ToRawInfo() interface{} { |
| 8656 | info := yaml.MapSlice{} |
| 8657 | if m.Name != "" { |
| 8658 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 8659 | } |
| 8660 | if m.Description != "" { |
| 8661 | info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) |
| 8662 | } |
| 8663 | if m.ExternalDocs != nil { |
| 8664 | info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) |
| 8665 | } |
| 8666 | // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} |
| 8667 | if m.VendorExtension != nil { |
| 8668 | for _, item := range m.VendorExtension { |
| 8669 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8670 | } |
| 8671 | } |
| 8672 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8673 | return info |
| 8674 | } |
| 8675 | |
| 8676 | // ToRawInfo returns a description of TypeItem suitable for JSON or YAML export. |
| 8677 | func (m *TypeItem) ToRawInfo() interface{} { |
| 8678 | info := yaml.MapSlice{} |
| 8679 | if len(m.Value) != 0 { |
| 8680 | info = append(info, yaml.MapItem{Key: "value", Value: m.Value}) |
| 8681 | } |
| 8682 | return info |
| 8683 | } |
| 8684 | |
| 8685 | // ToRawInfo returns a description of VendorExtension suitable for JSON or YAML export. |
| 8686 | func (m *VendorExtension) ToRawInfo() interface{} { |
| 8687 | info := yaml.MapSlice{} |
| 8688 | if m.AdditionalProperties != nil { |
| 8689 | for _, item := range m.AdditionalProperties { |
| 8690 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8691 | } |
| 8692 | } |
| 8693 | // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:} |
| 8694 | return info |
| 8695 | } |
| 8696 | |
| 8697 | // ToRawInfo returns a description of Xml suitable for JSON or YAML export. |
| 8698 | func (m *Xml) ToRawInfo() interface{} { |
| 8699 | info := yaml.MapSlice{} |
| 8700 | if m.Name != "" { |
| 8701 | info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) |
| 8702 | } |
| 8703 | if m.Namespace != "" { |
| 8704 | info = append(info, yaml.MapItem{Key: "namespace", Value: m.Namespace}) |
| 8705 | } |
| 8706 | if m.Prefix != "" { |
| 8707 | info = append(info, yaml.MapItem{Key: "prefix", Value: m.Prefix}) |
| 8708 | } |
| 8709 | if m.Attribute != false { |
| 8710 | info = append(info, yaml.MapItem{Key: "attribute", Value: m.Attribute}) |
| 8711 | } |
| 8712 | if m.Wrapped != false { |
| 8713 | info = append(info, yaml.MapItem{Key: "wrapped", Value: m.Wrapped}) |
| 8714 | } |
| 8715 | if m.VendorExtension != nil { |
| 8716 | for _, item := range m.VendorExtension { |
| 8717 | info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) |
| 8718 | } |
| 8719 | } |
| 8720 | // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} |
| 8721 | return info |
| 8722 | } |
| 8723 | |
| 8724 | var ( |
| 8725 | pattern0 = regexp.MustCompile("^x-") |
| 8726 | pattern1 = regexp.MustCompile("^/") |
| 8727 | pattern2 = regexp.MustCompile("^([0-9]{3})$|^(default)$") |
| 8728 | ) |