| 1 |
// Copyright 2020 Google LLC. 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 discovery_v1 |
| 18 |
|
| 19 |
import ( |
| 20 |
"fmt" |
| 21 |
"regexp" |
| 22 |
"strings" |
| 23 |
|
| 24 |
yaml "go.yaml.in/yaml/v3" |
| 25 |
|
| 26 |
"github.com/google/gnostic-models/compiler" |
| 27 |
) |
| 28 |
|
| 29 |
// Version returns the package name (and OpenAPI version). |
| 30 |
func Version() string { |
| 31 |
return "discovery_v1" |
| 32 |
} |
| 33 |
|
| 34 |
// NewAnnotations creates an object of type Annotations if possible, returning an error if not. |
| 35 |
func NewAnnotations(in *yaml.Node, context *compiler.Context) (*Annotations, error) { |
| 36 |
errors := make([]error, 0) |
| 37 |
x := &Annotations{} |
| 38 |
m, ok := compiler.UnpackMap(in) |
| 39 |
if !ok { |
| 40 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 41 |
errors = append(errors, compiler.NewError(context, message)) |
| 42 |
} else { |
| 43 |
allowedKeys := []string{"required"} |
| 44 |
var allowedPatterns []*regexp.Regexp |
| 45 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 46 |
if len(invalidKeys) > 0 { |
| 47 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 48 |
errors = append(errors, compiler.NewError(context, message)) |
| 49 |
} |
| 50 |
// repeated string required = 1; |
| 51 |
v1 := compiler.MapValueForKey(m, "required") |
| 52 |
if v1 != nil { |
| 53 |
v, ok := compiler.SequenceNodeForNode(v1) |
| 54 |
if ok { |
| 55 |
x.Required = compiler.StringArrayForSequenceNode(v) |
| 56 |
} else { |
| 57 |
message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) |
| 58 |
errors = append(errors, compiler.NewError(context, message)) |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 63 |
} |
| 64 |
|
| 65 |
// NewAny creates an object of type Any if possible, returning an error if not. |
| 66 |
func NewAny(in *yaml.Node, context *compiler.Context) (*Any, error) { |
| 67 |
errors := make([]error, 0) |
| 68 |
x := &Any{} |
| 69 |
bytes := compiler.Marshal(in) |
| 70 |
x.Yaml = string(bytes) |
| 71 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 72 |
} |
| 73 |
|
| 74 |
// NewAuth creates an object of type Auth if possible, returning an error if not. |
| 75 |
func NewAuth(in *yaml.Node, context *compiler.Context) (*Auth, error) { |
| 76 |
errors := make([]error, 0) |
| 77 |
x := &Auth{} |
| 78 |
m, ok := compiler.UnpackMap(in) |
| 79 |
if !ok { |
| 80 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 81 |
errors = append(errors, compiler.NewError(context, message)) |
| 82 |
} else { |
| 83 |
allowedKeys := []string{"oauth2"} |
| 84 |
var allowedPatterns []*regexp.Regexp |
| 85 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 86 |
if len(invalidKeys) > 0 { |
| 87 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 88 |
errors = append(errors, compiler.NewError(context, message)) |
| 89 |
} |
| 90 |
// Oauth2 oauth2 = 1; |
| 91 |
v1 := compiler.MapValueForKey(m, "oauth2") |
| 92 |
if v1 != nil { |
| 93 |
var err error |
| 94 |
x.Oauth2, err = NewOauth2(v1, compiler.NewContext("oauth2", v1, context)) |
| 95 |
if err != nil { |
| 96 |
errors = append(errors, err) |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 101 |
} |
| 102 |
|
| 103 |
// NewDocument creates an object of type Document if possible, returning an error if not. |
| 104 |
func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { |
| 105 |
errors := make([]error, 0) |
| 106 |
x := &Document{} |
| 107 |
m, ok := compiler.UnpackMap(in) |
| 108 |
if !ok { |
| 109 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 110 |
errors = append(errors, compiler.NewError(context, message)) |
| 111 |
} else { |
| 112 |
requiredKeys := []string{"discoveryVersion", "kind"} |
| 113 |
missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 114 |
if len(missingKeys) > 0 { |
| 115 |
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 116 |
errors = append(errors, compiler.NewError(context, message)) |
| 117 |
} |
| 118 |
allowedKeys := []string{"auth", "basePath", "baseUrl", "batchPath", "canonicalName", "description", "discoveryVersion", "documentationLink", "etag", "features", "fullyEncodeReservedExpansion", "icons", "id", "kind", "labels", "methods", "mtlsRootUrl", "name", "ownerDomain", "ownerName", "packagePath", "parameters", "protocol", "resources", "revision", "rootUrl", "schemas", "servicePath", "title", "version", "version_module"} |
| 119 |
var allowedPatterns []*regexp.Regexp |
| 120 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 121 |
if len(invalidKeys) > 0 { |
| 122 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 123 |
errors = append(errors, compiler.NewError(context, message)) |
| 124 |
} |
| 125 |
// string kind = 1; |
| 126 |
v1 := compiler.MapValueForKey(m, "kind") |
| 127 |
if v1 != nil { |
| 128 |
x.Kind, ok = compiler.StringForScalarNode(v1) |
| 129 |
if !ok { |
| 130 |
message := fmt.Sprintf("has unexpected value for kind: %s", compiler.Display(v1)) |
| 131 |
errors = append(errors, compiler.NewError(context, message)) |
| 132 |
} |
| 133 |
} |
| 134 |
// string discovery_version = 2; |
| 135 |
v2 := compiler.MapValueForKey(m, "discoveryVersion") |
| 136 |
if v2 != nil { |
| 137 |
x.DiscoveryVersion, ok = compiler.StringForScalarNode(v2) |
| 138 |
if !ok { |
| 139 |
message := fmt.Sprintf("has unexpected value for discoveryVersion: %s", compiler.Display(v2)) |
| 140 |
errors = append(errors, compiler.NewError(context, message)) |
| 141 |
} |
| 142 |
} |
| 143 |
// string id = 3; |
| 144 |
v3 := compiler.MapValueForKey(m, "id") |
| 145 |
if v3 != nil { |
| 146 |
x.Id, ok = compiler.StringForScalarNode(v3) |
| 147 |
if !ok { |
| 148 |
message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v3)) |
| 149 |
errors = append(errors, compiler.NewError(context, message)) |
| 150 |
} |
| 151 |
} |
| 152 |
// string name = 4; |
| 153 |
v4 := compiler.MapValueForKey(m, "name") |
| 154 |
if v4 != nil { |
| 155 |
x.Name, ok = compiler.StringForScalarNode(v4) |
| 156 |
if !ok { |
| 157 |
message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) |
| 158 |
errors = append(errors, compiler.NewError(context, message)) |
| 159 |
} |
| 160 |
} |
| 161 |
// string version = 5; |
| 162 |
v5 := compiler.MapValueForKey(m, "version") |
| 163 |
if v5 != nil { |
| 164 |
x.Version, ok = compiler.StringForScalarNode(v5) |
| 165 |
if !ok { |
| 166 |
message := fmt.Sprintf("has unexpected value for version: %s", compiler.Display(v5)) |
| 167 |
errors = append(errors, compiler.NewError(context, message)) |
| 168 |
} |
| 169 |
} |
| 170 |
// string revision = 6; |
| 171 |
v6 := compiler.MapValueForKey(m, "revision") |
| 172 |
if v6 != nil { |
| 173 |
x.Revision, ok = compiler.StringForScalarNode(v6) |
| 174 |
if !ok { |
| 175 |
message := fmt.Sprintf("has unexpected value for revision: %s", compiler.Display(v6)) |
| 176 |
errors = append(errors, compiler.NewError(context, message)) |
| 177 |
} |
| 178 |
} |
| 179 |
// string title = 7; |
| 180 |
v7 := compiler.MapValueForKey(m, "title") |
| 181 |
if v7 != nil { |
| 182 |
x.Title, ok = compiler.StringForScalarNode(v7) |
| 183 |
if !ok { |
| 184 |
message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v7)) |
| 185 |
errors = append(errors, compiler.NewError(context, message)) |
| 186 |
} |
| 187 |
} |
| 188 |
// string description = 8; |
| 189 |
v8 := compiler.MapValueForKey(m, "description") |
| 190 |
if v8 != nil { |
| 191 |
x.Description, ok = compiler.StringForScalarNode(v8) |
| 192 |
if !ok { |
| 193 |
message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v8)) |
| 194 |
errors = append(errors, compiler.NewError(context, message)) |
| 195 |
} |
| 196 |
} |
| 197 |
// Icons icons = 9; |
| 198 |
v9 := compiler.MapValueForKey(m, "icons") |
| 199 |
if v9 != nil { |
| 200 |
var err error |
| 201 |
x.Icons, err = NewIcons(v9, compiler.NewContext("icons", v9, context)) |
| 202 |
if err != nil { |
| 203 |
errors = append(errors, err) |
| 204 |
} |
| 205 |
} |
| 206 |
// string documentation_link = 10; |
| 207 |
v10 := compiler.MapValueForKey(m, "documentationLink") |
| 208 |
if v10 != nil { |
| 209 |
x.DocumentationLink, ok = compiler.StringForScalarNode(v10) |
| 210 |
if !ok { |
| 211 |
message := fmt.Sprintf("has unexpected value for documentationLink: %s", compiler.Display(v10)) |
| 212 |
errors = append(errors, compiler.NewError(context, message)) |
| 213 |
} |
| 214 |
} |
| 215 |
// repeated string labels = 11; |
| 216 |
v11 := compiler.MapValueForKey(m, "labels") |
| 217 |
if v11 != nil { |
| 218 |
v, ok := compiler.SequenceNodeForNode(v11) |
| 219 |
if ok { |
| 220 |
x.Labels = compiler.StringArrayForSequenceNode(v) |
| 221 |
} else { |
| 222 |
message := fmt.Sprintf("has unexpected value for labels: %s", compiler.Display(v11)) |
| 223 |
errors = append(errors, compiler.NewError(context, message)) |
| 224 |
} |
| 225 |
} |
| 226 |
// string protocol = 12; |
| 227 |
v12 := compiler.MapValueForKey(m, "protocol") |
| 228 |
if v12 != nil { |
| 229 |
x.Protocol, ok = compiler.StringForScalarNode(v12) |
| 230 |
if !ok { |
| 231 |
message := fmt.Sprintf("has unexpected value for protocol: %s", compiler.Display(v12)) |
| 232 |
errors = append(errors, compiler.NewError(context, message)) |
| 233 |
} |
| 234 |
} |
| 235 |
// string base_url = 13; |
| 236 |
v13 := compiler.MapValueForKey(m, "baseUrl") |
| 237 |
if v13 != nil { |
| 238 |
x.BaseUrl, ok = compiler.StringForScalarNode(v13) |
| 239 |
if !ok { |
| 240 |
message := fmt.Sprintf("has unexpected value for baseUrl: %s", compiler.Display(v13)) |
| 241 |
errors = append(errors, compiler.NewError(context, message)) |
| 242 |
} |
| 243 |
} |
| 244 |
// string base_path = 14; |
| 245 |
v14 := compiler.MapValueForKey(m, "basePath") |
| 246 |
if v14 != nil { |
| 247 |
x.BasePath, ok = compiler.StringForScalarNode(v14) |
| 248 |
if !ok { |
| 249 |
message := fmt.Sprintf("has unexpected value for basePath: %s", compiler.Display(v14)) |
| 250 |
errors = append(errors, compiler.NewError(context, message)) |
| 251 |
} |
| 252 |
} |
| 253 |
// string root_url = 15; |
| 254 |
v15 := compiler.MapValueForKey(m, "rootUrl") |
| 255 |
if v15 != nil { |
| 256 |
x.RootUrl, ok = compiler.StringForScalarNode(v15) |
| 257 |
if !ok { |
| 258 |
message := fmt.Sprintf("has unexpected value for rootUrl: %s", compiler.Display(v15)) |
| 259 |
errors = append(errors, compiler.NewError(context, message)) |
| 260 |
} |
| 261 |
} |
| 262 |
// string service_path = 16; |
| 263 |
v16 := compiler.MapValueForKey(m, "servicePath") |
| 264 |
if v16 != nil { |
| 265 |
x.ServicePath, ok = compiler.StringForScalarNode(v16) |
| 266 |
if !ok { |
| 267 |
message := fmt.Sprintf("has unexpected value for servicePath: %s", compiler.Display(v16)) |
| 268 |
errors = append(errors, compiler.NewError(context, message)) |
| 269 |
} |
| 270 |
} |
| 271 |
// string batch_path = 17; |
| 272 |
v17 := compiler.MapValueForKey(m, "batchPath") |
| 273 |
if v17 != nil { |
| 274 |
x.BatchPath, ok = compiler.StringForScalarNode(v17) |
| 275 |
if !ok { |
| 276 |
message := fmt.Sprintf("has unexpected value for batchPath: %s", compiler.Display(v17)) |
| 277 |
errors = append(errors, compiler.NewError(context, message)) |
| 278 |
} |
| 279 |
} |
| 280 |
// Parameters parameters = 18; |
| 281 |
v18 := compiler.MapValueForKey(m, "parameters") |
| 282 |
if v18 != nil { |
| 283 |
var err error |
| 284 |
x.Parameters, err = NewParameters(v18, compiler.NewContext("parameters", v18, context)) |
| 285 |
if err != nil { |
| 286 |
errors = append(errors, err) |
| 287 |
} |
| 288 |
} |
| 289 |
// Auth auth = 19; |
| 290 |
v19 := compiler.MapValueForKey(m, "auth") |
| 291 |
if v19 != nil { |
| 292 |
var err error |
| 293 |
x.Auth, err = NewAuth(v19, compiler.NewContext("auth", v19, context)) |
| 294 |
if err != nil { |
| 295 |
errors = append(errors, err) |
| 296 |
} |
| 297 |
} |
| 298 |
// repeated string features = 20; |
| 299 |
v20 := compiler.MapValueForKey(m, "features") |
| 300 |
if v20 != nil { |
| 301 |
v, ok := compiler.SequenceNodeForNode(v20) |
| 302 |
if ok { |
| 303 |
x.Features = compiler.StringArrayForSequenceNode(v) |
| 304 |
} else { |
| 305 |
message := fmt.Sprintf("has unexpected value for features: %s", compiler.Display(v20)) |
| 306 |
errors = append(errors, compiler.NewError(context, message)) |
| 307 |
} |
| 308 |
} |
| 309 |
// Schemas schemas = 21; |
| 310 |
v21 := compiler.MapValueForKey(m, "schemas") |
| 311 |
if v21 != nil { |
| 312 |
var err error |
| 313 |
x.Schemas, err = NewSchemas(v21, compiler.NewContext("schemas", v21, context)) |
| 314 |
if err != nil { |
| 315 |
errors = append(errors, err) |
| 316 |
} |
| 317 |
} |
| 318 |
// Methods methods = 22; |
| 319 |
v22 := compiler.MapValueForKey(m, "methods") |
| 320 |
if v22 != nil { |
| 321 |
var err error |
| 322 |
x.Methods, err = NewMethods(v22, compiler.NewContext("methods", v22, context)) |
| 323 |
if err != nil { |
| 324 |
errors = append(errors, err) |
| 325 |
} |
| 326 |
} |
| 327 |
// Resources resources = 23; |
| 328 |
v23 := compiler.MapValueForKey(m, "resources") |
| 329 |
if v23 != nil { |
| 330 |
var err error |
| 331 |
x.Resources, err = NewResources(v23, compiler.NewContext("resources", v23, context)) |
| 332 |
if err != nil { |
| 333 |
errors = append(errors, err) |
| 334 |
} |
| 335 |
} |
| 336 |
// string etag = 24; |
| 337 |
v24 := compiler.MapValueForKey(m, "etag") |
| 338 |
if v24 != nil { |
| 339 |
x.Etag, ok = compiler.StringForScalarNode(v24) |
| 340 |
if !ok { |
| 341 |
message := fmt.Sprintf("has unexpected value for etag: %s", compiler.Display(v24)) |
| 342 |
errors = append(errors, compiler.NewError(context, message)) |
| 343 |
} |
| 344 |
} |
| 345 |
// string owner_domain = 25; |
| 346 |
v25 := compiler.MapValueForKey(m, "ownerDomain") |
| 347 |
if v25 != nil { |
| 348 |
x.OwnerDomain, ok = compiler.StringForScalarNode(v25) |
| 349 |
if !ok { |
| 350 |
message := fmt.Sprintf("has unexpected value for ownerDomain: %s", compiler.Display(v25)) |
| 351 |
errors = append(errors, compiler.NewError(context, message)) |
| 352 |
} |
| 353 |
} |
| 354 |
// string owner_name = 26; |
| 355 |
v26 := compiler.MapValueForKey(m, "ownerName") |
| 356 |
if v26 != nil { |
| 357 |
x.OwnerName, ok = compiler.StringForScalarNode(v26) |
| 358 |
if !ok { |
| 359 |
message := fmt.Sprintf("has unexpected value for ownerName: %s", compiler.Display(v26)) |
| 360 |
errors = append(errors, compiler.NewError(context, message)) |
| 361 |
} |
| 362 |
} |
| 363 |
// bool version_module = 27; |
| 364 |
v27 := compiler.MapValueForKey(m, "version_module") |
| 365 |
if v27 != nil { |
| 366 |
x.VersionModule, ok = compiler.BoolForScalarNode(v27) |
| 367 |
if !ok { |
| 368 |
message := fmt.Sprintf("has unexpected value for version_module: %s", compiler.Display(v27)) |
| 369 |
errors = append(errors, compiler.NewError(context, message)) |
| 370 |
} |
| 371 |
} |
| 372 |
// string canonical_name = 28; |
| 373 |
v28 := compiler.MapValueForKey(m, "canonicalName") |
| 374 |
if v28 != nil { |
| 375 |
x.CanonicalName, ok = compiler.StringForScalarNode(v28) |
| 376 |
if !ok { |
| 377 |
message := fmt.Sprintf("has unexpected value for canonicalName: %s", compiler.Display(v28)) |
| 378 |
errors = append(errors, compiler.NewError(context, message)) |
| 379 |
} |
| 380 |
} |
| 381 |
// bool fully_encode_reserved_expansion = 29; |
| 382 |
v29 := compiler.MapValueForKey(m, "fullyEncodeReservedExpansion") |
| 383 |
if v29 != nil { |
| 384 |
x.FullyEncodeReservedExpansion, ok = compiler.BoolForScalarNode(v29) |
| 385 |
if !ok { |
| 386 |
message := fmt.Sprintf("has unexpected value for fullyEncodeReservedExpansion: %s", compiler.Display(v29)) |
| 387 |
errors = append(errors, compiler.NewError(context, message)) |
| 388 |
} |
| 389 |
} |
| 390 |
// string package_path = 30; |
| 391 |
v30 := compiler.MapValueForKey(m, "packagePath") |
| 392 |
if v30 != nil { |
| 393 |
x.PackagePath, ok = compiler.StringForScalarNode(v30) |
| 394 |
if !ok { |
| 395 |
message := fmt.Sprintf("has unexpected value for packagePath: %s", compiler.Display(v30)) |
| 396 |
errors = append(errors, compiler.NewError(context, message)) |
| 397 |
} |
| 398 |
} |
| 399 |
// string mtls_root_url = 31; |
| 400 |
v31 := compiler.MapValueForKey(m, "mtlsRootUrl") |
| 401 |
if v31 != nil { |
| 402 |
x.MtlsRootUrl, ok = compiler.StringForScalarNode(v31) |
| 403 |
if !ok { |
| 404 |
message := fmt.Sprintf("has unexpected value for mtlsRootUrl: %s", compiler.Display(v31)) |
| 405 |
errors = append(errors, compiler.NewError(context, message)) |
| 406 |
} |
| 407 |
} |
| 408 |
} |
| 409 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 410 |
} |
| 411 |
|
| 412 |
// NewIcons creates an object of type Icons if possible, returning an error if not. |
| 413 |
func NewIcons(in *yaml.Node, context *compiler.Context) (*Icons, error) { |
| 414 |
errors := make([]error, 0) |
| 415 |
x := &Icons{} |
| 416 |
m, ok := compiler.UnpackMap(in) |
| 417 |
if !ok { |
| 418 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 419 |
errors = append(errors, compiler.NewError(context, message)) |
| 420 |
} else { |
| 421 |
requiredKeys := []string{"x16", "x32"} |
| 422 |
missingKeys := compiler.MissingKeysInMap(m, requiredKeys) |
| 423 |
if len(missingKeys) > 0 { |
| 424 |
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", ")) |
| 425 |
errors = append(errors, compiler.NewError(context, message)) |
| 426 |
} |
| 427 |
allowedKeys := []string{"x16", "x32"} |
| 428 |
var allowedPatterns []*regexp.Regexp |
| 429 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 430 |
if len(invalidKeys) > 0 { |
| 431 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 432 |
errors = append(errors, compiler.NewError(context, message)) |
| 433 |
} |
| 434 |
// string x16 = 1; |
| 435 |
v1 := compiler.MapValueForKey(m, "x16") |
| 436 |
if v1 != nil { |
| 437 |
x.X16, ok = compiler.StringForScalarNode(v1) |
| 438 |
if !ok { |
| 439 |
message := fmt.Sprintf("has unexpected value for x16: %s", compiler.Display(v1)) |
| 440 |
errors = append(errors, compiler.NewError(context, message)) |
| 441 |
} |
| 442 |
} |
| 443 |
// string x32 = 2; |
| 444 |
v2 := compiler.MapValueForKey(m, "x32") |
| 445 |
if v2 != nil { |
| 446 |
x.X32, ok = compiler.StringForScalarNode(v2) |
| 447 |
if !ok { |
| 448 |
message := fmt.Sprintf("has unexpected value for x32: %s", compiler.Display(v2)) |
| 449 |
errors = append(errors, compiler.NewError(context, message)) |
| 450 |
} |
| 451 |
} |
| 452 |
} |
| 453 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 454 |
} |
| 455 |
|
| 456 |
// NewMediaUpload creates an object of type MediaUpload if possible, returning an error if not. |
| 457 |
func NewMediaUpload(in *yaml.Node, context *compiler.Context) (*MediaUpload, error) { |
| 458 |
errors := make([]error, 0) |
| 459 |
x := &MediaUpload{} |
| 460 |
m, ok := compiler.UnpackMap(in) |
| 461 |
if !ok { |
| 462 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 463 |
errors = append(errors, compiler.NewError(context, message)) |
| 464 |
} else { |
| 465 |
allowedKeys := []string{"accept", "maxSize", "protocols", "supportsSubscription"} |
| 466 |
var allowedPatterns []*regexp.Regexp |
| 467 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 468 |
if len(invalidKeys) > 0 { |
| 469 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 470 |
errors = append(errors, compiler.NewError(context, message)) |
| 471 |
} |
| 472 |
// repeated string accept = 1; |
| 473 |
v1 := compiler.MapValueForKey(m, "accept") |
| 474 |
if v1 != nil { |
| 475 |
v, ok := compiler.SequenceNodeForNode(v1) |
| 476 |
if ok { |
| 477 |
x.Accept = compiler.StringArrayForSequenceNode(v) |
| 478 |
} else { |
| 479 |
message := fmt.Sprintf("has unexpected value for accept: %s", compiler.Display(v1)) |
| 480 |
errors = append(errors, compiler.NewError(context, message)) |
| 481 |
} |
| 482 |
} |
| 483 |
// string max_size = 2; |
| 484 |
v2 := compiler.MapValueForKey(m, "maxSize") |
| 485 |
if v2 != nil { |
| 486 |
x.MaxSize, ok = compiler.StringForScalarNode(v2) |
| 487 |
if !ok { |
| 488 |
message := fmt.Sprintf("has unexpected value for maxSize: %s", compiler.Display(v2)) |
| 489 |
errors = append(errors, compiler.NewError(context, message)) |
| 490 |
} |
| 491 |
} |
| 492 |
// Protocols protocols = 3; |
| 493 |
v3 := compiler.MapValueForKey(m, "protocols") |
| 494 |
if v3 != nil { |
| 495 |
var err error |
| 496 |
x.Protocols, err = NewProtocols(v3, compiler.NewContext("protocols", v3, context)) |
| 497 |
if err != nil { |
| 498 |
errors = append(errors, err) |
| 499 |
} |
| 500 |
} |
| 501 |
// bool supports_subscription = 4; |
| 502 |
v4 := compiler.MapValueForKey(m, "supportsSubscription") |
| 503 |
if v4 != nil { |
| 504 |
x.SupportsSubscription, ok = compiler.BoolForScalarNode(v4) |
| 505 |
if !ok { |
| 506 |
message := fmt.Sprintf("has unexpected value for supportsSubscription: %s", compiler.Display(v4)) |
| 507 |
errors = append(errors, compiler.NewError(context, message)) |
| 508 |
} |
| 509 |
} |
| 510 |
} |
| 511 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 512 |
} |
| 513 |
|
| 514 |
// NewMethod creates an object of type Method if possible, returning an error if not. |
| 515 |
func NewMethod(in *yaml.Node, context *compiler.Context) (*Method, error) { |
| 516 |
errors := make([]error, 0) |
| 517 |
x := &Method{} |
| 518 |
m, ok := compiler.UnpackMap(in) |
| 519 |
if !ok { |
| 520 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 521 |
errors = append(errors, compiler.NewError(context, message)) |
| 522 |
} else { |
| 523 |
allowedKeys := []string{"description", "etagRequired", "flatPath", "httpMethod", "id", "mediaUpload", "parameterOrder", "parameters", "path", "request", "response", "scopes", "streamingType", "supportsMediaDownload", "supportsMediaUpload", "supportsSubscription", "useMediaDownloadService"} |
| 524 |
var allowedPatterns []*regexp.Regexp |
| 525 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 526 |
if len(invalidKeys) > 0 { |
| 527 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 528 |
errors = append(errors, compiler.NewError(context, message)) |
| 529 |
} |
| 530 |
// string id = 1; |
| 531 |
v1 := compiler.MapValueForKey(m, "id") |
| 532 |
if v1 != nil { |
| 533 |
x.Id, ok = compiler.StringForScalarNode(v1) |
| 534 |
if !ok { |
| 535 |
message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) |
| 536 |
errors = append(errors, compiler.NewError(context, message)) |
| 537 |
} |
| 538 |
} |
| 539 |
// string path = 2; |
| 540 |
v2 := compiler.MapValueForKey(m, "path") |
| 541 |
if v2 != nil { |
| 542 |
x.Path, ok = compiler.StringForScalarNode(v2) |
| 543 |
if !ok { |
| 544 |
message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) |
| 545 |
errors = append(errors, compiler.NewError(context, message)) |
| 546 |
} |
| 547 |
} |
| 548 |
// string http_method = 3; |
| 549 |
v3 := compiler.MapValueForKey(m, "httpMethod") |
| 550 |
if v3 != nil { |
| 551 |
x.HttpMethod, ok = compiler.StringForScalarNode(v3) |
| 552 |
if !ok { |
| 553 |
message := fmt.Sprintf("has unexpected value for httpMethod: %s", compiler.Display(v3)) |
| 554 |
errors = append(errors, compiler.NewError(context, message)) |
| 555 |
} |
| 556 |
} |
| 557 |
// string description = 4; |
| 558 |
v4 := compiler.MapValueForKey(m, "description") |
| 559 |
if v4 != nil { |
| 560 |
x.Description, ok = compiler.StringForScalarNode(v4) |
| 561 |
if !ok { |
| 562 |
message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) |
| 563 |
errors = append(errors, compiler.NewError(context, message)) |
| 564 |
} |
| 565 |
} |
| 566 |
// Parameters parameters = 5; |
| 567 |
v5 := compiler.MapValueForKey(m, "parameters") |
| 568 |
if v5 != nil { |
| 569 |
var err error |
| 570 |
x.Parameters, err = NewParameters(v5, compiler.NewContext("parameters", v5, context)) |
| 571 |
if err != nil { |
| 572 |
errors = append(errors, err) |
| 573 |
} |
| 574 |
} |
| 575 |
// repeated string parameter_order = 6; |
| 576 |
v6 := compiler.MapValueForKey(m, "parameterOrder") |
| 577 |
if v6 != nil { |
| 578 |
v, ok := compiler.SequenceNodeForNode(v6) |
| 579 |
if ok { |
| 580 |
x.ParameterOrder = compiler.StringArrayForSequenceNode(v) |
| 581 |
} else { |
| 582 |
message := fmt.Sprintf("has unexpected value for parameterOrder: %s", compiler.Display(v6)) |
| 583 |
errors = append(errors, compiler.NewError(context, message)) |
| 584 |
} |
| 585 |
} |
| 586 |
// Request request = 7; |
| 587 |
v7 := compiler.MapValueForKey(m, "request") |
| 588 |
if v7 != nil { |
| 589 |
var err error |
| 590 |
x.Request, err = NewRequest(v7, compiler.NewContext("request", v7, context)) |
| 591 |
if err != nil { |
| 592 |
errors = append(errors, err) |
| 593 |
} |
| 594 |
} |
| 595 |
// Response response = 8; |
| 596 |
v8 := compiler.MapValueForKey(m, "response") |
| 597 |
if v8 != nil { |
| 598 |
var err error |
| 599 |
x.Response, err = NewResponse(v8, compiler.NewContext("response", v8, context)) |
| 600 |
if err != nil { |
| 601 |
errors = append(errors, err) |
| 602 |
} |
| 603 |
} |
| 604 |
// repeated string scopes = 9; |
| 605 |
v9 := compiler.MapValueForKey(m, "scopes") |
| 606 |
if v9 != nil { |
| 607 |
v, ok := compiler.SequenceNodeForNode(v9) |
| 608 |
if ok { |
| 609 |
x.Scopes = compiler.StringArrayForSequenceNode(v) |
| 610 |
} else { |
| 611 |
message := fmt.Sprintf("has unexpected value for scopes: %s", compiler.Display(v9)) |
| 612 |
errors = append(errors, compiler.NewError(context, message)) |
| 613 |
} |
| 614 |
} |
| 615 |
// bool supports_media_download = 10; |
| 616 |
v10 := compiler.MapValueForKey(m, "supportsMediaDownload") |
| 617 |
if v10 != nil { |
| 618 |
x.SupportsMediaDownload, ok = compiler.BoolForScalarNode(v10) |
| 619 |
if !ok { |
| 620 |
message := fmt.Sprintf("has unexpected value for supportsMediaDownload: %s", compiler.Display(v10)) |
| 621 |
errors = append(errors, compiler.NewError(context, message)) |
| 622 |
} |
| 623 |
} |
| 624 |
// bool supports_media_upload = 11; |
| 625 |
v11 := compiler.MapValueForKey(m, "supportsMediaUpload") |
| 626 |
if v11 != nil { |
| 627 |
x.SupportsMediaUpload, ok = compiler.BoolForScalarNode(v11) |
| 628 |
if !ok { |
| 629 |
message := fmt.Sprintf("has unexpected value for supportsMediaUpload: %s", compiler.Display(v11)) |
| 630 |
errors = append(errors, compiler.NewError(context, message)) |
| 631 |
} |
| 632 |
} |
| 633 |
// bool use_media_download_service = 12; |
| 634 |
v12 := compiler.MapValueForKey(m, "useMediaDownloadService") |
| 635 |
if v12 != nil { |
| 636 |
x.UseMediaDownloadService, ok = compiler.BoolForScalarNode(v12) |
| 637 |
if !ok { |
| 638 |
message := fmt.Sprintf("has unexpected value for useMediaDownloadService: %s", compiler.Display(v12)) |
| 639 |
errors = append(errors, compiler.NewError(context, message)) |
| 640 |
} |
| 641 |
} |
| 642 |
// MediaUpload media_upload = 13; |
| 643 |
v13 := compiler.MapValueForKey(m, "mediaUpload") |
| 644 |
if v13 != nil { |
| 645 |
var err error |
| 646 |
x.MediaUpload, err = NewMediaUpload(v13, compiler.NewContext("mediaUpload", v13, context)) |
| 647 |
if err != nil { |
| 648 |
errors = append(errors, err) |
| 649 |
} |
| 650 |
} |
| 651 |
// bool supports_subscription = 14; |
| 652 |
v14 := compiler.MapValueForKey(m, "supportsSubscription") |
| 653 |
if v14 != nil { |
| 654 |
x.SupportsSubscription, ok = compiler.BoolForScalarNode(v14) |
| 655 |
if !ok { |
| 656 |
message := fmt.Sprintf("has unexpected value for supportsSubscription: %s", compiler.Display(v14)) |
| 657 |
errors = append(errors, compiler.NewError(context, message)) |
| 658 |
} |
| 659 |
} |
| 660 |
// string flat_path = 15; |
| 661 |
v15 := compiler.MapValueForKey(m, "flatPath") |
| 662 |
if v15 != nil { |
| 663 |
x.FlatPath, ok = compiler.StringForScalarNode(v15) |
| 664 |
if !ok { |
| 665 |
message := fmt.Sprintf("has unexpected value for flatPath: %s", compiler.Display(v15)) |
| 666 |
errors = append(errors, compiler.NewError(context, message)) |
| 667 |
} |
| 668 |
} |
| 669 |
// bool etag_required = 16; |
| 670 |
v16 := compiler.MapValueForKey(m, "etagRequired") |
| 671 |
if v16 != nil { |
| 672 |
x.EtagRequired, ok = compiler.BoolForScalarNode(v16) |
| 673 |
if !ok { |
| 674 |
message := fmt.Sprintf("has unexpected value for etagRequired: %s", compiler.Display(v16)) |
| 675 |
errors = append(errors, compiler.NewError(context, message)) |
| 676 |
} |
| 677 |
} |
| 678 |
// string streaming_type = 17; |
| 679 |
v17 := compiler.MapValueForKey(m, "streamingType") |
| 680 |
if v17 != nil { |
| 681 |
x.StreamingType, ok = compiler.StringForScalarNode(v17) |
| 682 |
if !ok { |
| 683 |
message := fmt.Sprintf("has unexpected value for streamingType: %s", compiler.Display(v17)) |
| 684 |
errors = append(errors, compiler.NewError(context, message)) |
| 685 |
} |
| 686 |
} |
| 687 |
} |
| 688 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 689 |
} |
| 690 |
|
| 691 |
// NewMethods creates an object of type Methods if possible, returning an error if not. |
| 692 |
func NewMethods(in *yaml.Node, context *compiler.Context) (*Methods, error) { |
| 693 |
errors := make([]error, 0) |
| 694 |
x := &Methods{} |
| 695 |
m, ok := compiler.UnpackMap(in) |
| 696 |
if !ok { |
| 697 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 698 |
errors = append(errors, compiler.NewError(context, message)) |
| 699 |
} else { |
| 700 |
// repeated NamedMethod additional_properties = 1; |
| 701 |
// MAP: Method |
| 702 |
x.AdditionalProperties = make([]*NamedMethod, 0) |
| 703 |
for i := 0; i < len(m.Content); i += 2 { |
| 704 |
k, ok := compiler.StringForScalarNode(m.Content[i]) |
| 705 |
if ok { |
| 706 |
v := m.Content[i+1] |
| 707 |
pair := &NamedMethod{} |
| 708 |
pair.Name = k |
| 709 |
var err error |
| 710 |
pair.Value, err = NewMethod(v, compiler.NewContext(k, v, context)) |
| 711 |
if err != nil { |
| 712 |
errors = append(errors, err) |
| 713 |
} |
| 714 |
x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 715 |
} |
| 716 |
} |
| 717 |
} |
| 718 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 719 |
} |
| 720 |
|
| 721 |
// NewNamedMethod creates an object of type NamedMethod if possible, returning an error if not. |
| 722 |
func NewNamedMethod(in *yaml.Node, context *compiler.Context) (*NamedMethod, error) { |
| 723 |
errors := make([]error, 0) |
| 724 |
x := &NamedMethod{} |
| 725 |
m, ok := compiler.UnpackMap(in) |
| 726 |
if !ok { |
| 727 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 728 |
errors = append(errors, compiler.NewError(context, message)) |
| 729 |
} else { |
| 730 |
allowedKeys := []string{"name", "value"} |
| 731 |
var allowedPatterns []*regexp.Regexp |
| 732 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 733 |
if len(invalidKeys) > 0 { |
| 734 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 735 |
errors = append(errors, compiler.NewError(context, message)) |
| 736 |
} |
| 737 |
// string name = 1; |
| 738 |
v1 := compiler.MapValueForKey(m, "name") |
| 739 |
if v1 != nil { |
| 740 |
x.Name, ok = compiler.StringForScalarNode(v1) |
| 741 |
if !ok { |
| 742 |
message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) |
| 743 |
errors = append(errors, compiler.NewError(context, message)) |
| 744 |
} |
| 745 |
} |
| 746 |
// Method value = 2; |
| 747 |
v2 := compiler.MapValueForKey(m, "value") |
| 748 |
if v2 != nil { |
| 749 |
var err error |
| 750 |
x.Value, err = NewMethod(v2, compiler.NewContext("value", v2, context)) |
| 751 |
if err != nil { |
| 752 |
errors = append(errors, err) |
| 753 |
} |
| 754 |
} |
| 755 |
} |
| 756 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 757 |
} |
| 758 |
|
| 759 |
// NewNamedParameter creates an object of type NamedParameter if possible, returning an error if not. |
| 760 |
func NewNamedParameter(in *yaml.Node, context *compiler.Context) (*NamedParameter, error) { |
| 761 |
errors := make([]error, 0) |
| 762 |
x := &NamedParameter{} |
| 763 |
m, ok := compiler.UnpackMap(in) |
| 764 |
if !ok { |
| 765 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 766 |
errors = append(errors, compiler.NewError(context, message)) |
| 767 |
} else { |
| 768 |
allowedKeys := []string{"name", "value"} |
| 769 |
var allowedPatterns []*regexp.Regexp |
| 770 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 771 |
if len(invalidKeys) > 0 { |
| 772 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 773 |
errors = append(errors, compiler.NewError(context, message)) |
| 774 |
} |
| 775 |
// string name = 1; |
| 776 |
v1 := compiler.MapValueForKey(m, "name") |
| 777 |
if v1 != nil { |
| 778 |
x.Name, ok = compiler.StringForScalarNode(v1) |
| 779 |
if !ok { |
| 780 |
message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) |
| 781 |
errors = append(errors, compiler.NewError(context, message)) |
| 782 |
} |
| 783 |
} |
| 784 |
// Parameter value = 2; |
| 785 |
v2 := compiler.MapValueForKey(m, "value") |
| 786 |
if v2 != nil { |
| 787 |
var err error |
| 788 |
x.Value, err = NewParameter(v2, compiler.NewContext("value", v2, context)) |
| 789 |
if err != nil { |
| 790 |
errors = append(errors, err) |
| 791 |
} |
| 792 |
} |
| 793 |
} |
| 794 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 795 |
} |
| 796 |
|
| 797 |
// NewNamedResource creates an object of type NamedResource if possible, returning an error if not. |
| 798 |
func NewNamedResource(in *yaml.Node, context *compiler.Context) (*NamedResource, error) { |
| 799 |
errors := make([]error, 0) |
| 800 |
x := &NamedResource{} |
| 801 |
m, ok := compiler.UnpackMap(in) |
| 802 |
if !ok { |
| 803 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 804 |
errors = append(errors, compiler.NewError(context, message)) |
| 805 |
} else { |
| 806 |
allowedKeys := []string{"name", "value"} |
| 807 |
var allowedPatterns []*regexp.Regexp |
| 808 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 809 |
if len(invalidKeys) > 0 { |
| 810 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 811 |
errors = append(errors, compiler.NewError(context, message)) |
| 812 |
} |
| 813 |
// string name = 1; |
| 814 |
v1 := compiler.MapValueForKey(m, "name") |
| 815 |
if v1 != nil { |
| 816 |
x.Name, ok = compiler.StringForScalarNode(v1) |
| 817 |
if !ok { |
| 818 |
message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) |
| 819 |
errors = append(errors, compiler.NewError(context, message)) |
| 820 |
} |
| 821 |
} |
| 822 |
// Resource value = 2; |
| 823 |
v2 := compiler.MapValueForKey(m, "value") |
| 824 |
if v2 != nil { |
| 825 |
var err error |
| 826 |
x.Value, err = NewResource(v2, compiler.NewContext("value", v2, context)) |
| 827 |
if err != nil { |
| 828 |
errors = append(errors, err) |
| 829 |
} |
| 830 |
} |
| 831 |
} |
| 832 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 833 |
} |
| 834 |
|
| 835 |
// NewNamedSchema creates an object of type NamedSchema if possible, returning an error if not. |
| 836 |
func NewNamedSchema(in *yaml.Node, context *compiler.Context) (*NamedSchema, error) { |
| 837 |
errors := make([]error, 0) |
| 838 |
x := &NamedSchema{} |
| 839 |
m, ok := compiler.UnpackMap(in) |
| 840 |
if !ok { |
| 841 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 842 |
errors = append(errors, compiler.NewError(context, message)) |
| 843 |
} else { |
| 844 |
allowedKeys := []string{"name", "value"} |
| 845 |
var allowedPatterns []*regexp.Regexp |
| 846 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 847 |
if len(invalidKeys) > 0 { |
| 848 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 849 |
errors = append(errors, compiler.NewError(context, message)) |
| 850 |
} |
| 851 |
// string name = 1; |
| 852 |
v1 := compiler.MapValueForKey(m, "name") |
| 853 |
if v1 != nil { |
| 854 |
x.Name, ok = compiler.StringForScalarNode(v1) |
| 855 |
if !ok { |
| 856 |
message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) |
| 857 |
errors = append(errors, compiler.NewError(context, message)) |
| 858 |
} |
| 859 |
} |
| 860 |
// Schema value = 2; |
| 861 |
v2 := compiler.MapValueForKey(m, "value") |
| 862 |
if v2 != nil { |
| 863 |
var err error |
| 864 |
x.Value, err = NewSchema(v2, compiler.NewContext("value", v2, context)) |
| 865 |
if err != nil { |
| 866 |
errors = append(errors, err) |
| 867 |
} |
| 868 |
} |
| 869 |
} |
| 870 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 871 |
} |
| 872 |
|
| 873 |
// NewNamedScope creates an object of type NamedScope if possible, returning an error if not. |
| 874 |
func NewNamedScope(in *yaml.Node, context *compiler.Context) (*NamedScope, error) { |
| 875 |
errors := make([]error, 0) |
| 876 |
x := &NamedScope{} |
| 877 |
m, ok := compiler.UnpackMap(in) |
| 878 |
if !ok { |
| 879 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 880 |
errors = append(errors, compiler.NewError(context, message)) |
| 881 |
} else { |
| 882 |
allowedKeys := []string{"name", "value"} |
| 883 |
var allowedPatterns []*regexp.Regexp |
| 884 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 885 |
if len(invalidKeys) > 0 { |
| 886 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 887 |
errors = append(errors, compiler.NewError(context, message)) |
| 888 |
} |
| 889 |
// string name = 1; |
| 890 |
v1 := compiler.MapValueForKey(m, "name") |
| 891 |
if v1 != nil { |
| 892 |
x.Name, ok = compiler.StringForScalarNode(v1) |
| 893 |
if !ok { |
| 894 |
message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) |
| 895 |
errors = append(errors, compiler.NewError(context, message)) |
| 896 |
} |
| 897 |
} |
| 898 |
// Scope value = 2; |
| 899 |
v2 := compiler.MapValueForKey(m, "value") |
| 900 |
if v2 != nil { |
| 901 |
var err error |
| 902 |
x.Value, err = NewScope(v2, compiler.NewContext("value", v2, context)) |
| 903 |
if err != nil { |
| 904 |
errors = append(errors, err) |
| 905 |
} |
| 906 |
} |
| 907 |
} |
| 908 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 909 |
} |
| 910 |
|
| 911 |
// NewOauth2 creates an object of type Oauth2 if possible, returning an error if not. |
| 912 |
func NewOauth2(in *yaml.Node, context *compiler.Context) (*Oauth2, error) { |
| 913 |
errors := make([]error, 0) |
| 914 |
x := &Oauth2{} |
| 915 |
m, ok := compiler.UnpackMap(in) |
| 916 |
if !ok { |
| 917 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 918 |
errors = append(errors, compiler.NewError(context, message)) |
| 919 |
} else { |
| 920 |
allowedKeys := []string{"scopes"} |
| 921 |
var allowedPatterns []*regexp.Regexp |
| 922 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 923 |
if len(invalidKeys) > 0 { |
| 924 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 925 |
errors = append(errors, compiler.NewError(context, message)) |
| 926 |
} |
| 927 |
// Scopes scopes = 1; |
| 928 |
v1 := compiler.MapValueForKey(m, "scopes") |
| 929 |
if v1 != nil { |
| 930 |
var err error |
| 931 |
x.Scopes, err = NewScopes(v1, compiler.NewContext("scopes", v1, context)) |
| 932 |
if err != nil { |
| 933 |
errors = append(errors, err) |
| 934 |
} |
| 935 |
} |
| 936 |
} |
| 937 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 938 |
} |
| 939 |
|
| 940 |
// NewParameter creates an object of type Parameter if possible, returning an error if not. |
| 941 |
func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) { |
| 942 |
errors := make([]error, 0) |
| 943 |
x := &Parameter{} |
| 944 |
m, ok := compiler.UnpackMap(in) |
| 945 |
if !ok { |
| 946 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 947 |
errors = append(errors, compiler.NewError(context, message)) |
| 948 |
} else { |
| 949 |
allowedKeys := []string{"$ref", "additionalProperties", "annotations", "default", "description", "enum", "enumDescriptions", "format", "id", "items", "location", "maximum", "minimum", "pattern", "properties", "repeated", "required", "type"} |
| 950 |
var allowedPatterns []*regexp.Regexp |
| 951 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 952 |
if len(invalidKeys) > 0 { |
| 953 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 954 |
errors = append(errors, compiler.NewError(context, message)) |
| 955 |
} |
| 956 |
// string id = 1; |
| 957 |
v1 := compiler.MapValueForKey(m, "id") |
| 958 |
if v1 != nil { |
| 959 |
x.Id, ok = compiler.StringForScalarNode(v1) |
| 960 |
if !ok { |
| 961 |
message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) |
| 962 |
errors = append(errors, compiler.NewError(context, message)) |
| 963 |
} |
| 964 |
} |
| 965 |
// string type = 2; |
| 966 |
v2 := compiler.MapValueForKey(m, "type") |
| 967 |
if v2 != nil { |
| 968 |
x.Type, ok = compiler.StringForScalarNode(v2) |
| 969 |
if !ok { |
| 970 |
message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v2)) |
| 971 |
errors = append(errors, compiler.NewError(context, message)) |
| 972 |
} |
| 973 |
} |
| 974 |
// string _ref = 3; |
| 975 |
v3 := compiler.MapValueForKey(m, "$ref") |
| 976 |
if v3 != nil { |
| 977 |
x.XRef, ok = compiler.StringForScalarNode(v3) |
| 978 |
if !ok { |
| 979 |
message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v3)) |
| 980 |
errors = append(errors, compiler.NewError(context, message)) |
| 981 |
} |
| 982 |
} |
| 983 |
// string description = 4; |
| 984 |
v4 := compiler.MapValueForKey(m, "description") |
| 985 |
if v4 != nil { |
| 986 |
x.Description, ok = compiler.StringForScalarNode(v4) |
| 987 |
if !ok { |
| 988 |
message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) |
| 989 |
errors = append(errors, compiler.NewError(context, message)) |
| 990 |
} |
| 991 |
} |
| 992 |
// string default = 5; |
| 993 |
v5 := compiler.MapValueForKey(m, "default") |
| 994 |
if v5 != nil { |
| 995 |
x.Default, ok = compiler.StringForScalarNode(v5) |
| 996 |
if !ok { |
| 997 |
message := fmt.Sprintf("has unexpected value for default: %s", compiler.Display(v5)) |
| 998 |
errors = append(errors, compiler.NewError(context, message)) |
| 999 |
} |
| 1000 |
} |
| 1001 |
// bool required = 6; |
| 1002 |
v6 := compiler.MapValueForKey(m, "required") |
| 1003 |
if v6 != nil { |
| 1004 |
x.Required, ok = compiler.BoolForScalarNode(v6) |
| 1005 |
if !ok { |
| 1006 |
message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v6)) |
| 1007 |
errors = append(errors, compiler.NewError(context, message)) |
| 1008 |
} |
| 1009 |
} |
| 1010 |
// string format = 7; |
| 1011 |
v7 := compiler.MapValueForKey(m, "format") |
| 1012 |
if v7 != nil { |
| 1013 |
x.Format, ok = compiler.StringForScalarNode(v7) |
| 1014 |
if !ok { |
| 1015 |
message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v7)) |
| 1016 |
errors = append(errors, compiler.NewError(context, message)) |
| 1017 |
} |
| 1018 |
} |
| 1019 |
// string pattern = 8; |
| 1020 |
v8 := compiler.MapValueForKey(m, "pattern") |
| 1021 |
if v8 != nil { |
| 1022 |
x.Pattern, ok = compiler.StringForScalarNode(v8) |
| 1023 |
if !ok { |
| 1024 |
message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v8)) |
| 1025 |
errors = append(errors, compiler.NewError(context, message)) |
| 1026 |
} |
| 1027 |
} |
| 1028 |
// string minimum = 9; |
| 1029 |
v9 := compiler.MapValueForKey(m, "minimum") |
| 1030 |
if v9 != nil { |
| 1031 |
x.Minimum, ok = compiler.StringForScalarNode(v9) |
| 1032 |
if !ok { |
| 1033 |
message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v9)) |
| 1034 |
errors = append(errors, compiler.NewError(context, message)) |
| 1035 |
} |
| 1036 |
} |
| 1037 |
// string maximum = 10; |
| 1038 |
v10 := compiler.MapValueForKey(m, "maximum") |
| 1039 |
if v10 != nil { |
| 1040 |
x.Maximum, ok = compiler.StringForScalarNode(v10) |
| 1041 |
if !ok { |
| 1042 |
message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v10)) |
| 1043 |
errors = append(errors, compiler.NewError(context, message)) |
| 1044 |
} |
| 1045 |
} |
| 1046 |
// repeated string enum = 11; |
| 1047 |
v11 := compiler.MapValueForKey(m, "enum") |
| 1048 |
if v11 != nil { |
| 1049 |
v, ok := compiler.SequenceNodeForNode(v11) |
| 1050 |
if ok { |
| 1051 |
x.Enum = compiler.StringArrayForSequenceNode(v) |
| 1052 |
} else { |
| 1053 |
message := fmt.Sprintf("has unexpected value for enum: %s", compiler.Display(v11)) |
| 1054 |
errors = append(errors, compiler.NewError(context, message)) |
| 1055 |
} |
| 1056 |
} |
| 1057 |
// repeated string enum_descriptions = 12; |
| 1058 |
v12 := compiler.MapValueForKey(m, "enumDescriptions") |
| 1059 |
if v12 != nil { |
| 1060 |
v, ok := compiler.SequenceNodeForNode(v12) |
| 1061 |
if ok { |
| 1062 |
x.EnumDescriptions = compiler.StringArrayForSequenceNode(v) |
| 1063 |
} else { |
| 1064 |
message := fmt.Sprintf("has unexpected value for enumDescriptions: %s", compiler.Display(v12)) |
| 1065 |
errors = append(errors, compiler.NewError(context, message)) |
| 1066 |
} |
| 1067 |
} |
| 1068 |
// bool repeated = 13; |
| 1069 |
v13 := compiler.MapValueForKey(m, "repeated") |
| 1070 |
if v13 != nil { |
| 1071 |
x.Repeated, ok = compiler.BoolForScalarNode(v13) |
| 1072 |
if !ok { |
| 1073 |
message := fmt.Sprintf("has unexpected value for repeated: %s", compiler.Display(v13)) |
| 1074 |
errors = append(errors, compiler.NewError(context, message)) |
| 1075 |
} |
| 1076 |
} |
| 1077 |
// string location = 14; |
| 1078 |
v14 := compiler.MapValueForKey(m, "location") |
| 1079 |
if v14 != nil { |
| 1080 |
x.Location, ok = compiler.StringForScalarNode(v14) |
| 1081 |
if !ok { |
| 1082 |
message := fmt.Sprintf("has unexpected value for location: %s", compiler.Display(v14)) |
| 1083 |
errors = append(errors, compiler.NewError(context, message)) |
| 1084 |
} |
| 1085 |
} |
| 1086 |
// Schemas properties = 15; |
| 1087 |
v15 := compiler.MapValueForKey(m, "properties") |
| 1088 |
if v15 != nil { |
| 1089 |
var err error |
| 1090 |
x.Properties, err = NewSchemas(v15, compiler.NewContext("properties", v15, context)) |
| 1091 |
if err != nil { |
| 1092 |
errors = append(errors, err) |
| 1093 |
} |
| 1094 |
} |
| 1095 |
// Schema additional_properties = 16; |
| 1096 |
v16 := compiler.MapValueForKey(m, "additionalProperties") |
| 1097 |
if v16 != nil { |
| 1098 |
var err error |
| 1099 |
x.AdditionalProperties, err = NewSchema(v16, compiler.NewContext("additionalProperties", v16, context)) |
| 1100 |
if err != nil { |
| 1101 |
errors = append(errors, err) |
| 1102 |
} |
| 1103 |
} |
| 1104 |
// Schema items = 17; |
| 1105 |
v17 := compiler.MapValueForKey(m, "items") |
| 1106 |
if v17 != nil { |
| 1107 |
var err error |
| 1108 |
x.Items, err = NewSchema(v17, compiler.NewContext("items", v17, context)) |
| 1109 |
if err != nil { |
| 1110 |
errors = append(errors, err) |
| 1111 |
} |
| 1112 |
} |
| 1113 |
// Annotations annotations = 18; |
| 1114 |
v18 := compiler.MapValueForKey(m, "annotations") |
| 1115 |
if v18 != nil { |
| 1116 |
var err error |
| 1117 |
x.Annotations, err = NewAnnotations(v18, compiler.NewContext("annotations", v18, context)) |
| 1118 |
if err != nil { |
| 1119 |
errors = append(errors, err) |
| 1120 |
} |
| 1121 |
} |
| 1122 |
} |
| 1123 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1124 |
} |
| 1125 |
|
| 1126 |
// NewParameters creates an object of type Parameters if possible, returning an error if not. |
| 1127 |
func NewParameters(in *yaml.Node, context *compiler.Context) (*Parameters, error) { |
| 1128 |
errors := make([]error, 0) |
| 1129 |
x := &Parameters{} |
| 1130 |
m, ok := compiler.UnpackMap(in) |
| 1131 |
if !ok { |
| 1132 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1133 |
errors = append(errors, compiler.NewError(context, message)) |
| 1134 |
} else { |
| 1135 |
// repeated NamedParameter additional_properties = 1; |
| 1136 |
// MAP: Parameter |
| 1137 |
x.AdditionalProperties = make([]*NamedParameter, 0) |
| 1138 |
for i := 0; i < len(m.Content); i += 2 { |
| 1139 |
k, ok := compiler.StringForScalarNode(m.Content[i]) |
| 1140 |
if ok { |
| 1141 |
v := m.Content[i+1] |
| 1142 |
pair := &NamedParameter{} |
| 1143 |
pair.Name = k |
| 1144 |
var err error |
| 1145 |
pair.Value, err = NewParameter(v, compiler.NewContext(k, v, context)) |
| 1146 |
if err != nil { |
| 1147 |
errors = append(errors, err) |
| 1148 |
} |
| 1149 |
x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 1150 |
} |
| 1151 |
} |
| 1152 |
} |
| 1153 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1154 |
} |
| 1155 |
|
| 1156 |
// NewProtocols creates an object of type Protocols if possible, returning an error if not. |
| 1157 |
func NewProtocols(in *yaml.Node, context *compiler.Context) (*Protocols, error) { |
| 1158 |
errors := make([]error, 0) |
| 1159 |
x := &Protocols{} |
| 1160 |
m, ok := compiler.UnpackMap(in) |
| 1161 |
if !ok { |
| 1162 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1163 |
errors = append(errors, compiler.NewError(context, message)) |
| 1164 |
} else { |
| 1165 |
allowedKeys := []string{"resumable", "simple"} |
| 1166 |
var allowedPatterns []*regexp.Regexp |
| 1167 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1168 |
if len(invalidKeys) > 0 { |
| 1169 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1170 |
errors = append(errors, compiler.NewError(context, message)) |
| 1171 |
} |
| 1172 |
// Simple simple = 1; |
| 1173 |
v1 := compiler.MapValueForKey(m, "simple") |
| 1174 |
if v1 != nil { |
| 1175 |
var err error |
| 1176 |
x.Simple, err = NewSimple(v1, compiler.NewContext("simple", v1, context)) |
| 1177 |
if err != nil { |
| 1178 |
errors = append(errors, err) |
| 1179 |
} |
| 1180 |
} |
| 1181 |
// Resumable resumable = 2; |
| 1182 |
v2 := compiler.MapValueForKey(m, "resumable") |
| 1183 |
if v2 != nil { |
| 1184 |
var err error |
| 1185 |
x.Resumable, err = NewResumable(v2, compiler.NewContext("resumable", v2, context)) |
| 1186 |
if err != nil { |
| 1187 |
errors = append(errors, err) |
| 1188 |
} |
| 1189 |
} |
| 1190 |
} |
| 1191 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1192 |
} |
| 1193 |
|
| 1194 |
// NewRequest creates an object of type Request if possible, returning an error if not. |
| 1195 |
func NewRequest(in *yaml.Node, context *compiler.Context) (*Request, error) { |
| 1196 |
errors := make([]error, 0) |
| 1197 |
x := &Request{} |
| 1198 |
m, ok := compiler.UnpackMap(in) |
| 1199 |
if !ok { |
| 1200 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1201 |
errors = append(errors, compiler.NewError(context, message)) |
| 1202 |
} else { |
| 1203 |
allowedKeys := []string{"$ref", "parameterName"} |
| 1204 |
var allowedPatterns []*regexp.Regexp |
| 1205 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1206 |
if len(invalidKeys) > 0 { |
| 1207 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1208 |
errors = append(errors, compiler.NewError(context, message)) |
| 1209 |
} |
| 1210 |
// string _ref = 1; |
| 1211 |
v1 := compiler.MapValueForKey(m, "$ref") |
| 1212 |
if v1 != nil { |
| 1213 |
x.XRef, ok = compiler.StringForScalarNode(v1) |
| 1214 |
if !ok { |
| 1215 |
message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) |
| 1216 |
errors = append(errors, compiler.NewError(context, message)) |
| 1217 |
} |
| 1218 |
} |
| 1219 |
// string parameter_name = 2; |
| 1220 |
v2 := compiler.MapValueForKey(m, "parameterName") |
| 1221 |
if v2 != nil { |
| 1222 |
x.ParameterName, ok = compiler.StringForScalarNode(v2) |
| 1223 |
if !ok { |
| 1224 |
message := fmt.Sprintf("has unexpected value for parameterName: %s", compiler.Display(v2)) |
| 1225 |
errors = append(errors, compiler.NewError(context, message)) |
| 1226 |
} |
| 1227 |
} |
| 1228 |
} |
| 1229 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1230 |
} |
| 1231 |
|
| 1232 |
// NewResource creates an object of type Resource if possible, returning an error if not. |
| 1233 |
func NewResource(in *yaml.Node, context *compiler.Context) (*Resource, error) { |
| 1234 |
errors := make([]error, 0) |
| 1235 |
x := &Resource{} |
| 1236 |
m, ok := compiler.UnpackMap(in) |
| 1237 |
if !ok { |
| 1238 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1239 |
errors = append(errors, compiler.NewError(context, message)) |
| 1240 |
} else { |
| 1241 |
allowedKeys := []string{"methods", "resources"} |
| 1242 |
var allowedPatterns []*regexp.Regexp |
| 1243 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1244 |
if len(invalidKeys) > 0 { |
| 1245 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1246 |
errors = append(errors, compiler.NewError(context, message)) |
| 1247 |
} |
| 1248 |
// Methods methods = 1; |
| 1249 |
v1 := compiler.MapValueForKey(m, "methods") |
| 1250 |
if v1 != nil { |
| 1251 |
var err error |
| 1252 |
x.Methods, err = NewMethods(v1, compiler.NewContext("methods", v1, context)) |
| 1253 |
if err != nil { |
| 1254 |
errors = append(errors, err) |
| 1255 |
} |
| 1256 |
} |
| 1257 |
// Resources resources = 2; |
| 1258 |
v2 := compiler.MapValueForKey(m, "resources") |
| 1259 |
if v2 != nil { |
| 1260 |
var err error |
| 1261 |
x.Resources, err = NewResources(v2, compiler.NewContext("resources", v2, context)) |
| 1262 |
if err != nil { |
| 1263 |
errors = append(errors, err) |
| 1264 |
} |
| 1265 |
} |
| 1266 |
} |
| 1267 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1268 |
} |
| 1269 |
|
| 1270 |
// NewResources creates an object of type Resources if possible, returning an error if not. |
| 1271 |
func NewResources(in *yaml.Node, context *compiler.Context) (*Resources, error) { |
| 1272 |
errors := make([]error, 0) |
| 1273 |
x := &Resources{} |
| 1274 |
m, ok := compiler.UnpackMap(in) |
| 1275 |
if !ok { |
| 1276 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1277 |
errors = append(errors, compiler.NewError(context, message)) |
| 1278 |
} else { |
| 1279 |
// repeated NamedResource additional_properties = 1; |
| 1280 |
// MAP: Resource |
| 1281 |
x.AdditionalProperties = make([]*NamedResource, 0) |
| 1282 |
for i := 0; i < len(m.Content); i += 2 { |
| 1283 |
k, ok := compiler.StringForScalarNode(m.Content[i]) |
| 1284 |
if ok { |
| 1285 |
v := m.Content[i+1] |
| 1286 |
pair := &NamedResource{} |
| 1287 |
pair.Name = k |
| 1288 |
var err error |
| 1289 |
pair.Value, err = NewResource(v, compiler.NewContext(k, v, context)) |
| 1290 |
if err != nil { |
| 1291 |
errors = append(errors, err) |
| 1292 |
} |
| 1293 |
x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 1294 |
} |
| 1295 |
} |
| 1296 |
} |
| 1297 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1298 |
} |
| 1299 |
|
| 1300 |
// NewResponse creates an object of type Response if possible, returning an error if not. |
| 1301 |
func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { |
| 1302 |
errors := make([]error, 0) |
| 1303 |
x := &Response{} |
| 1304 |
m, ok := compiler.UnpackMap(in) |
| 1305 |
if !ok { |
| 1306 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1307 |
errors = append(errors, compiler.NewError(context, message)) |
| 1308 |
} else { |
| 1309 |
allowedKeys := []string{"$ref"} |
| 1310 |
var allowedPatterns []*regexp.Regexp |
| 1311 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1312 |
if len(invalidKeys) > 0 { |
| 1313 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1314 |
errors = append(errors, compiler.NewError(context, message)) |
| 1315 |
} |
| 1316 |
// string _ref = 1; |
| 1317 |
v1 := compiler.MapValueForKey(m, "$ref") |
| 1318 |
if v1 != nil { |
| 1319 |
x.XRef, ok = compiler.StringForScalarNode(v1) |
| 1320 |
if !ok { |
| 1321 |
message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) |
| 1322 |
errors = append(errors, compiler.NewError(context, message)) |
| 1323 |
} |
| 1324 |
} |
| 1325 |
} |
| 1326 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1327 |
} |
| 1328 |
|
| 1329 |
// NewResumable creates an object of type Resumable if possible, returning an error if not. |
| 1330 |
func NewResumable(in *yaml.Node, context *compiler.Context) (*Resumable, error) { |
| 1331 |
errors := make([]error, 0) |
| 1332 |
x := &Resumable{} |
| 1333 |
m, ok := compiler.UnpackMap(in) |
| 1334 |
if !ok { |
| 1335 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1336 |
errors = append(errors, compiler.NewError(context, message)) |
| 1337 |
} else { |
| 1338 |
allowedKeys := []string{"multipart", "path"} |
| 1339 |
var allowedPatterns []*regexp.Regexp |
| 1340 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1341 |
if len(invalidKeys) > 0 { |
| 1342 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1343 |
errors = append(errors, compiler.NewError(context, message)) |
| 1344 |
} |
| 1345 |
// bool multipart = 1; |
| 1346 |
v1 := compiler.MapValueForKey(m, "multipart") |
| 1347 |
if v1 != nil { |
| 1348 |
x.Multipart, ok = compiler.BoolForScalarNode(v1) |
| 1349 |
if !ok { |
| 1350 |
message := fmt.Sprintf("has unexpected value for multipart: %s", compiler.Display(v1)) |
| 1351 |
errors = append(errors, compiler.NewError(context, message)) |
| 1352 |
} |
| 1353 |
} |
| 1354 |
// string path = 2; |
| 1355 |
v2 := compiler.MapValueForKey(m, "path") |
| 1356 |
if v2 != nil { |
| 1357 |
x.Path, ok = compiler.StringForScalarNode(v2) |
| 1358 |
if !ok { |
| 1359 |
message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) |
| 1360 |
errors = append(errors, compiler.NewError(context, message)) |
| 1361 |
} |
| 1362 |
} |
| 1363 |
} |
| 1364 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1365 |
} |
| 1366 |
|
| 1367 |
// NewSchema creates an object of type Schema if possible, returning an error if not. |
| 1368 |
func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { |
| 1369 |
errors := make([]error, 0) |
| 1370 |
x := &Schema{} |
| 1371 |
m, ok := compiler.UnpackMap(in) |
| 1372 |
if !ok { |
| 1373 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1374 |
errors = append(errors, compiler.NewError(context, message)) |
| 1375 |
} else { |
| 1376 |
allowedKeys := []string{"$ref", "additionalProperties", "annotations", "default", "description", "enum", "enumDescriptions", "format", "id", "items", "location", "maximum", "minimum", "pattern", "properties", "readOnly", "repeated", "required", "type"} |
| 1377 |
var allowedPatterns []*regexp.Regexp |
| 1378 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1379 |
if len(invalidKeys) > 0 { |
| 1380 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1381 |
errors = append(errors, compiler.NewError(context, message)) |
| 1382 |
} |
| 1383 |
// string id = 1; |
| 1384 |
v1 := compiler.MapValueForKey(m, "id") |
| 1385 |
if v1 != nil { |
| 1386 |
x.Id, ok = compiler.StringForScalarNode(v1) |
| 1387 |
if !ok { |
| 1388 |
message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) |
| 1389 |
errors = append(errors, compiler.NewError(context, message)) |
| 1390 |
} |
| 1391 |
} |
| 1392 |
// string type = 2; |
| 1393 |
v2 := compiler.MapValueForKey(m, "type") |
| 1394 |
if v2 != nil { |
| 1395 |
x.Type, ok = compiler.StringForScalarNode(v2) |
| 1396 |
if !ok { |
| 1397 |
message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v2)) |
| 1398 |
errors = append(errors, compiler.NewError(context, message)) |
| 1399 |
} |
| 1400 |
} |
| 1401 |
// string description = 3; |
| 1402 |
v3 := compiler.MapValueForKey(m, "description") |
| 1403 |
if v3 != nil { |
| 1404 |
x.Description, ok = compiler.StringForScalarNode(v3) |
| 1405 |
if !ok { |
| 1406 |
message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) |
| 1407 |
errors = append(errors, compiler.NewError(context, message)) |
| 1408 |
} |
| 1409 |
} |
| 1410 |
// string default = 4; |
| 1411 |
v4 := compiler.MapValueForKey(m, "default") |
| 1412 |
if v4 != nil { |
| 1413 |
x.Default, ok = compiler.StringForScalarNode(v4) |
| 1414 |
if !ok { |
| 1415 |
message := fmt.Sprintf("has unexpected value for default: %s", compiler.Display(v4)) |
| 1416 |
errors = append(errors, compiler.NewError(context, message)) |
| 1417 |
} |
| 1418 |
} |
| 1419 |
// bool required = 5; |
| 1420 |
v5 := compiler.MapValueForKey(m, "required") |
| 1421 |
if v5 != nil { |
| 1422 |
x.Required, ok = compiler.BoolForScalarNode(v5) |
| 1423 |
if !ok { |
| 1424 |
message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v5)) |
| 1425 |
errors = append(errors, compiler.NewError(context, message)) |
| 1426 |
} |
| 1427 |
} |
| 1428 |
// string format = 6; |
| 1429 |
v6 := compiler.MapValueForKey(m, "format") |
| 1430 |
if v6 != nil { |
| 1431 |
x.Format, ok = compiler.StringForScalarNode(v6) |
| 1432 |
if !ok { |
| 1433 |
message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v6)) |
| 1434 |
errors = append(errors, compiler.NewError(context, message)) |
| 1435 |
} |
| 1436 |
} |
| 1437 |
// string pattern = 7; |
| 1438 |
v7 := compiler.MapValueForKey(m, "pattern") |
| 1439 |
if v7 != nil { |
| 1440 |
x.Pattern, ok = compiler.StringForScalarNode(v7) |
| 1441 |
if !ok { |
| 1442 |
message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v7)) |
| 1443 |
errors = append(errors, compiler.NewError(context, message)) |
| 1444 |
} |
| 1445 |
} |
| 1446 |
// string minimum = 8; |
| 1447 |
v8 := compiler.MapValueForKey(m, "minimum") |
| 1448 |
if v8 != nil { |
| 1449 |
x.Minimum, ok = compiler.StringForScalarNode(v8) |
| 1450 |
if !ok { |
| 1451 |
message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v8)) |
| 1452 |
errors = append(errors, compiler.NewError(context, message)) |
| 1453 |
} |
| 1454 |
} |
| 1455 |
// string maximum = 9; |
| 1456 |
v9 := compiler.MapValueForKey(m, "maximum") |
| 1457 |
if v9 != nil { |
| 1458 |
x.Maximum, ok = compiler.StringForScalarNode(v9) |
| 1459 |
if !ok { |
| 1460 |
message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v9)) |
| 1461 |
errors = append(errors, compiler.NewError(context, message)) |
| 1462 |
} |
| 1463 |
} |
| 1464 |
// repeated string enum = 10; |
| 1465 |
v10 := compiler.MapValueForKey(m, "enum") |
| 1466 |
if v10 != nil { |
| 1467 |
v, ok := compiler.SequenceNodeForNode(v10) |
| 1468 |
if ok { |
| 1469 |
x.Enum = compiler.StringArrayForSequenceNode(v) |
| 1470 |
} else { |
| 1471 |
message := fmt.Sprintf("has unexpected value for enum: %s", compiler.Display(v10)) |
| 1472 |
errors = append(errors, compiler.NewError(context, message)) |
| 1473 |
} |
| 1474 |
} |
| 1475 |
// repeated string enum_descriptions = 11; |
| 1476 |
v11 := compiler.MapValueForKey(m, "enumDescriptions") |
| 1477 |
if v11 != nil { |
| 1478 |
v, ok := compiler.SequenceNodeForNode(v11) |
| 1479 |
if ok { |
| 1480 |
x.EnumDescriptions = compiler.StringArrayForSequenceNode(v) |
| 1481 |
} else { |
| 1482 |
message := fmt.Sprintf("has unexpected value for enumDescriptions: %s", compiler.Display(v11)) |
| 1483 |
errors = append(errors, compiler.NewError(context, message)) |
| 1484 |
} |
| 1485 |
} |
| 1486 |
// bool repeated = 12; |
| 1487 |
v12 := compiler.MapValueForKey(m, "repeated") |
| 1488 |
if v12 != nil { |
| 1489 |
x.Repeated, ok = compiler.BoolForScalarNode(v12) |
| 1490 |
if !ok { |
| 1491 |
message := fmt.Sprintf("has unexpected value for repeated: %s", compiler.Display(v12)) |
| 1492 |
errors = append(errors, compiler.NewError(context, message)) |
| 1493 |
} |
| 1494 |
} |
| 1495 |
// string location = 13; |
| 1496 |
v13 := compiler.MapValueForKey(m, "location") |
| 1497 |
if v13 != nil { |
| 1498 |
x.Location, ok = compiler.StringForScalarNode(v13) |
| 1499 |
if !ok { |
| 1500 |
message := fmt.Sprintf("has unexpected value for location: %s", compiler.Display(v13)) |
| 1501 |
errors = append(errors, compiler.NewError(context, message)) |
| 1502 |
} |
| 1503 |
} |
| 1504 |
// Schemas properties = 14; |
| 1505 |
v14 := compiler.MapValueForKey(m, "properties") |
| 1506 |
if v14 != nil { |
| 1507 |
var err error |
| 1508 |
x.Properties, err = NewSchemas(v14, compiler.NewContext("properties", v14, context)) |
| 1509 |
if err != nil { |
| 1510 |
errors = append(errors, err) |
| 1511 |
} |
| 1512 |
} |
| 1513 |
// Schema additional_properties = 15; |
| 1514 |
v15 := compiler.MapValueForKey(m, "additionalProperties") |
| 1515 |
if v15 != nil { |
| 1516 |
var err error |
| 1517 |
x.AdditionalProperties, err = NewSchema(v15, compiler.NewContext("additionalProperties", v15, context)) |
| 1518 |
if err != nil { |
| 1519 |
errors = append(errors, err) |
| 1520 |
} |
| 1521 |
} |
| 1522 |
// Schema items = 16; |
| 1523 |
v16 := compiler.MapValueForKey(m, "items") |
| 1524 |
if v16 != nil { |
| 1525 |
var err error |
| 1526 |
x.Items, err = NewSchema(v16, compiler.NewContext("items", v16, context)) |
| 1527 |
if err != nil { |
| 1528 |
errors = append(errors, err) |
| 1529 |
} |
| 1530 |
} |
| 1531 |
// string _ref = 17; |
| 1532 |
v17 := compiler.MapValueForKey(m, "$ref") |
| 1533 |
if v17 != nil { |
| 1534 |
x.XRef, ok = compiler.StringForScalarNode(v17) |
| 1535 |
if !ok { |
| 1536 |
message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v17)) |
| 1537 |
errors = append(errors, compiler.NewError(context, message)) |
| 1538 |
} |
| 1539 |
} |
| 1540 |
// Annotations annotations = 18; |
| 1541 |
v18 := compiler.MapValueForKey(m, "annotations") |
| 1542 |
if v18 != nil { |
| 1543 |
var err error |
| 1544 |
x.Annotations, err = NewAnnotations(v18, compiler.NewContext("annotations", v18, context)) |
| 1545 |
if err != nil { |
| 1546 |
errors = append(errors, err) |
| 1547 |
} |
| 1548 |
} |
| 1549 |
// bool read_only = 19; |
| 1550 |
v19 := compiler.MapValueForKey(m, "readOnly") |
| 1551 |
if v19 != nil { |
| 1552 |
x.ReadOnly, ok = compiler.BoolForScalarNode(v19) |
| 1553 |
if !ok { |
| 1554 |
message := fmt.Sprintf("has unexpected value for readOnly: %s", compiler.Display(v19)) |
| 1555 |
errors = append(errors, compiler.NewError(context, message)) |
| 1556 |
} |
| 1557 |
} |
| 1558 |
} |
| 1559 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1560 |
} |
| 1561 |
|
| 1562 |
// NewSchemas creates an object of type Schemas if possible, returning an error if not. |
| 1563 |
func NewSchemas(in *yaml.Node, context *compiler.Context) (*Schemas, error) { |
| 1564 |
errors := make([]error, 0) |
| 1565 |
x := &Schemas{} |
| 1566 |
m, ok := compiler.UnpackMap(in) |
| 1567 |
if !ok { |
| 1568 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1569 |
errors = append(errors, compiler.NewError(context, message)) |
| 1570 |
} else { |
| 1571 |
// repeated NamedSchema additional_properties = 1; |
| 1572 |
// MAP: Schema |
| 1573 |
x.AdditionalProperties = make([]*NamedSchema, 0) |
| 1574 |
for i := 0; i < len(m.Content); i += 2 { |
| 1575 |
k, ok := compiler.StringForScalarNode(m.Content[i]) |
| 1576 |
if ok { |
| 1577 |
v := m.Content[i+1] |
| 1578 |
pair := &NamedSchema{} |
| 1579 |
pair.Name = k |
| 1580 |
var err error |
| 1581 |
pair.Value, err = NewSchema(v, compiler.NewContext(k, v, context)) |
| 1582 |
if err != nil { |
| 1583 |
errors = append(errors, err) |
| 1584 |
} |
| 1585 |
x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 1586 |
} |
| 1587 |
} |
| 1588 |
} |
| 1589 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1590 |
} |
| 1591 |
|
| 1592 |
// NewScope creates an object of type Scope if possible, returning an error if not. |
| 1593 |
func NewScope(in *yaml.Node, context *compiler.Context) (*Scope, error) { |
| 1594 |
errors := make([]error, 0) |
| 1595 |
x := &Scope{} |
| 1596 |
m, ok := compiler.UnpackMap(in) |
| 1597 |
if !ok { |
| 1598 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1599 |
errors = append(errors, compiler.NewError(context, message)) |
| 1600 |
} else { |
| 1601 |
allowedKeys := []string{"description"} |
| 1602 |
var allowedPatterns []*regexp.Regexp |
| 1603 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1604 |
if len(invalidKeys) > 0 { |
| 1605 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1606 |
errors = append(errors, compiler.NewError(context, message)) |
| 1607 |
} |
| 1608 |
// string description = 1; |
| 1609 |
v1 := compiler.MapValueForKey(m, "description") |
| 1610 |
if v1 != nil { |
| 1611 |
x.Description, ok = compiler.StringForScalarNode(v1) |
| 1612 |
if !ok { |
| 1613 |
message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) |
| 1614 |
errors = append(errors, compiler.NewError(context, message)) |
| 1615 |
} |
| 1616 |
} |
| 1617 |
} |
| 1618 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1619 |
} |
| 1620 |
|
| 1621 |
// NewScopes creates an object of type Scopes if possible, returning an error if not. |
| 1622 |
func NewScopes(in *yaml.Node, context *compiler.Context) (*Scopes, error) { |
| 1623 |
errors := make([]error, 0) |
| 1624 |
x := &Scopes{} |
| 1625 |
m, ok := compiler.UnpackMap(in) |
| 1626 |
if !ok { |
| 1627 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1628 |
errors = append(errors, compiler.NewError(context, message)) |
| 1629 |
} else { |
| 1630 |
// repeated NamedScope additional_properties = 1; |
| 1631 |
// MAP: Scope |
| 1632 |
x.AdditionalProperties = make([]*NamedScope, 0) |
| 1633 |
for i := 0; i < len(m.Content); i += 2 { |
| 1634 |
k, ok := compiler.StringForScalarNode(m.Content[i]) |
| 1635 |
if ok { |
| 1636 |
v := m.Content[i+1] |
| 1637 |
pair := &NamedScope{} |
| 1638 |
pair.Name = k |
| 1639 |
var err error |
| 1640 |
pair.Value, err = NewScope(v, compiler.NewContext(k, v, context)) |
| 1641 |
if err != nil { |
| 1642 |
errors = append(errors, err) |
| 1643 |
} |
| 1644 |
x.AdditionalProperties = append(x.AdditionalProperties, pair) |
| 1645 |
} |
| 1646 |
} |
| 1647 |
} |
| 1648 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1649 |
} |
| 1650 |
|
| 1651 |
// NewSimple creates an object of type Simple if possible, returning an error if not. |
| 1652 |
func NewSimple(in *yaml.Node, context *compiler.Context) (*Simple, error) { |
| 1653 |
errors := make([]error, 0) |
| 1654 |
x := &Simple{} |
| 1655 |
m, ok := compiler.UnpackMap(in) |
| 1656 |
if !ok { |
| 1657 |
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in) |
| 1658 |
errors = append(errors, compiler.NewError(context, message)) |
| 1659 |
} else { |
| 1660 |
allowedKeys := []string{"multipart", "path"} |
| 1661 |
var allowedPatterns []*regexp.Regexp |
| 1662 |
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) |
| 1663 |
if len(invalidKeys) > 0 { |
| 1664 |
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) |
| 1665 |
errors = append(errors, compiler.NewError(context, message)) |
| 1666 |
} |
| 1667 |
// bool multipart = 1; |
| 1668 |
v1 := compiler.MapValueForKey(m, "multipart") |
| 1669 |
if v1 != nil { |
| 1670 |
x.Multipart, ok = compiler.BoolForScalarNode(v1) |
| 1671 |
if !ok { |
| 1672 |
message := fmt.Sprintf("has unexpected value for multipart: %s", compiler.Display(v1)) |
| 1673 |
errors = append(errors, compiler.NewError(context, message)) |
| 1674 |
} |
| 1675 |
} |
| 1676 |
// string path = 2; |
| 1677 |
v2 := compiler.MapValueForKey(m, "path") |
| 1678 |
if v2 != nil { |
| 1679 |
x.Path, ok = compiler.StringForScalarNode(v2) |
| 1680 |
if !ok { |
| 1681 |
message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) |
| 1682 |
errors = append(errors, compiler.NewError(context, message)) |
| 1683 |
} |
| 1684 |
} |
| 1685 |
} |
| 1686 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1687 |
} |
| 1688 |
|
| 1689 |
// NewStringArray creates an object of type StringArray if possible, returning an error if not. |
| 1690 |
func NewStringArray(in *yaml.Node, context *compiler.Context) (*StringArray, error) { |
| 1691 |
errors := make([]error, 0) |
| 1692 |
x := &StringArray{} |
| 1693 |
x.Value = make([]string, 0) |
| 1694 |
for _, node := range in.Content { |
| 1695 |
s, _ := compiler.StringForScalarNode(node) |
| 1696 |
x.Value = append(x.Value, s) |
| 1697 |
} |
| 1698 |
return x, compiler.NewErrorGroupOrNil(errors) |
| 1699 |
} |
| 1700 |
|
| 1701 |
// ResolveReferences resolves references found inside Annotations objects. |
| 1702 |
func (m *Annotations) ResolveReferences(root string) (*yaml.Node, error) { |
| 1703 |
errors := make([]error, 0) |
| 1704 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1705 |
} |
| 1706 |
|
| 1707 |
// ResolveReferences resolves references found inside Any objects. |
| 1708 |
func (m *Any) ResolveReferences(root string) (*yaml.Node, error) { |
| 1709 |
errors := make([]error, 0) |
| 1710 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1711 |
} |
| 1712 |
|
| 1713 |
// ResolveReferences resolves references found inside Auth objects. |
| 1714 |
func (m *Auth) ResolveReferences(root string) (*yaml.Node, error) { |
| 1715 |
errors := make([]error, 0) |
| 1716 |
if m.Oauth2 != nil { |
| 1717 |
_, err := m.Oauth2.ResolveReferences(root) |
| 1718 |
if err != nil { |
| 1719 |
errors = append(errors, err) |
| 1720 |
} |
| 1721 |
} |
| 1722 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1723 |
} |
| 1724 |
|
| 1725 |
// ResolveReferences resolves references found inside Document objects. |
| 1726 |
func (m *Document) ResolveReferences(root string) (*yaml.Node, error) { |
| 1727 |
errors := make([]error, 0) |
| 1728 |
if m.Icons != nil { |
| 1729 |
_, err := m.Icons.ResolveReferences(root) |
| 1730 |
if err != nil { |
| 1731 |
errors = append(errors, err) |
| 1732 |
} |
| 1733 |
} |
| 1734 |
if m.Parameters != nil { |
| 1735 |
_, err := m.Parameters.ResolveReferences(root) |
| 1736 |
if err != nil { |
| 1737 |
errors = append(errors, err) |
| 1738 |
} |
| 1739 |
} |
| 1740 |
if m.Auth != nil { |
| 1741 |
_, err := m.Auth.ResolveReferences(root) |
| 1742 |
if err != nil { |
| 1743 |
errors = append(errors, err) |
| 1744 |
} |
| 1745 |
} |
| 1746 |
if m.Schemas != nil { |
| 1747 |
_, err := m.Schemas.ResolveReferences(root) |
| 1748 |
if err != nil { |
| 1749 |
errors = append(errors, err) |
| 1750 |
} |
| 1751 |
} |
| 1752 |
if m.Methods != nil { |
| 1753 |
_, err := m.Methods.ResolveReferences(root) |
| 1754 |
if err != nil { |
| 1755 |
errors = append(errors, err) |
| 1756 |
} |
| 1757 |
} |
| 1758 |
if m.Resources != nil { |
| 1759 |
_, err := m.Resources.ResolveReferences(root) |
| 1760 |
if err != nil { |
| 1761 |
errors = append(errors, err) |
| 1762 |
} |
| 1763 |
} |
| 1764 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1765 |
} |
| 1766 |
|
| 1767 |
// ResolveReferences resolves references found inside Icons objects. |
| 1768 |
func (m *Icons) ResolveReferences(root string) (*yaml.Node, error) { |
| 1769 |
errors := make([]error, 0) |
| 1770 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1771 |
} |
| 1772 |
|
| 1773 |
// ResolveReferences resolves references found inside MediaUpload objects. |
| 1774 |
func (m *MediaUpload) ResolveReferences(root string) (*yaml.Node, error) { |
| 1775 |
errors := make([]error, 0) |
| 1776 |
if m.Protocols != nil { |
| 1777 |
_, err := m.Protocols.ResolveReferences(root) |
| 1778 |
if err != nil { |
| 1779 |
errors = append(errors, err) |
| 1780 |
} |
| 1781 |
} |
| 1782 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1783 |
} |
| 1784 |
|
| 1785 |
// ResolveReferences resolves references found inside Method objects. |
| 1786 |
func (m *Method) ResolveReferences(root string) (*yaml.Node, error) { |
| 1787 |
errors := make([]error, 0) |
| 1788 |
if m.Parameters != nil { |
| 1789 |
_, err := m.Parameters.ResolveReferences(root) |
| 1790 |
if err != nil { |
| 1791 |
errors = append(errors, err) |
| 1792 |
} |
| 1793 |
} |
| 1794 |
if m.Request != nil { |
| 1795 |
_, err := m.Request.ResolveReferences(root) |
| 1796 |
if err != nil { |
| 1797 |
errors = append(errors, err) |
| 1798 |
} |
| 1799 |
} |
| 1800 |
if m.Response != nil { |
| 1801 |
_, err := m.Response.ResolveReferences(root) |
| 1802 |
if err != nil { |
| 1803 |
errors = append(errors, err) |
| 1804 |
} |
| 1805 |
} |
| 1806 |
if m.MediaUpload != nil { |
| 1807 |
_, err := m.MediaUpload.ResolveReferences(root) |
| 1808 |
if err != nil { |
| 1809 |
errors = append(errors, err) |
| 1810 |
} |
| 1811 |
} |
| 1812 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1813 |
} |
| 1814 |
|
| 1815 |
// ResolveReferences resolves references found inside Methods objects. |
| 1816 |
func (m *Methods) ResolveReferences(root string) (*yaml.Node, error) { |
| 1817 |
errors := make([]error, 0) |
| 1818 |
for _, item := range m.AdditionalProperties { |
| 1819 |
if item != nil { |
| 1820 |
_, err := item.ResolveReferences(root) |
| 1821 |
if err != nil { |
| 1822 |
errors = append(errors, err) |
| 1823 |
} |
| 1824 |
} |
| 1825 |
} |
| 1826 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1827 |
} |
| 1828 |
|
| 1829 |
// ResolveReferences resolves references found inside NamedMethod objects. |
| 1830 |
func (m *NamedMethod) ResolveReferences(root string) (*yaml.Node, error) { |
| 1831 |
errors := make([]error, 0) |
| 1832 |
if m.Value != nil { |
| 1833 |
_, err := m.Value.ResolveReferences(root) |
| 1834 |
if err != nil { |
| 1835 |
errors = append(errors, err) |
| 1836 |
} |
| 1837 |
} |
| 1838 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1839 |
} |
| 1840 |
|
| 1841 |
// ResolveReferences resolves references found inside NamedParameter objects. |
| 1842 |
func (m *NamedParameter) ResolveReferences(root string) (*yaml.Node, error) { |
| 1843 |
errors := make([]error, 0) |
| 1844 |
if m.Value != nil { |
| 1845 |
_, err := m.Value.ResolveReferences(root) |
| 1846 |
if err != nil { |
| 1847 |
errors = append(errors, err) |
| 1848 |
} |
| 1849 |
} |
| 1850 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1851 |
} |
| 1852 |
|
| 1853 |
// ResolveReferences resolves references found inside NamedResource objects. |
| 1854 |
func (m *NamedResource) ResolveReferences(root string) (*yaml.Node, error) { |
| 1855 |
errors := make([]error, 0) |
| 1856 |
if m.Value != nil { |
| 1857 |
_, err := m.Value.ResolveReferences(root) |
| 1858 |
if err != nil { |
| 1859 |
errors = append(errors, err) |
| 1860 |
} |
| 1861 |
} |
| 1862 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1863 |
} |
| 1864 |
|
| 1865 |
// ResolveReferences resolves references found inside NamedSchema objects. |
| 1866 |
func (m *NamedSchema) ResolveReferences(root string) (*yaml.Node, error) { |
| 1867 |
errors := make([]error, 0) |
| 1868 |
if m.Value != nil { |
| 1869 |
_, err := m.Value.ResolveReferences(root) |
| 1870 |
if err != nil { |
| 1871 |
errors = append(errors, err) |
| 1872 |
} |
| 1873 |
} |
| 1874 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1875 |
} |
| 1876 |
|
| 1877 |
// ResolveReferences resolves references found inside NamedScope objects. |
| 1878 |
func (m *NamedScope) ResolveReferences(root string) (*yaml.Node, error) { |
| 1879 |
errors := make([]error, 0) |
| 1880 |
if m.Value != nil { |
| 1881 |
_, err := m.Value.ResolveReferences(root) |
| 1882 |
if err != nil { |
| 1883 |
errors = append(errors, err) |
| 1884 |
} |
| 1885 |
} |
| 1886 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1887 |
} |
| 1888 |
|
| 1889 |
// ResolveReferences resolves references found inside Oauth2 objects. |
| 1890 |
func (m *Oauth2) ResolveReferences(root string) (*yaml.Node, error) { |
| 1891 |
errors := make([]error, 0) |
| 1892 |
if m.Scopes != nil { |
| 1893 |
_, err := m.Scopes.ResolveReferences(root) |
| 1894 |
if err != nil { |
| 1895 |
errors = append(errors, err) |
| 1896 |
} |
| 1897 |
} |
| 1898 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1899 |
} |
| 1900 |
|
| 1901 |
// ResolveReferences resolves references found inside Parameter objects. |
| 1902 |
func (m *Parameter) ResolveReferences(root string) (*yaml.Node, error) { |
| 1903 |
errors := make([]error, 0) |
| 1904 |
if m.XRef != "" { |
| 1905 |
info, err := compiler.ReadInfoForRef(root, m.XRef) |
| 1906 |
if err != nil { |
| 1907 |
return nil, err |
| 1908 |
} |
| 1909 |
if info != nil { |
| 1910 |
replacement, err := NewParameter(info, nil) |
| 1911 |
if err == nil { |
| 1912 |
*m = *replacement |
| 1913 |
return m.ResolveReferences(root) |
| 1914 |
} |
| 1915 |
} |
| 1916 |
return info, nil |
| 1917 |
} |
| 1918 |
if m.Properties != nil { |
| 1919 |
_, err := m.Properties.ResolveReferences(root) |
| 1920 |
if err != nil { |
| 1921 |
errors = append(errors, err) |
| 1922 |
} |
| 1923 |
} |
| 1924 |
if m.AdditionalProperties != nil { |
| 1925 |
_, err := m.AdditionalProperties.ResolveReferences(root) |
| 1926 |
if err != nil { |
| 1927 |
errors = append(errors, err) |
| 1928 |
} |
| 1929 |
} |
| 1930 |
if m.Items != nil { |
| 1931 |
_, err := m.Items.ResolveReferences(root) |
| 1932 |
if err != nil { |
| 1933 |
errors = append(errors, err) |
| 1934 |
} |
| 1935 |
} |
| 1936 |
if m.Annotations != nil { |
| 1937 |
_, err := m.Annotations.ResolveReferences(root) |
| 1938 |
if err != nil { |
| 1939 |
errors = append(errors, err) |
| 1940 |
} |
| 1941 |
} |
| 1942 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1943 |
} |
| 1944 |
|
| 1945 |
// ResolveReferences resolves references found inside Parameters objects. |
| 1946 |
func (m *Parameters) ResolveReferences(root string) (*yaml.Node, error) { |
| 1947 |
errors := make([]error, 0) |
| 1948 |
for _, item := range m.AdditionalProperties { |
| 1949 |
if item != nil { |
| 1950 |
_, err := item.ResolveReferences(root) |
| 1951 |
if err != nil { |
| 1952 |
errors = append(errors, err) |
| 1953 |
} |
| 1954 |
} |
| 1955 |
} |
| 1956 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1957 |
} |
| 1958 |
|
| 1959 |
// ResolveReferences resolves references found inside Protocols objects. |
| 1960 |
func (m *Protocols) ResolveReferences(root string) (*yaml.Node, error) { |
| 1961 |
errors := make([]error, 0) |
| 1962 |
if m.Simple != nil { |
| 1963 |
_, err := m.Simple.ResolveReferences(root) |
| 1964 |
if err != nil { |
| 1965 |
errors = append(errors, err) |
| 1966 |
} |
| 1967 |
} |
| 1968 |
if m.Resumable != nil { |
| 1969 |
_, err := m.Resumable.ResolveReferences(root) |
| 1970 |
if err != nil { |
| 1971 |
errors = append(errors, err) |
| 1972 |
} |
| 1973 |
} |
| 1974 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1975 |
} |
| 1976 |
|
| 1977 |
// ResolveReferences resolves references found inside Request objects. |
| 1978 |
func (m *Request) ResolveReferences(root string) (*yaml.Node, error) { |
| 1979 |
errors := make([]error, 0) |
| 1980 |
if m.XRef != "" { |
| 1981 |
info, err := compiler.ReadInfoForRef(root, m.XRef) |
| 1982 |
if err != nil { |
| 1983 |
return nil, err |
| 1984 |
} |
| 1985 |
if info != nil { |
| 1986 |
replacement, err := NewRequest(info, nil) |
| 1987 |
if err == nil { |
| 1988 |
*m = *replacement |
| 1989 |
return m.ResolveReferences(root) |
| 1990 |
} |
| 1991 |
} |
| 1992 |
return info, nil |
| 1993 |
} |
| 1994 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 1995 |
} |
| 1996 |
|
| 1997 |
// ResolveReferences resolves references found inside Resource objects. |
| 1998 |
func (m *Resource) ResolveReferences(root string) (*yaml.Node, error) { |
| 1999 |
errors := make([]error, 0) |
| 2000 |
if m.Methods != nil { |
| 2001 |
_, err := m.Methods.ResolveReferences(root) |
| 2002 |
if err != nil { |
| 2003 |
errors = append(errors, err) |
| 2004 |
} |
| 2005 |
} |
| 2006 |
if m.Resources != nil { |
| 2007 |
_, err := m.Resources.ResolveReferences(root) |
| 2008 |
if err != nil { |
| 2009 |
errors = append(errors, err) |
| 2010 |
} |
| 2011 |
} |
| 2012 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2013 |
} |
| 2014 |
|
| 2015 |
// ResolveReferences resolves references found inside Resources objects. |
| 2016 |
func (m *Resources) ResolveReferences(root string) (*yaml.Node, error) { |
| 2017 |
errors := make([]error, 0) |
| 2018 |
for _, item := range m.AdditionalProperties { |
| 2019 |
if item != nil { |
| 2020 |
_, err := item.ResolveReferences(root) |
| 2021 |
if err != nil { |
| 2022 |
errors = append(errors, err) |
| 2023 |
} |
| 2024 |
} |
| 2025 |
} |
| 2026 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2027 |
} |
| 2028 |
|
| 2029 |
// ResolveReferences resolves references found inside Response objects. |
| 2030 |
func (m *Response) ResolveReferences(root string) (*yaml.Node, error) { |
| 2031 |
errors := make([]error, 0) |
| 2032 |
if m.XRef != "" { |
| 2033 |
info, err := compiler.ReadInfoForRef(root, m.XRef) |
| 2034 |
if err != nil { |
| 2035 |
return nil, err |
| 2036 |
} |
| 2037 |
return info, nil |
| 2038 |
} |
| 2039 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2040 |
} |
| 2041 |
|
| 2042 |
// ResolveReferences resolves references found inside Resumable objects. |
| 2043 |
func (m *Resumable) ResolveReferences(root string) (*yaml.Node, error) { |
| 2044 |
errors := make([]error, 0) |
| 2045 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2046 |
} |
| 2047 |
|
| 2048 |
// ResolveReferences resolves references found inside Schema objects. |
| 2049 |
func (m *Schema) ResolveReferences(root string) (*yaml.Node, error) { |
| 2050 |
errors := make([]error, 0) |
| 2051 |
if m.Properties != nil { |
| 2052 |
_, err := m.Properties.ResolveReferences(root) |
| 2053 |
if err != nil { |
| 2054 |
errors = append(errors, err) |
| 2055 |
} |
| 2056 |
} |
| 2057 |
if m.AdditionalProperties != nil { |
| 2058 |
_, err := m.AdditionalProperties.ResolveReferences(root) |
| 2059 |
if err != nil { |
| 2060 |
errors = append(errors, err) |
| 2061 |
} |
| 2062 |
} |
| 2063 |
if m.Items != nil { |
| 2064 |
_, err := m.Items.ResolveReferences(root) |
| 2065 |
if err != nil { |
| 2066 |
errors = append(errors, err) |
| 2067 |
} |
| 2068 |
} |
| 2069 |
if m.XRef != "" { |
| 2070 |
info, err := compiler.ReadInfoForRef(root, m.XRef) |
| 2071 |
if err != nil { |
| 2072 |
return nil, err |
| 2073 |
} |
| 2074 |
if info != nil { |
| 2075 |
replacement, err := NewSchema(info, nil) |
| 2076 |
if err == nil { |
| 2077 |
*m = *replacement |
| 2078 |
return m.ResolveReferences(root) |
| 2079 |
} |
| 2080 |
} |
| 2081 |
return info, nil |
| 2082 |
} |
| 2083 |
if m.Annotations != nil { |
| 2084 |
_, err := m.Annotations.ResolveReferences(root) |
| 2085 |
if err != nil { |
| 2086 |
errors = append(errors, err) |
| 2087 |
} |
| 2088 |
} |
| 2089 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2090 |
} |
| 2091 |
|
| 2092 |
// ResolveReferences resolves references found inside Schemas objects. |
| 2093 |
func (m *Schemas) ResolveReferences(root string) (*yaml.Node, error) { |
| 2094 |
errors := make([]error, 0) |
| 2095 |
for _, item := range m.AdditionalProperties { |
| 2096 |
if item != nil { |
| 2097 |
_, err := item.ResolveReferences(root) |
| 2098 |
if err != nil { |
| 2099 |
errors = append(errors, err) |
| 2100 |
} |
| 2101 |
} |
| 2102 |
} |
| 2103 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2104 |
} |
| 2105 |
|
| 2106 |
// ResolveReferences resolves references found inside Scope objects. |
| 2107 |
func (m *Scope) ResolveReferences(root string) (*yaml.Node, error) { |
| 2108 |
errors := make([]error, 0) |
| 2109 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2110 |
} |
| 2111 |
|
| 2112 |
// ResolveReferences resolves references found inside Scopes objects. |
| 2113 |
func (m *Scopes) ResolveReferences(root string) (*yaml.Node, error) { |
| 2114 |
errors := make([]error, 0) |
| 2115 |
for _, item := range m.AdditionalProperties { |
| 2116 |
if item != nil { |
| 2117 |
_, err := item.ResolveReferences(root) |
| 2118 |
if err != nil { |
| 2119 |
errors = append(errors, err) |
| 2120 |
} |
| 2121 |
} |
| 2122 |
} |
| 2123 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2124 |
} |
| 2125 |
|
| 2126 |
// ResolveReferences resolves references found inside Simple objects. |
| 2127 |
func (m *Simple) ResolveReferences(root string) (*yaml.Node, error) { |
| 2128 |
errors := make([]error, 0) |
| 2129 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2130 |
} |
| 2131 |
|
| 2132 |
// ResolveReferences resolves references found inside StringArray objects. |
| 2133 |
func (m *StringArray) ResolveReferences(root string) (*yaml.Node, error) { |
| 2134 |
errors := make([]error, 0) |
| 2135 |
return nil, compiler.NewErrorGroupOrNil(errors) |
| 2136 |
} |
| 2137 |
|
| 2138 |
// ToRawInfo returns a description of Annotations suitable for JSON or YAML export. |
| 2139 |
func (m *Annotations) ToRawInfo() *yaml.Node { |
| 2140 |
info := compiler.NewMappingNode() |
| 2141 |
if m == nil { |
| 2142 |
return info |
| 2143 |
} |
| 2144 |
if len(m.Required) != 0 { |
| 2145 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) |
| 2146 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Required)) |
| 2147 |
} |
| 2148 |
return info |
| 2149 |
} |
| 2150 |
|
| 2151 |
// ToRawInfo returns a description of Any suitable for JSON or YAML export. |
| 2152 |
func (m *Any) ToRawInfo() *yaml.Node { |
| 2153 |
var err error |
| 2154 |
var node yaml.Node |
| 2155 |
err = yaml.Unmarshal([]byte(m.Yaml), &node) |
| 2156 |
if err == nil { |
| 2157 |
if node.Kind == yaml.DocumentNode { |
| 2158 |
return node.Content[0] |
| 2159 |
} |
| 2160 |
return &node |
| 2161 |
} |
| 2162 |
return compiler.NewNullNode() |
| 2163 |
} |
| 2164 |
|
| 2165 |
// ToRawInfo returns a description of Auth suitable for JSON or YAML export. |
| 2166 |
func (m *Auth) ToRawInfo() *yaml.Node { |
| 2167 |
info := compiler.NewMappingNode() |
| 2168 |
if m == nil { |
| 2169 |
return info |
| 2170 |
} |
| 2171 |
if m.Oauth2 != nil { |
| 2172 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("oauth2")) |
| 2173 |
info.Content = append(info.Content, m.Oauth2.ToRawInfo()) |
| 2174 |
} |
| 2175 |
return info |
| 2176 |
} |
| 2177 |
|
| 2178 |
// ToRawInfo returns a description of Document suitable for JSON or YAML export. |
| 2179 |
func (m *Document) ToRawInfo() *yaml.Node { |
| 2180 |
info := compiler.NewMappingNode() |
| 2181 |
if m == nil { |
| 2182 |
return info |
| 2183 |
} |
| 2184 |
// always include this required field. |
| 2185 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("kind")) |
| 2186 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Kind)) |
| 2187 |
// always include this required field. |
| 2188 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("discoveryVersion")) |
| 2189 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.DiscoveryVersion)) |
| 2190 |
if m.Id != "" { |
| 2191 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("id")) |
| 2192 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Id)) |
| 2193 |
} |
| 2194 |
if m.Name != "" { |
| 2195 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) |
| 2196 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) |
| 2197 |
} |
| 2198 |
if m.Version != "" { |
| 2199 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("version")) |
| 2200 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Version)) |
| 2201 |
} |
| 2202 |
if m.Revision != "" { |
| 2203 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("revision")) |
| 2204 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Revision)) |
| 2205 |
} |
| 2206 |
if m.Title != "" { |
| 2207 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) |
| 2208 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) |
| 2209 |
} |
| 2210 |
if m.Description != "" { |
| 2211 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) |
| 2212 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) |
| 2213 |
} |
| 2214 |
if m.Icons != nil { |
| 2215 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("icons")) |
| 2216 |
info.Content = append(info.Content, m.Icons.ToRawInfo()) |
| 2217 |
} |
| 2218 |
if m.DocumentationLink != "" { |
| 2219 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("documentationLink")) |
| 2220 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.DocumentationLink)) |
| 2221 |
} |
| 2222 |
if len(m.Labels) != 0 { |
| 2223 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("labels")) |
| 2224 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Labels)) |
| 2225 |
} |
| 2226 |
if m.Protocol != "" { |
| 2227 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("protocol")) |
| 2228 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Protocol)) |
| 2229 |
} |
| 2230 |
if m.BaseUrl != "" { |
| 2231 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("baseUrl")) |
| 2232 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BaseUrl)) |
| 2233 |
} |
| 2234 |
if m.BasePath != "" { |
| 2235 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("basePath")) |
| 2236 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BasePath)) |
| 2237 |
} |
| 2238 |
if m.RootUrl != "" { |
| 2239 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("rootUrl")) |
| 2240 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.RootUrl)) |
| 2241 |
} |
| 2242 |
if m.ServicePath != "" { |
| 2243 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("servicePath")) |
| 2244 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.ServicePath)) |
| 2245 |
} |
| 2246 |
if m.BatchPath != "" { |
| 2247 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("batchPath")) |
| 2248 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BatchPath)) |
| 2249 |
} |
| 2250 |
if m.Parameters != nil { |
| 2251 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) |
| 2252 |
info.Content = append(info.Content, m.Parameters.ToRawInfo()) |
| 2253 |
} |
| 2254 |
if m.Auth != nil { |
| 2255 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("auth")) |
| 2256 |
info.Content = append(info.Content, m.Auth.ToRawInfo()) |
| 2257 |
} |
| 2258 |
if len(m.Features) != 0 { |
| 2259 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("features")) |
| 2260 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Features)) |
| 2261 |
} |
| 2262 |
if m.Schemas != nil { |
| 2263 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("schemas")) |
| 2264 |
info.Content = append(info.Content, m.Schemas.ToRawInfo()) |
| 2265 |
} |
| 2266 |
if m.Methods != nil { |
| 2267 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("methods")) |
| 2268 |
info.Content = append(info.Content, m.Methods.ToRawInfo()) |
| 2269 |
} |
| 2270 |
if m.Resources != nil { |
| 2271 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("resources")) |
| 2272 |
info.Content = append(info.Content, m.Resources.ToRawInfo()) |
| 2273 |
} |
| 2274 |
if m.Etag != "" { |
| 2275 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("etag")) |
| 2276 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Etag)) |
| 2277 |
} |
| 2278 |
if m.OwnerDomain != "" { |
| 2279 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("ownerDomain")) |
| 2280 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OwnerDomain)) |
| 2281 |
} |
| 2282 |
if m.OwnerName != "" { |
| 2283 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("ownerName")) |
| 2284 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OwnerName)) |
| 2285 |
} |
| 2286 |
if m.VersionModule { |
| 2287 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("version_module")) |
| 2288 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.VersionModule)) |
| 2289 |
} |
| 2290 |
if m.CanonicalName != "" { |
| 2291 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("canonicalName")) |
| 2292 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.CanonicalName)) |
| 2293 |
} |
| 2294 |
if m.FullyEncodeReservedExpansion { |
| 2295 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("fullyEncodeReservedExpansion")) |
| 2296 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.FullyEncodeReservedExpansion)) |
| 2297 |
} |
| 2298 |
if m.PackagePath != "" { |
| 2299 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("packagePath")) |
| 2300 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.PackagePath)) |
| 2301 |
} |
| 2302 |
if m.MtlsRootUrl != "" { |
| 2303 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("mtlsRootUrl")) |
| 2304 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.MtlsRootUrl)) |
| 2305 |
} |
| 2306 |
return info |
| 2307 |
} |
| 2308 |
|
| 2309 |
// ToRawInfo returns a description of Icons suitable for JSON or YAML export. |
| 2310 |
func (m *Icons) ToRawInfo() *yaml.Node { |
| 2311 |
info := compiler.NewMappingNode() |
| 2312 |
if m == nil { |
| 2313 |
return info |
| 2314 |
} |
| 2315 |
// always include this required field. |
| 2316 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("x16")) |
| 2317 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.X16)) |
| 2318 |
// always include this required field. |
| 2319 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("x32")) |
| 2320 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.X32)) |
| 2321 |
return info |
| 2322 |
} |
| 2323 |
|
| 2324 |
// ToRawInfo returns a description of MediaUpload suitable for JSON or YAML export. |
| 2325 |
func (m *MediaUpload) ToRawInfo() *yaml.Node { |
| 2326 |
info := compiler.NewMappingNode() |
| 2327 |
if m == nil { |
| 2328 |
return info |
| 2329 |
} |
| 2330 |
if len(m.Accept) != 0 { |
| 2331 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("accept")) |
| 2332 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Accept)) |
| 2333 |
} |
| 2334 |
if m.MaxSize != "" { |
| 2335 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("maxSize")) |
| 2336 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.MaxSize)) |
| 2337 |
} |
| 2338 |
if m.Protocols != nil { |
| 2339 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("protocols")) |
| 2340 |
info.Content = append(info.Content, m.Protocols.ToRawInfo()) |
| 2341 |
} |
| 2342 |
if m.SupportsSubscription { |
| 2343 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("supportsSubscription")) |
| 2344 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.SupportsSubscription)) |
| 2345 |
} |
| 2346 |
return info |
| 2347 |
} |
| 2348 |
|
| 2349 |
// ToRawInfo returns a description of Method suitable for JSON or YAML export. |
| 2350 |
func (m *Method) ToRawInfo() *yaml.Node { |
| 2351 |
info := compiler.NewMappingNode() |
| 2352 |
if m == nil { |
| 2353 |
return info |
| 2354 |
} |
| 2355 |
if m.Id != "" { |
| 2356 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("id")) |
| 2357 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Id)) |
| 2358 |
} |
| 2359 |
if m.Path != "" { |
| 2360 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("path")) |
| 2361 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Path)) |
| 2362 |
} |
| 2363 |
if m.HttpMethod != "" { |
| 2364 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("httpMethod")) |
| 2365 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.HttpMethod)) |
| 2366 |
} |
| 2367 |
if m.Description != "" { |
| 2368 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) |
| 2369 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) |
| 2370 |
} |
| 2371 |
if m.Parameters != nil { |
| 2372 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) |
| 2373 |
info.Content = append(info.Content, m.Parameters.ToRawInfo()) |
| 2374 |
} |
| 2375 |
if len(m.ParameterOrder) != 0 { |
| 2376 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("parameterOrder")) |
| 2377 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.ParameterOrder)) |
| 2378 |
} |
| 2379 |
if m.Request != nil { |
| 2380 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("request")) |
| 2381 |
info.Content = append(info.Content, m.Request.ToRawInfo()) |
| 2382 |
} |
| 2383 |
if m.Response != nil { |
| 2384 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("response")) |
| 2385 |
info.Content = append(info.Content, m.Response.ToRawInfo()) |
| 2386 |
} |
| 2387 |
if len(m.Scopes) != 0 { |
| 2388 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) |
| 2389 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Scopes)) |
| 2390 |
} |
| 2391 |
if m.SupportsMediaDownload { |
| 2392 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("supportsMediaDownload")) |
| 2393 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.SupportsMediaDownload)) |
| 2394 |
} |
| 2395 |
if m.SupportsMediaUpload { |
| 2396 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("supportsMediaUpload")) |
| 2397 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.SupportsMediaUpload)) |
| 2398 |
} |
| 2399 |
if m.UseMediaDownloadService { |
| 2400 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("useMediaDownloadService")) |
| 2401 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UseMediaDownloadService)) |
| 2402 |
} |
| 2403 |
if m.MediaUpload != nil { |
| 2404 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("mediaUpload")) |
| 2405 |
info.Content = append(info.Content, m.MediaUpload.ToRawInfo()) |
| 2406 |
} |
| 2407 |
if m.SupportsSubscription { |
| 2408 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("supportsSubscription")) |
| 2409 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.SupportsSubscription)) |
| 2410 |
} |
| 2411 |
if m.FlatPath != "" { |
| 2412 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("flatPath")) |
| 2413 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.FlatPath)) |
| 2414 |
} |
| 2415 |
if m.EtagRequired { |
| 2416 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("etagRequired")) |
| 2417 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.EtagRequired)) |
| 2418 |
} |
| 2419 |
if m.StreamingType != "" { |
| 2420 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("streamingType")) |
| 2421 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.StreamingType)) |
| 2422 |
} |
| 2423 |
return info |
| 2424 |
} |
| 2425 |
|
| 2426 |
// ToRawInfo returns a description of Methods suitable for JSON or YAML export. |
| 2427 |
func (m *Methods) ToRawInfo() *yaml.Node { |
| 2428 |
info := compiler.NewMappingNode() |
| 2429 |
if m == nil { |
| 2430 |
return info |
| 2431 |
} |
| 2432 |
if m.AdditionalProperties != nil { |
| 2433 |
for _, item := range m.AdditionalProperties { |
| 2434 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) |
| 2435 |
info.Content = append(info.Content, item.Value.ToRawInfo()) |
| 2436 |
} |
| 2437 |
} |
| 2438 |
return info |
| 2439 |
} |
| 2440 |
|
| 2441 |
// ToRawInfo returns a description of NamedMethod suitable for JSON or YAML export. |
| 2442 |
func (m *NamedMethod) ToRawInfo() *yaml.Node { |
| 2443 |
info := compiler.NewMappingNode() |
| 2444 |
if m == nil { |
| 2445 |
return info |
| 2446 |
} |
| 2447 |
if m.Name != "" { |
| 2448 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) |
| 2449 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) |
| 2450 |
} |
| 2451 |
// &{Name:value Type:Method StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 2452 |
return info |
| 2453 |
} |
| 2454 |
|
| 2455 |
// ToRawInfo returns a description of NamedParameter suitable for JSON or YAML export. |
| 2456 |
func (m *NamedParameter) ToRawInfo() *yaml.Node { |
| 2457 |
info := compiler.NewMappingNode() |
| 2458 |
if m == nil { |
| 2459 |
return info |
| 2460 |
} |
| 2461 |
if m.Name != "" { |
| 2462 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) |
| 2463 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) |
| 2464 |
} |
| 2465 |
// &{Name:value Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 2466 |
return info |
| 2467 |
} |
| 2468 |
|
| 2469 |
// ToRawInfo returns a description of NamedResource suitable for JSON or YAML export. |
| 2470 |
func (m *NamedResource) ToRawInfo() *yaml.Node { |
| 2471 |
info := compiler.NewMappingNode() |
| 2472 |
if m == nil { |
| 2473 |
return info |
| 2474 |
} |
| 2475 |
if m.Name != "" { |
| 2476 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) |
| 2477 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) |
| 2478 |
} |
| 2479 |
// &{Name:value Type:Resource StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 2480 |
return info |
| 2481 |
} |
| 2482 |
|
| 2483 |
// ToRawInfo returns a description of NamedSchema suitable for JSON or YAML export. |
| 2484 |
func (m *NamedSchema) ToRawInfo() *yaml.Node { |
| 2485 |
info := compiler.NewMappingNode() |
| 2486 |
if m == nil { |
| 2487 |
return info |
| 2488 |
} |
| 2489 |
if m.Name != "" { |
| 2490 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) |
| 2491 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) |
| 2492 |
} |
| 2493 |
// &{Name:value Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 2494 |
return info |
| 2495 |
} |
| 2496 |
|
| 2497 |
// ToRawInfo returns a description of NamedScope suitable for JSON or YAML export. |
| 2498 |
func (m *NamedScope) ToRawInfo() *yaml.Node { |
| 2499 |
info := compiler.NewMappingNode() |
| 2500 |
if m == nil { |
| 2501 |
return info |
| 2502 |
} |
| 2503 |
if m.Name != "" { |
| 2504 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) |
| 2505 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) |
| 2506 |
} |
| 2507 |
// &{Name:value Type:Scope StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} |
| 2508 |
return info |
| 2509 |
} |
| 2510 |
|
| 2511 |
// ToRawInfo returns a description of Oauth2 suitable for JSON or YAML export. |
| 2512 |
func (m *Oauth2) ToRawInfo() *yaml.Node { |
| 2513 |
info := compiler.NewMappingNode() |
| 2514 |
if m == nil { |
| 2515 |
return info |
| 2516 |
} |
| 2517 |
if m.Scopes != nil { |
| 2518 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) |
| 2519 |
info.Content = append(info.Content, m.Scopes.ToRawInfo()) |
| 2520 |
} |
| 2521 |
return info |
| 2522 |
} |
| 2523 |
|
| 2524 |
// ToRawInfo returns a description of Parameter suitable for JSON or YAML export. |
| 2525 |
func (m *Parameter) ToRawInfo() *yaml.Node { |
| 2526 |
info := compiler.NewMappingNode() |
| 2527 |
if m == nil { |
| 2528 |
return info |
| 2529 |
} |
| 2530 |
if m.Id != "" { |
| 2531 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("id")) |
| 2532 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Id)) |
| 2533 |
} |
| 2534 |
if m.Type != "" { |
| 2535 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) |
| 2536 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) |
| 2537 |
} |
| 2538 |
if m.XRef != "" { |
| 2539 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) |
| 2540 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) |
| 2541 |
} |
| 2542 |
if m.Description != "" { |
| 2543 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) |
| 2544 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) |
| 2545 |
} |
| 2546 |
if m.Default != "" { |
| 2547 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) |
| 2548 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Default)) |
| 2549 |
} |
| 2550 |
if m.Required { |
| 2551 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) |
| 2552 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) |
| 2553 |
} |
| 2554 |
if m.Format != "" { |
| 2555 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) |
| 2556 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) |
| 2557 |
} |
| 2558 |
if m.Pattern != "" { |
| 2559 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) |
| 2560 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) |
| 2561 |
} |
| 2562 |
if m.Minimum != "" { |
| 2563 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) |
| 2564 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Minimum)) |
| 2565 |
} |
| 2566 |
if m.Maximum != "" { |
| 2567 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) |
| 2568 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Maximum)) |
| 2569 |
} |
| 2570 |
if len(m.Enum) != 0 { |
| 2571 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) |
| 2572 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Enum)) |
| 2573 |
} |
| 2574 |
if len(m.EnumDescriptions) != 0 { |
| 2575 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("enumDescriptions")) |
| 2576 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.EnumDescriptions)) |
| 2577 |
} |
| 2578 |
if m.Repeated { |
| 2579 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("repeated")) |
| 2580 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Repeated)) |
| 2581 |
} |
| 2582 |
if m.Location != "" { |
| 2583 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("location")) |
| 2584 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Location)) |
| 2585 |
} |
| 2586 |
if m.Properties != nil { |
| 2587 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("properties")) |
| 2588 |
info.Content = append(info.Content, m.Properties.ToRawInfo()) |
| 2589 |
} |
| 2590 |
if m.AdditionalProperties != nil { |
| 2591 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("additionalProperties")) |
| 2592 |
info.Content = append(info.Content, m.AdditionalProperties.ToRawInfo()) |
| 2593 |
} |
| 2594 |
if m.Items != nil { |
| 2595 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) |
| 2596 |
info.Content = append(info.Content, m.Items.ToRawInfo()) |
| 2597 |
} |
| 2598 |
if m.Annotations != nil { |
| 2599 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("annotations")) |
| 2600 |
info.Content = append(info.Content, m.Annotations.ToRawInfo()) |
| 2601 |
} |
| 2602 |
return info |
| 2603 |
} |
| 2604 |
|
| 2605 |
// ToRawInfo returns a description of Parameters suitable for JSON or YAML export. |
| 2606 |
func (m *Parameters) ToRawInfo() *yaml.Node { |
| 2607 |
info := compiler.NewMappingNode() |
| 2608 |
if m == nil { |
| 2609 |
return info |
| 2610 |
} |
| 2611 |
if m.AdditionalProperties != nil { |
| 2612 |
for _, item := range m.AdditionalProperties { |
| 2613 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) |
| 2614 |
info.Content = append(info.Content, item.Value.ToRawInfo()) |
| 2615 |
} |
| 2616 |
} |
| 2617 |
return info |
| 2618 |
} |
| 2619 |
|
| 2620 |
// ToRawInfo returns a description of Protocols suitable for JSON or YAML export. |
| 2621 |
func (m *Protocols) ToRawInfo() *yaml.Node { |
| 2622 |
info := compiler.NewMappingNode() |
| 2623 |
if m == nil { |
| 2624 |
return info |
| 2625 |
} |
| 2626 |
if m.Simple != nil { |
| 2627 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("simple")) |
| 2628 |
info.Content = append(info.Content, m.Simple.ToRawInfo()) |
| 2629 |
} |
| 2630 |
if m.Resumable != nil { |
| 2631 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("resumable")) |
| 2632 |
info.Content = append(info.Content, m.Resumable.ToRawInfo()) |
| 2633 |
} |
| 2634 |
return info |
| 2635 |
} |
| 2636 |
|
| 2637 |
// ToRawInfo returns a description of Request suitable for JSON or YAML export. |
| 2638 |
func (m *Request) ToRawInfo() *yaml.Node { |
| 2639 |
info := compiler.NewMappingNode() |
| 2640 |
if m == nil { |
| 2641 |
return info |
| 2642 |
} |
| 2643 |
if m.XRef != "" { |
| 2644 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) |
| 2645 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) |
| 2646 |
} |
| 2647 |
if m.ParameterName != "" { |
| 2648 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("parameterName")) |
| 2649 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.ParameterName)) |
| 2650 |
} |
| 2651 |
return info |
| 2652 |
} |
| 2653 |
|
| 2654 |
// ToRawInfo returns a description of Resource suitable for JSON or YAML export. |
| 2655 |
func (m *Resource) ToRawInfo() *yaml.Node { |
| 2656 |
info := compiler.NewMappingNode() |
| 2657 |
if m == nil { |
| 2658 |
return info |
| 2659 |
} |
| 2660 |
if m.Methods != nil { |
| 2661 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("methods")) |
| 2662 |
info.Content = append(info.Content, m.Methods.ToRawInfo()) |
| 2663 |
} |
| 2664 |
if m.Resources != nil { |
| 2665 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("resources")) |
| 2666 |
info.Content = append(info.Content, m.Resources.ToRawInfo()) |
| 2667 |
} |
| 2668 |
return info |
| 2669 |
} |
| 2670 |
|
| 2671 |
// ToRawInfo returns a description of Resources suitable for JSON or YAML export. |
| 2672 |
func (m *Resources) ToRawInfo() *yaml.Node { |
| 2673 |
info := compiler.NewMappingNode() |
| 2674 |
if m == nil { |
| 2675 |
return info |
| 2676 |
} |
| 2677 |
if m.AdditionalProperties != nil { |
| 2678 |
for _, item := range m.AdditionalProperties { |
| 2679 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) |
| 2680 |
info.Content = append(info.Content, item.Value.ToRawInfo()) |
| 2681 |
} |
| 2682 |
} |
| 2683 |
return info |
| 2684 |
} |
| 2685 |
|
| 2686 |
// ToRawInfo returns a description of Response suitable for JSON or YAML export. |
| 2687 |
func (m *Response) ToRawInfo() *yaml.Node { |
| 2688 |
info := compiler.NewMappingNode() |
| 2689 |
if m == nil { |
| 2690 |
return info |
| 2691 |
} |
| 2692 |
if m.XRef != "" { |
| 2693 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) |
| 2694 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) |
| 2695 |
} |
| 2696 |
return info |
| 2697 |
} |
| 2698 |
|
| 2699 |
// ToRawInfo returns a description of Resumable suitable for JSON or YAML export. |
| 2700 |
func (m *Resumable) ToRawInfo() *yaml.Node { |
| 2701 |
info := compiler.NewMappingNode() |
| 2702 |
if m == nil { |
| 2703 |
return info |
| 2704 |
} |
| 2705 |
if m.Multipart { |
| 2706 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("multipart")) |
| 2707 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Multipart)) |
| 2708 |
} |
| 2709 |
if m.Path != "" { |
| 2710 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("path")) |
| 2711 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Path)) |
| 2712 |
} |
| 2713 |
return info |
| 2714 |
} |
| 2715 |
|
| 2716 |
// ToRawInfo returns a description of Schema suitable for JSON or YAML export. |
| 2717 |
func (m *Schema) ToRawInfo() *yaml.Node { |
| 2718 |
info := compiler.NewMappingNode() |
| 2719 |
if m == nil { |
| 2720 |
return info |
| 2721 |
} |
| 2722 |
if m.Id != "" { |
| 2723 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("id")) |
| 2724 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Id)) |
| 2725 |
} |
| 2726 |
if m.Type != "" { |
| 2727 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) |
| 2728 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) |
| 2729 |
} |
| 2730 |
if m.Description != "" { |
| 2731 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) |
| 2732 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) |
| 2733 |
} |
| 2734 |
if m.Default != "" { |
| 2735 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) |
| 2736 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Default)) |
| 2737 |
} |
| 2738 |
if m.Required { |
| 2739 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) |
| 2740 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) |
| 2741 |
} |
| 2742 |
if m.Format != "" { |
| 2743 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) |
| 2744 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) |
| 2745 |
} |
| 2746 |
if m.Pattern != "" { |
| 2747 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) |
| 2748 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) |
| 2749 |
} |
| 2750 |
if m.Minimum != "" { |
| 2751 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) |
| 2752 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Minimum)) |
| 2753 |
} |
| 2754 |
if m.Maximum != "" { |
| 2755 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) |
| 2756 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Maximum)) |
| 2757 |
} |
| 2758 |
if len(m.Enum) != 0 { |
| 2759 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) |
| 2760 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Enum)) |
| 2761 |
} |
| 2762 |
if len(m.EnumDescriptions) != 0 { |
| 2763 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("enumDescriptions")) |
| 2764 |
info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.EnumDescriptions)) |
| 2765 |
} |
| 2766 |
if m.Repeated { |
| 2767 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("repeated")) |
| 2768 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Repeated)) |
| 2769 |
} |
| 2770 |
if m.Location != "" { |
| 2771 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("location")) |
| 2772 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Location)) |
| 2773 |
} |
| 2774 |
if m.Properties != nil { |
| 2775 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("properties")) |
| 2776 |
info.Content = append(info.Content, m.Properties.ToRawInfo()) |
| 2777 |
} |
| 2778 |
if m.AdditionalProperties != nil { |
| 2779 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("additionalProperties")) |
| 2780 |
info.Content = append(info.Content, m.AdditionalProperties.ToRawInfo()) |
| 2781 |
} |
| 2782 |
if m.Items != nil { |
| 2783 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) |
| 2784 |
info.Content = append(info.Content, m.Items.ToRawInfo()) |
| 2785 |
} |
| 2786 |
if m.XRef != "" { |
| 2787 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) |
| 2788 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) |
| 2789 |
} |
| 2790 |
if m.Annotations != nil { |
| 2791 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("annotations")) |
| 2792 |
info.Content = append(info.Content, m.Annotations.ToRawInfo()) |
| 2793 |
} |
| 2794 |
if m.ReadOnly { |
| 2795 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("readOnly")) |
| 2796 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ReadOnly)) |
| 2797 |
} |
| 2798 |
return info |
| 2799 |
} |
| 2800 |
|
| 2801 |
// ToRawInfo returns a description of Schemas suitable for JSON or YAML export. |
| 2802 |
func (m *Schemas) ToRawInfo() *yaml.Node { |
| 2803 |
info := compiler.NewMappingNode() |
| 2804 |
if m == nil { |
| 2805 |
return info |
| 2806 |
} |
| 2807 |
if m.AdditionalProperties != nil { |
| 2808 |
for _, item := range m.AdditionalProperties { |
| 2809 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) |
| 2810 |
info.Content = append(info.Content, item.Value.ToRawInfo()) |
| 2811 |
} |
| 2812 |
} |
| 2813 |
return info |
| 2814 |
} |
| 2815 |
|
| 2816 |
// ToRawInfo returns a description of Scope suitable for JSON or YAML export. |
| 2817 |
func (m *Scope) ToRawInfo() *yaml.Node { |
| 2818 |
info := compiler.NewMappingNode() |
| 2819 |
if m == nil { |
| 2820 |
return info |
| 2821 |
} |
| 2822 |
if m.Description != "" { |
| 2823 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) |
| 2824 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) |
| 2825 |
} |
| 2826 |
return info |
| 2827 |
} |
| 2828 |
|
| 2829 |
// ToRawInfo returns a description of Scopes suitable for JSON or YAML export. |
| 2830 |
func (m *Scopes) ToRawInfo() *yaml.Node { |
| 2831 |
info := compiler.NewMappingNode() |
| 2832 |
if m == nil { |
| 2833 |
return info |
| 2834 |
} |
| 2835 |
if m.AdditionalProperties != nil { |
| 2836 |
for _, item := range m.AdditionalProperties { |
| 2837 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) |
| 2838 |
info.Content = append(info.Content, item.Value.ToRawInfo()) |
| 2839 |
} |
| 2840 |
} |
| 2841 |
return info |
| 2842 |
} |
| 2843 |
|
| 2844 |
// ToRawInfo returns a description of Simple suitable for JSON or YAML export. |
| 2845 |
func (m *Simple) ToRawInfo() *yaml.Node { |
| 2846 |
info := compiler.NewMappingNode() |
| 2847 |
if m == nil { |
| 2848 |
return info |
| 2849 |
} |
| 2850 |
if m.Multipart { |
| 2851 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("multipart")) |
| 2852 |
info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Multipart)) |
| 2853 |
} |
| 2854 |
if m.Path != "" { |
| 2855 |
info.Content = append(info.Content, compiler.NewScalarNodeForString("path")) |
| 2856 |
info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Path)) |
| 2857 |
} |
| 2858 |
return info |
| 2859 |
} |
| 2860 |
|
| 2861 |
// ToRawInfo returns a description of StringArray suitable for JSON or YAML export. |
| 2862 |
func (m *StringArray) ToRawInfo() *yaml.Node { |
| 2863 |
return compiler.NewSequenceNodeForStringArray(m.Value) |
| 2864 |
} |