mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 17:57:51 +00:00
5983 lines
178 KiB
Go
5983 lines
178 KiB
Go
// Copyright 2017 Google Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// THIS FILE IS AUTOMATICALLY GENERATED.
|
|
|
|
package openapi_v3
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/googleapis/gnostic/compiler"
|
|
"gopkg.in/yaml.v2"
|
|
"strings"
|
|
)
|
|
|
|
func Version() string {
|
|
return "openapi_v3"
|
|
}
|
|
|
|
func NewAny(in interface{}, context *compiler.Context) (*Any, error) {
|
|
errors := make([]error, 0)
|
|
x := &Any{}
|
|
bytes, _ := yaml.Marshal(in)
|
|
x.Yaml = string(bytes)
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewAnyOrExpression(in interface{}, context *compiler.Context) (*AnyOrExpression, error) {
|
|
errors := make([]error, 0)
|
|
x := &AnyOrExpression{}
|
|
matched := false
|
|
// Any any = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewAny(m, compiler.NewContext("any", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &AnyOrExpression_Any{Any: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Expression expression = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewExpression(m, compiler.NewContext("expression", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &AnyOrExpression_Expression{Expression: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewCallback(in interface{}, context *compiler.Context) (*Callback, error) {
|
|
errors := make([]error, 0)
|
|
x := &Callback{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{expression}", "^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedPathItem expression = 1;
|
|
// MAP: PathItem {expression}
|
|
x.Expression = make([]*NamedPathItem, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{expression}", k) {
|
|
pair := &NamedPathItem{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewPathItem(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Expression = append(x.Expression, pair)
|
|
}
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 2;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewCallbackOrReference(in interface{}, context *compiler.Context) (*CallbackOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &CallbackOrReference{}
|
|
matched := false
|
|
// Callback callback = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewCallback(m, compiler.NewContext("callback", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &CallbackOrReference_Callback{Callback: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Reference reference = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewReference(m, compiler.NewContext("reference", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &CallbackOrReference_Reference{Reference: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewCallbacks(in interface{}, context *compiler.Context) (*Callbacks, error) {
|
|
errors := make([]error, 0)
|
|
x := &Callbacks{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{name}", "^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedCallbackOrReference name = 1;
|
|
// MAP: CallbackOrReference {name}
|
|
x.Name = make([]*NamedCallbackOrReference, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{name}", k) {
|
|
pair := &NamedCallbackOrReference{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewCallbackOrReference(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Name = append(x.Name, pair)
|
|
}
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 2;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewComponents(in interface{}, context *compiler.Context) (*Components, error) {
|
|
errors := make([]error, 0)
|
|
x := &Components{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"callbacks", "examples", "headers", "links", "parameters", "requestBodies", "responses", "schemas", "securitySchemes"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// Schemas schemas = 1;
|
|
v1 := compiler.MapValueForKey(m, "schemas")
|
|
if v1 != nil {
|
|
var err error
|
|
x.Schemas, err = NewSchemas(v1, compiler.NewContext("schemas", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Responses responses = 2;
|
|
v2 := compiler.MapValueForKey(m, "responses")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Responses, err = NewResponses(v2, compiler.NewContext("responses", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Parameters parameters = 3;
|
|
v3 := compiler.MapValueForKey(m, "parameters")
|
|
if v3 != nil {
|
|
var err error
|
|
x.Parameters, err = NewParameters(v3, compiler.NewContext("parameters", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Examples examples = 4;
|
|
v4 := compiler.MapValueForKey(m, "examples")
|
|
if v4 != nil {
|
|
var err error
|
|
x.Examples, err = NewExamples(v4, compiler.NewContext("examples", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// RequestBodies request_bodies = 5;
|
|
v5 := compiler.MapValueForKey(m, "requestBodies")
|
|
if v5 != nil {
|
|
var err error
|
|
x.RequestBodies, err = NewRequestBodies(v5, compiler.NewContext("requestBodies", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Headers headers = 6;
|
|
v6 := compiler.MapValueForKey(m, "headers")
|
|
if v6 != nil {
|
|
var err error
|
|
x.Headers, err = NewHeaders(v6, compiler.NewContext("headers", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// SecuritySchemes security_schemes = 7;
|
|
v7 := compiler.MapValueForKey(m, "securitySchemes")
|
|
if v7 != nil {
|
|
var err error
|
|
x.SecuritySchemes, err = NewSecuritySchemes(v7, compiler.NewContext("securitySchemes", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Links links = 8;
|
|
v8 := compiler.MapValueForKey(m, "links")
|
|
if v8 != nil {
|
|
var err error
|
|
x.Links, err = NewLinks(v8, compiler.NewContext("links", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Callbacks callbacks = 9;
|
|
v9 := compiler.MapValueForKey(m, "callbacks")
|
|
if v9 != nil {
|
|
var err error
|
|
x.Callbacks, err = NewCallbacks(v9, compiler.NewContext("callbacks", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 10;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewContact(in interface{}, context *compiler.Context) (*Contact, error) {
|
|
errors := make([]error, 0)
|
|
x := &Contact{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"email", "name", "url"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string url = 2;
|
|
v2 := compiler.MapValueForKey(m, "url")
|
|
if v2 != nil {
|
|
x.Url, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string email = 3;
|
|
v3 := compiler.MapValueForKey(m, "email")
|
|
if v3 != nil {
|
|
x.Email, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for email: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 4;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewContent(in interface{}, context *compiler.Context) (*Content, error) {
|
|
errors := make([]error, 0)
|
|
x := &Content{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{media-type}"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedMediaType media_type = 1;
|
|
// MAP: MediaType {media-type}
|
|
x.MediaType = make([]*NamedMediaType, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{media-type}", k) {
|
|
pair := &NamedMediaType{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewMediaType(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.MediaType = append(x.MediaType, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewDocument(in interface{}, context *compiler.Context) (*Document, error) {
|
|
errors := make([]error, 0)
|
|
x := &Document{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"info", "openapi", "paths"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"components", "externalDocs", "info", "openapi", "paths", "security", "servers", "tags"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string openapi = 1;
|
|
v1 := compiler.MapValueForKey(m, "openapi")
|
|
if v1 != nil {
|
|
x.Openapi, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for openapi: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Info info = 2;
|
|
v2 := compiler.MapValueForKey(m, "info")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Info, err = NewInfo(v2, compiler.NewContext("info", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated Server servers = 3;
|
|
v3 := compiler.MapValueForKey(m, "servers")
|
|
if v3 != nil {
|
|
// repeated Server
|
|
x.Servers = make([]*Server, 0)
|
|
a, ok := v3.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewServer(item, compiler.NewContext("servers", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Servers = append(x.Servers, y)
|
|
}
|
|
}
|
|
}
|
|
// Paths paths = 4;
|
|
v4 := compiler.MapValueForKey(m, "paths")
|
|
if v4 != nil {
|
|
var err error
|
|
x.Paths, err = NewPaths(v4, compiler.NewContext("paths", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Components components = 5;
|
|
v5 := compiler.MapValueForKey(m, "components")
|
|
if v5 != nil {
|
|
var err error
|
|
x.Components, err = NewComponents(v5, compiler.NewContext("components", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated SecurityRequirement security = 6;
|
|
v6 := compiler.MapValueForKey(m, "security")
|
|
if v6 != nil {
|
|
// repeated SecurityRequirement
|
|
x.Security = make([]*SecurityRequirement, 0)
|
|
a, ok := v6.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewSecurityRequirement(item, compiler.NewContext("security", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Security = append(x.Security, y)
|
|
}
|
|
}
|
|
}
|
|
// repeated Tag tags = 7;
|
|
v7 := compiler.MapValueForKey(m, "tags")
|
|
if v7 != nil {
|
|
// repeated Tag
|
|
x.Tags = make([]*Tag, 0)
|
|
a, ok := v7.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewTag(item, compiler.NewContext("tags", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Tags = append(x.Tags, y)
|
|
}
|
|
}
|
|
}
|
|
// ExternalDocs external_docs = 8;
|
|
v8 := compiler.MapValueForKey(m, "externalDocs")
|
|
if v8 != nil {
|
|
var err error
|
|
x.ExternalDocs, err = NewExternalDocs(v8, compiler.NewContext("externalDocs", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 9;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) {
|
|
errors := make([]error, 0)
|
|
x := &Encoding{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{property}"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedEncodingProperty property = 1;
|
|
// MAP: EncodingProperty {property}
|
|
x.Property = make([]*NamedEncodingProperty, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{property}", k) {
|
|
pair := &NamedEncodingProperty{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewEncodingProperty(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Property = append(x.Property, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewEncodingProperty(in interface{}, context *compiler.Context) (*EncodingProperty, error) {
|
|
errors := make([]error, 0)
|
|
x := &EncodingProperty{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"contentType", "explode", "headers", "style"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string content_type = 1;
|
|
v1 := compiler.MapValueForKey(m, "contentType")
|
|
if v1 != nil {
|
|
x.ContentType, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for contentType: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Object headers = 2;
|
|
v2 := compiler.MapValueForKey(m, "headers")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Headers, err = NewObject(v2, compiler.NewContext("headers", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// string style = 3;
|
|
v3 := compiler.MapValueForKey(m, "style")
|
|
if v3 != nil {
|
|
x.Style, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool explode = 4;
|
|
v4 := compiler.MapValueForKey(m, "explode")
|
|
if v4 != nil {
|
|
x.Explode, ok = v4.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v4, v4)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 5;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewExample(in interface{}, context *compiler.Context) (*Example, error) {
|
|
errors := make([]error, 0)
|
|
x := &Example{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewExampleOrReference(in interface{}, context *compiler.Context) (*ExampleOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &ExampleOrReference{}
|
|
matched := false
|
|
// Example example = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewExample(m, compiler.NewContext("example", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &ExampleOrReference_Example{Example: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Reference reference = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewReference(m, compiler.NewContext("reference", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &ExampleOrReference_Reference{Reference: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) {
|
|
errors := make([]error, 0)
|
|
x := &Examples{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewExpression(in interface{}, context *compiler.Context) (*Expression, error) {
|
|
errors := make([]error, 0)
|
|
x := &Expression{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
// repeated NamedAny additional_properties = 1;
|
|
// MAP: Any
|
|
x.AdditionalProperties = make([]*NamedAny, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
pair := &NamedAny{}
|
|
pair.Name = k
|
|
result := &Any{}
|
|
handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
|
|
if handled {
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
} else {
|
|
bytes, _ := yaml.Marshal(v)
|
|
result.Yaml = string(bytes)
|
|
result.Value = resultFromExt
|
|
pair.Value = result
|
|
}
|
|
} else {
|
|
pair.Value, err = NewAny(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
x.AdditionalProperties = append(x.AdditionalProperties, pair)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, error) {
|
|
errors := make([]error, 0)
|
|
x := &ExternalDocs{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"url"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"description", "url"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string description = 1;
|
|
v1 := compiler.MapValueForKey(m, "description")
|
|
if v1 != nil {
|
|
x.Description, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string url = 2;
|
|
v2 := compiler.MapValueForKey(m, "url")
|
|
if v2 != nil {
|
|
x.Url, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 3;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewHeader(in interface{}, context *compiler.Context) (*Header, error) {
|
|
errors := make([]error, 0)
|
|
x := &Header{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"allowEmptyValue", "allowReserved", "content", "deprecated", "description", "example", "examples", "explode", "in", "name", "required", "schema", "style"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string in = 2;
|
|
v2 := compiler.MapValueForKey(m, "in")
|
|
if v2 != nil {
|
|
x.In, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string description = 3;
|
|
v3 := compiler.MapValueForKey(m, "description")
|
|
if v3 != nil {
|
|
x.Description, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool required = 4;
|
|
v4 := compiler.MapValueForKey(m, "required")
|
|
if v4 != nil {
|
|
x.Required, ok = v4.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v4, v4)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool deprecated = 5;
|
|
v5 := compiler.MapValueForKey(m, "deprecated")
|
|
if v5 != nil {
|
|
x.Deprecated, ok = v5.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v5, v5)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool allow_empty_value = 6;
|
|
v6 := compiler.MapValueForKey(m, "allowEmptyValue")
|
|
if v6 != nil {
|
|
x.AllowEmptyValue, ok = v6.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v6, v6)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string style = 7;
|
|
v7 := compiler.MapValueForKey(m, "style")
|
|
if v7 != nil {
|
|
x.Style, ok = v7.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v7, v7)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool explode = 8;
|
|
v8 := compiler.MapValueForKey(m, "explode")
|
|
if v8 != nil {
|
|
x.Explode, ok = v8.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v8, v8)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool allow_reserved = 9;
|
|
v9 := compiler.MapValueForKey(m, "allowReserved")
|
|
if v9 != nil {
|
|
x.AllowReserved, ok = v9.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for allowReserved: %+v (%T)", v9, v9)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// SchemaOrReference schema = 10;
|
|
v10 := compiler.MapValueForKey(m, "schema")
|
|
if v10 != nil {
|
|
var err error
|
|
x.Schema, err = NewSchemaOrReference(v10, compiler.NewContext("schema", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated ExampleOrReference examples = 11;
|
|
v11 := compiler.MapValueForKey(m, "examples")
|
|
if v11 != nil {
|
|
// repeated ExampleOrReference
|
|
x.Examples = make([]*ExampleOrReference, 0)
|
|
a, ok := v11.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewExampleOrReference(item, compiler.NewContext("examples", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Examples = append(x.Examples, y)
|
|
}
|
|
}
|
|
}
|
|
// ExampleOrReference example = 12;
|
|
v12 := compiler.MapValueForKey(m, "example")
|
|
if v12 != nil {
|
|
var err error
|
|
x.Example, err = NewExampleOrReference(v12, compiler.NewContext("example", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Content content = 13;
|
|
v13 := compiler.MapValueForKey(m, "content")
|
|
if v13 != nil {
|
|
var err error
|
|
x.Content, err = NewContent(v13, compiler.NewContext("content", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewHeaderOrReference(in interface{}, context *compiler.Context) (*HeaderOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &HeaderOrReference{}
|
|
matched := false
|
|
// Header header = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewHeader(m, compiler.NewContext("header", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &HeaderOrReference_Header{Header: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Reference reference = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewReference(m, compiler.NewContext("reference", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &HeaderOrReference_Reference{Reference: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) {
|
|
errors := make([]error, 0)
|
|
x := &Headers{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{name}"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedHeaderOrReference name = 1;
|
|
// MAP: HeaderOrReference {name}
|
|
x.Name = make([]*NamedHeaderOrReference, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{name}", k) {
|
|
pair := &NamedHeaderOrReference{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewHeaderOrReference(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Name = append(x.Name, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewInfo(in interface{}, context *compiler.Context) (*Info, error) {
|
|
errors := make([]error, 0)
|
|
x := &Info{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"title", "version"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"contact", "description", "license", "termsOfService", "title", "version"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string title = 1;
|
|
v1 := compiler.MapValueForKey(m, "title")
|
|
if v1 != nil {
|
|
x.Title, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string description = 2;
|
|
v2 := compiler.MapValueForKey(m, "description")
|
|
if v2 != nil {
|
|
x.Description, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string terms_of_service = 3;
|
|
v3 := compiler.MapValueForKey(m, "termsOfService")
|
|
if v3 != nil {
|
|
x.TermsOfService, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for termsOfService: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Contact contact = 4;
|
|
v4 := compiler.MapValueForKey(m, "contact")
|
|
if v4 != nil {
|
|
var err error
|
|
x.Contact, err = NewContact(v4, compiler.NewContext("contact", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// License license = 5;
|
|
v5 := compiler.MapValueForKey(m, "license")
|
|
if v5 != nil {
|
|
var err error
|
|
x.License, err = NewLicense(v5, compiler.NewContext("license", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// string version = 6;
|
|
v6 := compiler.MapValueForKey(m, "version")
|
|
if v6 != nil {
|
|
x.Version, ok = v6.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v6, v6)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 7;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) {
|
|
errors := make([]error, 0)
|
|
x := &ItemsItem{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for item array: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
x.SchemaOrReference = make([]*SchemaOrReference, 0)
|
|
y, err := NewSchemaOrReference(m, compiler.NewContext("<array>", context))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
x.SchemaOrReference = append(x.SchemaOrReference, y)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewLicense(in interface{}, context *compiler.Context) (*License, error) {
|
|
errors := make([]error, 0)
|
|
x := &License{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"name"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"name", "url"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string url = 2;
|
|
v2 := compiler.MapValueForKey(m, "url")
|
|
if v2 != nil {
|
|
x.Url, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 3;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewLink(in interface{}, context *compiler.Context) (*Link, error) {
|
|
errors := make([]error, 0)
|
|
x := &Link{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"description", "headers", "href", "operationId", "parameters"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string href = 1;
|
|
v1 := compiler.MapValueForKey(m, "href")
|
|
if v1 != nil {
|
|
x.Href, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for href: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string operation_id = 2;
|
|
v2 := compiler.MapValueForKey(m, "operationId")
|
|
if v2 != nil {
|
|
x.OperationId, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// LinkParameters parameters = 3;
|
|
v3 := compiler.MapValueForKey(m, "parameters")
|
|
if v3 != nil {
|
|
var err error
|
|
x.Parameters, err = NewLinkParameters(v3, compiler.NewContext("parameters", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Headers headers = 4;
|
|
v4 := compiler.MapValueForKey(m, "headers")
|
|
if v4 != nil {
|
|
var err error
|
|
x.Headers, err = NewHeaders(v4, compiler.NewContext("headers", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// string description = 5;
|
|
v5 := compiler.MapValueForKey(m, "description")
|
|
if v5 != nil {
|
|
x.Description, ok = v5.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 6;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewLinkOrReference(in interface{}, context *compiler.Context) (*LinkOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &LinkOrReference{}
|
|
matched := false
|
|
// Link link = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewLink(m, compiler.NewContext("link", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &LinkOrReference_Link{Link: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Reference reference = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewReference(m, compiler.NewContext("reference", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &LinkOrReference_Reference{Reference: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewLinkParameters(in interface{}, context *compiler.Context) (*LinkParameters, error) {
|
|
errors := make([]error, 0)
|
|
x := &LinkParameters{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{name}"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedAnyOrExpression name = 1;
|
|
// MAP: AnyOrExpression {name}
|
|
x.Name = make([]*NamedAnyOrExpression, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{name}", k) {
|
|
pair := &NamedAnyOrExpression{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewAnyOrExpression(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Name = append(x.Name, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewLinks(in interface{}, context *compiler.Context) (*Links, error) {
|
|
errors := make([]error, 0)
|
|
x := &Links{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{name}"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedLinkOrReference name = 1;
|
|
// MAP: LinkOrReference {name}
|
|
x.Name = make([]*NamedLinkOrReference, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{name}", k) {
|
|
pair := &NamedLinkOrReference{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewLinkOrReference(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Name = append(x.Name, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewMediaType(in interface{}, context *compiler.Context) (*MediaType, error) {
|
|
errors := make([]error, 0)
|
|
x := &MediaType{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"encoding", "example", "examples", "schema"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// SchemaOrReference schema = 1;
|
|
v1 := compiler.MapValueForKey(m, "schema")
|
|
if v1 != nil {
|
|
var err error
|
|
x.Schema, err = NewSchemaOrReference(v1, compiler.NewContext("schema", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated ExampleOrReference examples = 2;
|
|
v2 := compiler.MapValueForKey(m, "examples")
|
|
if v2 != nil {
|
|
// repeated ExampleOrReference
|
|
x.Examples = make([]*ExampleOrReference, 0)
|
|
a, ok := v2.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewExampleOrReference(item, compiler.NewContext("examples", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Examples = append(x.Examples, y)
|
|
}
|
|
}
|
|
}
|
|
// ExampleOrReference example = 3;
|
|
v3 := compiler.MapValueForKey(m, "example")
|
|
if v3 != nil {
|
|
var err error
|
|
x.Example, err = NewExampleOrReference(v3, compiler.NewContext("example", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Encoding encoding = 4;
|
|
v4 := compiler.MapValueForKey(m, "encoding")
|
|
if v4 != nil {
|
|
var err error
|
|
x.Encoding, err = NewEncoding(v4, compiler.NewContext("encoding", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 5;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedAny{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Any value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewAny(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedAnyOrExpression(in interface{}, context *compiler.Context) (*NamedAnyOrExpression, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedAnyOrExpression{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// AnyOrExpression value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewAnyOrExpression(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedCallbackOrReference(in interface{}, context *compiler.Context) (*NamedCallbackOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedCallbackOrReference{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// CallbackOrReference value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewCallbackOrReference(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedEncodingProperty(in interface{}, context *compiler.Context) (*NamedEncodingProperty, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedEncodingProperty{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// EncodingProperty value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewEncodingProperty(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedHeaderOrReference(in interface{}, context *compiler.Context) (*NamedHeaderOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedHeaderOrReference{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// HeaderOrReference value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewHeaderOrReference(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedLinkOrReference(in interface{}, context *compiler.Context) (*NamedLinkOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedLinkOrReference{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// LinkOrReference value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewLinkOrReference(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedMediaType(in interface{}, context *compiler.Context) (*NamedMediaType, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedMediaType{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// MediaType value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewMediaType(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParameter, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedParameter{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Parameter value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewParameter(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedPathItem{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// PathItem value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewPathItem(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedRequestBody(in interface{}, context *compiler.Context) (*NamedRequestBody, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedRequestBody{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// RequestBody value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewRequestBody(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedResponseOrReference(in interface{}, context *compiler.Context) (*NamedResponseOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedResponseOrReference{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// ResponseOrReference value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewResponseOrReference(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedSchema{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Schema value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewSchema(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedSecurityScheme(in interface{}, context *compiler.Context) (*NamedSecurityScheme, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedSecurityScheme{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// SecurityScheme value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewSecurityScheme(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedServerVariable(in interface{}, context *compiler.Context) (*NamedServerVariable, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedServerVariable{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// ServerVariable value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewServerVariable(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewNamedSpecificationExtension(in interface{}, context *compiler.Context) (*NamedSpecificationExtension, error) {
|
|
errors := make([]error, 0)
|
|
x := &NamedSpecificationExtension{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"name", "value"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// SpecificationExtension value = 2;
|
|
v2 := compiler.MapValueForKey(m, "value")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Value, err = NewSpecificationExtension(v2, compiler.NewContext("value", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) {
|
|
errors := make([]error, 0)
|
|
x := &OauthFlow{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"authorizationUrl", "refreshUrl", "scopes", "tokenUrl"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string authorization_url = 1;
|
|
v1 := compiler.MapValueForKey(m, "authorizationUrl")
|
|
if v1 != nil {
|
|
x.AuthorizationUrl, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string token_url = 2;
|
|
v2 := compiler.MapValueForKey(m, "tokenUrl")
|
|
if v2 != nil {
|
|
x.TokenUrl, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string refresh_url = 3;
|
|
v3 := compiler.MapValueForKey(m, "refreshUrl")
|
|
if v3 != nil {
|
|
x.RefreshUrl, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for refreshUrl: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Scopes scopes = 4;
|
|
v4 := compiler.MapValueForKey(m, "scopes")
|
|
if v4 != nil {
|
|
var err error
|
|
x.Scopes, err = NewScopes(v4, compiler.NewContext("scopes", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 5;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewOauthFlows(in interface{}, context *compiler.Context) (*OauthFlows, error) {
|
|
errors := make([]error, 0)
|
|
x := &OauthFlows{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"authorizationCode", "clientCredentials", "implicit", "password"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// OauthFlow implicit = 1;
|
|
v1 := compiler.MapValueForKey(m, "implicit")
|
|
if v1 != nil {
|
|
var err error
|
|
x.Implicit, err = NewOauthFlow(v1, compiler.NewContext("implicit", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// OauthFlow password = 2;
|
|
v2 := compiler.MapValueForKey(m, "password")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Password, err = NewOauthFlow(v2, compiler.NewContext("password", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// OauthFlow client_credentials = 3;
|
|
v3 := compiler.MapValueForKey(m, "clientCredentials")
|
|
if v3 != nil {
|
|
var err error
|
|
x.ClientCredentials, err = NewOauthFlow(v3, compiler.NewContext("clientCredentials", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// OauthFlow authorization_code = 4;
|
|
v4 := compiler.MapValueForKey(m, "authorizationCode")
|
|
if v4 != nil {
|
|
var err error
|
|
x.AuthorizationCode, err = NewOauthFlow(v4, compiler.NewContext("authorizationCode", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 5;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewObject(in interface{}, context *compiler.Context) (*Object, error) {
|
|
errors := make([]error, 0)
|
|
x := &Object{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
// repeated NamedAny additional_properties = 1;
|
|
// MAP: Any
|
|
x.AdditionalProperties = make([]*NamedAny, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
pair := &NamedAny{}
|
|
pair.Name = k
|
|
result := &Any{}
|
|
handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
|
|
if handled {
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
} else {
|
|
bytes, _ := yaml.Marshal(v)
|
|
result.Yaml = string(bytes)
|
|
result.Value = resultFromExt
|
|
pair.Value = result
|
|
}
|
|
} else {
|
|
pair.Value, err = NewAny(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
x.AdditionalProperties = append(x.AdditionalProperties, pair)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) {
|
|
errors := make([]error, 0)
|
|
x := &Operation{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"responses"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"callbacks", "deprecated", "description", "externalDocs", "operationId", "parameters", "requestBody", "responses", "security", "servers", "summary", "tags"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated string tags = 1;
|
|
v1 := compiler.MapValueForKey(m, "tags")
|
|
if v1 != nil {
|
|
v, ok := v1.([]interface{})
|
|
if ok {
|
|
x.Tags = compiler.ConvertInterfaceArrayToStringArray(v)
|
|
} else {
|
|
message := fmt.Sprintf("has unexpected value for tags: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string summary = 2;
|
|
v2 := compiler.MapValueForKey(m, "summary")
|
|
if v2 != nil {
|
|
x.Summary, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string description = 3;
|
|
v3 := compiler.MapValueForKey(m, "description")
|
|
if v3 != nil {
|
|
x.Description, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// ExternalDocs external_docs = 4;
|
|
v4 := compiler.MapValueForKey(m, "externalDocs")
|
|
if v4 != nil {
|
|
var err error
|
|
x.ExternalDocs, err = NewExternalDocs(v4, compiler.NewContext("externalDocs", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// string operation_id = 5;
|
|
v5 := compiler.MapValueForKey(m, "operationId")
|
|
if v5 != nil {
|
|
x.OperationId, ok = v5.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v5, v5)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated ParameterOrReference parameters = 6;
|
|
v6 := compiler.MapValueForKey(m, "parameters")
|
|
if v6 != nil {
|
|
// repeated ParameterOrReference
|
|
x.Parameters = make([]*ParameterOrReference, 0)
|
|
a, ok := v6.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewParameterOrReference(item, compiler.NewContext("parameters", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Parameters = append(x.Parameters, y)
|
|
}
|
|
}
|
|
}
|
|
// RequestBodyOrReference request_body = 7;
|
|
v7 := compiler.MapValueForKey(m, "requestBody")
|
|
if v7 != nil {
|
|
var err error
|
|
x.RequestBody, err = NewRequestBodyOrReference(v7, compiler.NewContext("requestBody", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Responses responses = 8;
|
|
v8 := compiler.MapValueForKey(m, "responses")
|
|
if v8 != nil {
|
|
var err error
|
|
x.Responses, err = NewResponses(v8, compiler.NewContext("responses", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Callbacks callbacks = 9;
|
|
v9 := compiler.MapValueForKey(m, "callbacks")
|
|
if v9 != nil {
|
|
var err error
|
|
x.Callbacks, err = NewCallbacks(v9, compiler.NewContext("callbacks", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// bool deprecated = 10;
|
|
v10 := compiler.MapValueForKey(m, "deprecated")
|
|
if v10 != nil {
|
|
x.Deprecated, ok = v10.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v10, v10)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated SecurityRequirement security = 11;
|
|
v11 := compiler.MapValueForKey(m, "security")
|
|
if v11 != nil {
|
|
// repeated SecurityRequirement
|
|
x.Security = make([]*SecurityRequirement, 0)
|
|
a, ok := v11.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewSecurityRequirement(item, compiler.NewContext("security", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Security = append(x.Security, y)
|
|
}
|
|
}
|
|
}
|
|
// Server servers = 12;
|
|
v12 := compiler.MapValueForKey(m, "servers")
|
|
if v12 != nil {
|
|
var err error
|
|
x.Servers, err = NewServer(v12, compiler.NewContext("servers", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 13;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) {
|
|
errors := make([]error, 0)
|
|
x := &Parameter{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"in", "name"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"allowEmptyValue", "allowReserved", "content", "deprecated", "description", "example", "examples", "explode", "in", "name", "required", "schema", "style"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string in = 2;
|
|
v2 := compiler.MapValueForKey(m, "in")
|
|
if v2 != nil {
|
|
x.In, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string description = 3;
|
|
v3 := compiler.MapValueForKey(m, "description")
|
|
if v3 != nil {
|
|
x.Description, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool required = 4;
|
|
v4 := compiler.MapValueForKey(m, "required")
|
|
if v4 != nil {
|
|
x.Required, ok = v4.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v4, v4)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool deprecated = 5;
|
|
v5 := compiler.MapValueForKey(m, "deprecated")
|
|
if v5 != nil {
|
|
x.Deprecated, ok = v5.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v5, v5)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool allow_empty_value = 6;
|
|
v6 := compiler.MapValueForKey(m, "allowEmptyValue")
|
|
if v6 != nil {
|
|
x.AllowEmptyValue, ok = v6.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v6, v6)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string style = 7;
|
|
v7 := compiler.MapValueForKey(m, "style")
|
|
if v7 != nil {
|
|
x.Style, ok = v7.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v7, v7)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool explode = 8;
|
|
v8 := compiler.MapValueForKey(m, "explode")
|
|
if v8 != nil {
|
|
x.Explode, ok = v8.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v8, v8)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool allow_reserved = 9;
|
|
v9 := compiler.MapValueForKey(m, "allowReserved")
|
|
if v9 != nil {
|
|
x.AllowReserved, ok = v9.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for allowReserved: %+v (%T)", v9, v9)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// SchemaOrReference schema = 10;
|
|
v10 := compiler.MapValueForKey(m, "schema")
|
|
if v10 != nil {
|
|
var err error
|
|
x.Schema, err = NewSchemaOrReference(v10, compiler.NewContext("schema", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated ExampleOrReference examples = 11;
|
|
v11 := compiler.MapValueForKey(m, "examples")
|
|
if v11 != nil {
|
|
// repeated ExampleOrReference
|
|
x.Examples = make([]*ExampleOrReference, 0)
|
|
a, ok := v11.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewExampleOrReference(item, compiler.NewContext("examples", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Examples = append(x.Examples, y)
|
|
}
|
|
}
|
|
}
|
|
// ExampleOrReference example = 12;
|
|
v12 := compiler.MapValueForKey(m, "example")
|
|
if v12 != nil {
|
|
var err error
|
|
x.Example, err = NewExampleOrReference(v12, compiler.NewContext("example", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Content content = 13;
|
|
v13 := compiler.MapValueForKey(m, "content")
|
|
if v13 != nil {
|
|
var err error
|
|
x.Content, err = NewContent(v13, compiler.NewContext("content", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 14;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewParameterOrReference(in interface{}, context *compiler.Context) (*ParameterOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &ParameterOrReference{}
|
|
matched := false
|
|
// Parameter parameter = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewParameter(m, compiler.NewContext("parameter", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &ParameterOrReference_Parameter{Parameter: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Reference reference = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewReference(m, compiler.NewContext("reference", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &ParameterOrReference_Reference{Reference: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewParameters(in interface{}, context *compiler.Context) (*Parameters, error) {
|
|
errors := make([]error, 0)
|
|
x := &Parameters{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
// repeated NamedParameter additional_properties = 1;
|
|
// MAP: Parameter
|
|
x.AdditionalProperties = make([]*NamedParameter, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
pair := &NamedParameter{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewParameter(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.AdditionalProperties = append(x.AdditionalProperties, pair)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) {
|
|
errors := make([]error, 0)
|
|
x := &PathItem{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"$ref", "delete", "description", "get", "head", "options", "parameters", "patch", "post", "put", "servers", "summary", "trace"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string _ref = 1;
|
|
v1 := compiler.MapValueForKey(m, "$ref")
|
|
if v1 != nil {
|
|
x.XRef, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string summary = 2;
|
|
v2 := compiler.MapValueForKey(m, "summary")
|
|
if v2 != nil {
|
|
x.Summary, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string description = 3;
|
|
v3 := compiler.MapValueForKey(m, "description")
|
|
if v3 != nil {
|
|
x.Description, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Operation get = 4;
|
|
v4 := compiler.MapValueForKey(m, "get")
|
|
if v4 != nil {
|
|
var err error
|
|
x.Get, err = NewOperation(v4, compiler.NewContext("get", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Operation put = 5;
|
|
v5 := compiler.MapValueForKey(m, "put")
|
|
if v5 != nil {
|
|
var err error
|
|
x.Put, err = NewOperation(v5, compiler.NewContext("put", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Operation post = 6;
|
|
v6 := compiler.MapValueForKey(m, "post")
|
|
if v6 != nil {
|
|
var err error
|
|
x.Post, err = NewOperation(v6, compiler.NewContext("post", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Operation delete = 7;
|
|
v7 := compiler.MapValueForKey(m, "delete")
|
|
if v7 != nil {
|
|
var err error
|
|
x.Delete, err = NewOperation(v7, compiler.NewContext("delete", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Operation options = 8;
|
|
v8 := compiler.MapValueForKey(m, "options")
|
|
if v8 != nil {
|
|
var err error
|
|
x.Options, err = NewOperation(v8, compiler.NewContext("options", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Operation head = 9;
|
|
v9 := compiler.MapValueForKey(m, "head")
|
|
if v9 != nil {
|
|
var err error
|
|
x.Head, err = NewOperation(v9, compiler.NewContext("head", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Operation patch = 10;
|
|
v10 := compiler.MapValueForKey(m, "patch")
|
|
if v10 != nil {
|
|
var err error
|
|
x.Patch, err = NewOperation(v10, compiler.NewContext("patch", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Operation trace = 11;
|
|
v11 := compiler.MapValueForKey(m, "trace")
|
|
if v11 != nil {
|
|
var err error
|
|
x.Trace, err = NewOperation(v11, compiler.NewContext("trace", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Server servers = 12;
|
|
v12 := compiler.MapValueForKey(m, "servers")
|
|
if v12 != nil {
|
|
var err error
|
|
x.Servers, err = NewServer(v12, compiler.NewContext("servers", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated ParameterOrReference parameters = 13;
|
|
v13 := compiler.MapValueForKey(m, "parameters")
|
|
if v13 != nil {
|
|
// repeated ParameterOrReference
|
|
x.Parameters = make([]*ParameterOrReference, 0)
|
|
a, ok := v13.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewParameterOrReference(item, compiler.NewContext("parameters", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Parameters = append(x.Parameters, y)
|
|
}
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 14;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) {
|
|
errors := make([]error, 0)
|
|
x := &Paths{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"/{path}", "^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedPathItem path = 1;
|
|
// MAP: PathItem /{path}
|
|
x.Path = make([]*NamedPathItem, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("/{path}", k) {
|
|
pair := &NamedPathItem{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewPathItem(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Path = append(x.Path, pair)
|
|
}
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 2;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewPrimitive(in interface{}, context *compiler.Context) (*Primitive, error) {
|
|
errors := make([]error, 0)
|
|
x := &Primitive{}
|
|
matched := false
|
|
switch in := in.(type) {
|
|
case bool:
|
|
x.Oneof = &Primitive_Boolean{Boolean: in}
|
|
matched = true
|
|
case string:
|
|
x.Oneof = &Primitive_String_{String_: in}
|
|
matched = true
|
|
case int64:
|
|
x.Oneof = &Primitive_Integer{Integer: in}
|
|
matched = true
|
|
case int32:
|
|
x.Oneof = &Primitive_Integer{Integer: int64(in)}
|
|
matched = true
|
|
case int:
|
|
x.Oneof = &Primitive_Integer{Integer: int64(in)}
|
|
matched = true
|
|
case float64:
|
|
x.Oneof = &Primitive_Number{Number: in}
|
|
matched = true
|
|
case float32:
|
|
x.Oneof = &Primitive_Number{Number: float64(in)}
|
|
matched = true
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewProperties(in interface{}, context *compiler.Context) (*Properties, error) {
|
|
errors := make([]error, 0)
|
|
x := &Properties{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
// repeated NamedSchema additional_properties = 1;
|
|
// MAP: Schema
|
|
x.AdditionalProperties = make([]*NamedSchema, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
pair := &NamedSchema{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSchema(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.AdditionalProperties = append(x.AdditionalProperties, pair)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewReference(in interface{}, context *compiler.Context) (*Reference, error) {
|
|
errors := make([]error, 0)
|
|
x := &Reference{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"$ref"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"$ref"}
|
|
allowedPatterns := []string{}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string _ref = 1;
|
|
v1 := compiler.MapValueForKey(m, "$ref")
|
|
if v1 != nil {
|
|
x.XRef, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewRequestBodies(in interface{}, context *compiler.Context) (*RequestBodies, error) {
|
|
errors := make([]error, 0)
|
|
x := &RequestBodies{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
// repeated NamedRequestBody additional_properties = 1;
|
|
// MAP: RequestBody
|
|
x.AdditionalProperties = make([]*NamedRequestBody, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
pair := &NamedRequestBody{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewRequestBody(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.AdditionalProperties = append(x.AdditionalProperties, pair)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, error) {
|
|
errors := make([]error, 0)
|
|
x := &RequestBody{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"content", "description", "required"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string description = 1;
|
|
v1 := compiler.MapValueForKey(m, "description")
|
|
if v1 != nil {
|
|
x.Description, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Content content = 2;
|
|
v2 := compiler.MapValueForKey(m, "content")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Content, err = NewContent(v2, compiler.NewContext("content", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// bool required = 3;
|
|
v3 := compiler.MapValueForKey(m, "required")
|
|
if v3 != nil {
|
|
x.Required, ok = v3.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 4;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewRequestBodyOrReference(in interface{}, context *compiler.Context) (*RequestBodyOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &RequestBodyOrReference{}
|
|
matched := false
|
|
// RequestBody request_body = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewRequestBody(m, compiler.NewContext("requestBody", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &RequestBodyOrReference_RequestBody{RequestBody: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Reference reference = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewReference(m, compiler.NewContext("reference", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &RequestBodyOrReference_Reference{Reference: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewResponse(in interface{}, context *compiler.Context) (*Response, error) {
|
|
errors := make([]error, 0)
|
|
x := &Response{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"description"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"content", "description", "headers", "links"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string description = 1;
|
|
v1 := compiler.MapValueForKey(m, "description")
|
|
if v1 != nil {
|
|
x.Description, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Headers headers = 2;
|
|
v2 := compiler.MapValueForKey(m, "headers")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Headers, err = NewHeaders(v2, compiler.NewContext("headers", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Content content = 3;
|
|
v3 := compiler.MapValueForKey(m, "content")
|
|
if v3 != nil {
|
|
var err error
|
|
x.Content, err = NewContent(v3, compiler.NewContext("content", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Links links = 4;
|
|
v4 := compiler.MapValueForKey(m, "links")
|
|
if v4 != nil {
|
|
var err error
|
|
x.Links, err = NewLinks(v4, compiler.NewContext("links", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 5;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewResponseOrReference(in interface{}, context *compiler.Context) (*ResponseOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &ResponseOrReference{}
|
|
matched := false
|
|
// Response response = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewResponse(m, compiler.NewContext("response", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &ResponseOrReference_Response{Response: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Reference reference = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewReference(m, compiler.NewContext("reference", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &ResponseOrReference_Reference{Reference: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) {
|
|
errors := make([]error, 0)
|
|
x := &Responses{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"default"}
|
|
allowedPatterns := []string{"^([0-9]{3})$", "^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// ResponseOrReference default = 1;
|
|
v1 := compiler.MapValueForKey(m, "default")
|
|
if v1 != nil {
|
|
var err error
|
|
x.Default, err = NewResponseOrReference(v1, compiler.NewContext("default", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedResponseOrReference response_code = 2;
|
|
// MAP: ResponseOrReference ^([0-9]{3})$
|
|
x.ResponseCode = make([]*NamedResponseOrReference, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^([0-9]{3})$", k) {
|
|
pair := &NamedResponseOrReference{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewResponseOrReference(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.ResponseCode = append(x.ResponseCode, pair)
|
|
}
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 3;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) {
|
|
errors := make([]error, 0)
|
|
x := &Schema{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"allOf", "anyOf", "deprecated", "description", "discriminator", "enum", "exclusiveMaximum", "exclusiveMinimum", "externalDocs", "format", "items", "maxItems", "maxLength", "maxProperties", "maximum", "minItems", "minLength", "minProperties", "minimum", "multipleOf", "not", "nullable", "oneOf", "pattern", "properties", "readOnly", "required", "title", "type", "uniqueItems", "writeOnly", "xml"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// bool nullable = 1;
|
|
v1 := compiler.MapValueForKey(m, "nullable")
|
|
if v1 != nil {
|
|
x.Nullable, ok = v1.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for nullable: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string discriminator = 2;
|
|
v2 := compiler.MapValueForKey(m, "discriminator")
|
|
if v2 != nil {
|
|
x.Discriminator, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for discriminator: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool read_only = 3;
|
|
v3 := compiler.MapValueForKey(m, "readOnly")
|
|
if v3 != nil {
|
|
x.ReadOnly, ok = v3.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool write_only = 4;
|
|
v4 := compiler.MapValueForKey(m, "writeOnly")
|
|
if v4 != nil {
|
|
x.WriteOnly, ok = v4.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for writeOnly: %+v (%T)", v4, v4)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// Xml xml = 5;
|
|
v5 := compiler.MapValueForKey(m, "xml")
|
|
if v5 != nil {
|
|
var err error
|
|
x.Xml, err = NewXml(v5, compiler.NewContext("xml", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// ExternalDocs external_docs = 6;
|
|
v6 := compiler.MapValueForKey(m, "externalDocs")
|
|
if v6 != nil {
|
|
var err error
|
|
x.ExternalDocs, err = NewExternalDocs(v6, compiler.NewContext("externalDocs", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// bool deprecated = 7;
|
|
v7 := compiler.MapValueForKey(m, "deprecated")
|
|
if v7 != nil {
|
|
x.Deprecated, ok = v7.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v7, v7)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string title = 8;
|
|
v8 := compiler.MapValueForKey(m, "title")
|
|
if v8 != nil {
|
|
x.Title, ok = v8.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v8, v8)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// float multiple_of = 9;
|
|
v9 := compiler.MapValueForKey(m, "multipleOf")
|
|
if v9 != nil {
|
|
switch v9 := v9.(type) {
|
|
case float64:
|
|
x.MultipleOf = v9
|
|
case float32:
|
|
x.MultipleOf = float64(v9)
|
|
case uint64:
|
|
x.MultipleOf = float64(v9)
|
|
case uint32:
|
|
x.MultipleOf = float64(v9)
|
|
case int64:
|
|
x.MultipleOf = float64(v9)
|
|
case int32:
|
|
x.MultipleOf = float64(v9)
|
|
case int:
|
|
x.MultipleOf = float64(v9)
|
|
default:
|
|
message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v9, v9)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// float maximum = 10;
|
|
v10 := compiler.MapValueForKey(m, "maximum")
|
|
if v10 != nil {
|
|
switch v10 := v10.(type) {
|
|
case float64:
|
|
x.Maximum = v10
|
|
case float32:
|
|
x.Maximum = float64(v10)
|
|
case uint64:
|
|
x.Maximum = float64(v10)
|
|
case uint32:
|
|
x.Maximum = float64(v10)
|
|
case int64:
|
|
x.Maximum = float64(v10)
|
|
case int32:
|
|
x.Maximum = float64(v10)
|
|
case int:
|
|
x.Maximum = float64(v10)
|
|
default:
|
|
message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool exclusive_maximum = 11;
|
|
v11 := compiler.MapValueForKey(m, "exclusiveMaximum")
|
|
if v11 != nil {
|
|
x.ExclusiveMaximum, ok = v11.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// float minimum = 12;
|
|
v12 := compiler.MapValueForKey(m, "minimum")
|
|
if v12 != nil {
|
|
switch v12 := v12.(type) {
|
|
case float64:
|
|
x.Minimum = v12
|
|
case float32:
|
|
x.Minimum = float64(v12)
|
|
case uint64:
|
|
x.Minimum = float64(v12)
|
|
case uint32:
|
|
x.Minimum = float64(v12)
|
|
case int64:
|
|
x.Minimum = float64(v12)
|
|
case int32:
|
|
x.Minimum = float64(v12)
|
|
case int:
|
|
x.Minimum = float64(v12)
|
|
default:
|
|
message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool exclusive_minimum = 13;
|
|
v13 := compiler.MapValueForKey(m, "exclusiveMinimum")
|
|
if v13 != nil {
|
|
x.ExclusiveMinimum, ok = v13.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// int64 max_length = 14;
|
|
v14 := compiler.MapValueForKey(m, "maxLength")
|
|
if v14 != nil {
|
|
t, ok := v14.(int)
|
|
if ok {
|
|
x.MaxLength = int64(t)
|
|
} else {
|
|
message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v14, v14)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// int64 min_length = 15;
|
|
v15 := compiler.MapValueForKey(m, "minLength")
|
|
if v15 != nil {
|
|
t, ok := v15.(int)
|
|
if ok {
|
|
x.MinLength = int64(t)
|
|
} else {
|
|
message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v15, v15)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string pattern = 16;
|
|
v16 := compiler.MapValueForKey(m, "pattern")
|
|
if v16 != nil {
|
|
x.Pattern, ok = v16.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// int64 max_items = 17;
|
|
v17 := compiler.MapValueForKey(m, "maxItems")
|
|
if v17 != nil {
|
|
t, ok := v17.(int)
|
|
if ok {
|
|
x.MaxItems = int64(t)
|
|
} else {
|
|
message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v17, v17)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// int64 min_items = 18;
|
|
v18 := compiler.MapValueForKey(m, "minItems")
|
|
if v18 != nil {
|
|
t, ok := v18.(int)
|
|
if ok {
|
|
x.MinItems = int64(t)
|
|
} else {
|
|
message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v18, v18)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool unique_items = 19;
|
|
v19 := compiler.MapValueForKey(m, "uniqueItems")
|
|
if v19 != nil {
|
|
x.UniqueItems, ok = v19.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// int64 max_properties = 20;
|
|
v20 := compiler.MapValueForKey(m, "maxProperties")
|
|
if v20 != nil {
|
|
t, ok := v20.(int)
|
|
if ok {
|
|
x.MaxProperties = int64(t)
|
|
} else {
|
|
message := fmt.Sprintf("has unexpected value for maxProperties: %+v (%T)", v20, v20)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// int64 min_properties = 21;
|
|
v21 := compiler.MapValueForKey(m, "minProperties")
|
|
if v21 != nil {
|
|
t, ok := v21.(int)
|
|
if ok {
|
|
x.MinProperties = int64(t)
|
|
} else {
|
|
message := fmt.Sprintf("has unexpected value for minProperties: %+v (%T)", v21, v21)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated string required = 22;
|
|
v22 := compiler.MapValueForKey(m, "required")
|
|
if v22 != nil {
|
|
v, ok := v22.([]interface{})
|
|
if ok {
|
|
x.Required = compiler.ConvertInterfaceArrayToStringArray(v)
|
|
} else {
|
|
message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v22, v22)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated Any enum = 23;
|
|
v23 := compiler.MapValueForKey(m, "enum")
|
|
if v23 != nil {
|
|
// repeated Any
|
|
x.Enum = make([]*Any, 0)
|
|
a, ok := v23.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewAny(item, compiler.NewContext("enum", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Enum = append(x.Enum, y)
|
|
}
|
|
}
|
|
}
|
|
// string type = 24;
|
|
v24 := compiler.MapValueForKey(m, "type")
|
|
if v24 != nil {
|
|
x.Type, ok = v24.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v24, v24)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated SchemaOrReference all_of = 25;
|
|
v25 := compiler.MapValueForKey(m, "allOf")
|
|
if v25 != nil {
|
|
// repeated SchemaOrReference
|
|
x.AllOf = make([]*SchemaOrReference, 0)
|
|
a, ok := v25.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewSchemaOrReference(item, compiler.NewContext("allOf", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.AllOf = append(x.AllOf, y)
|
|
}
|
|
}
|
|
}
|
|
// repeated SchemaOrReference one_of = 26;
|
|
v26 := compiler.MapValueForKey(m, "oneOf")
|
|
if v26 != nil {
|
|
// repeated SchemaOrReference
|
|
x.OneOf = make([]*SchemaOrReference, 0)
|
|
a, ok := v26.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewSchemaOrReference(item, compiler.NewContext("oneOf", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.OneOf = append(x.OneOf, y)
|
|
}
|
|
}
|
|
}
|
|
// repeated SchemaOrReference any_of = 27;
|
|
v27 := compiler.MapValueForKey(m, "anyOf")
|
|
if v27 != nil {
|
|
// repeated SchemaOrReference
|
|
x.AnyOf = make([]*SchemaOrReference, 0)
|
|
a, ok := v27.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewSchemaOrReference(item, compiler.NewContext("anyOf", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.AnyOf = append(x.AnyOf, y)
|
|
}
|
|
}
|
|
}
|
|
// Schema not = 28;
|
|
v28 := compiler.MapValueForKey(m, "not")
|
|
if v28 != nil {
|
|
var err error
|
|
x.Not, err = NewSchema(v28, compiler.NewContext("not", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// ItemsItem items = 29;
|
|
v29 := compiler.MapValueForKey(m, "items")
|
|
if v29 != nil {
|
|
var err error
|
|
x.Items, err = NewItemsItem(v29, compiler.NewContext("items", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// Properties properties = 30;
|
|
v30 := compiler.MapValueForKey(m, "properties")
|
|
if v30 != nil {
|
|
var err error
|
|
x.Properties, err = NewProperties(v30, compiler.NewContext("properties", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// string description = 31;
|
|
v31 := compiler.MapValueForKey(m, "description")
|
|
if v31 != nil {
|
|
x.Description, ok = v31.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v31, v31)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string format = 32;
|
|
v32 := compiler.MapValueForKey(m, "format")
|
|
if v32 != nil {
|
|
x.Format, ok = v32.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v32, v32)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 33;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewSchemaOrReference(in interface{}, context *compiler.Context) (*SchemaOrReference, error) {
|
|
errors := make([]error, 0)
|
|
x := &SchemaOrReference{}
|
|
matched := false
|
|
// Schema schema = 1;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewSchema(m, compiler.NewContext("schema", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &SchemaOrReference_Schema{Schema: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
// Reference reference = 2;
|
|
{
|
|
m, ok := compiler.UnpackMap(in)
|
|
if ok {
|
|
// errors might be ok here, they mean we just don't have the right subtype
|
|
t, matching_error := NewReference(m, compiler.NewContext("reference", context))
|
|
if matching_error == nil {
|
|
x.Oneof = &SchemaOrReference_Reference{Reference: t}
|
|
matched = true
|
|
} else {
|
|
errors = append(errors, matching_error)
|
|
}
|
|
}
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewSchemas(in interface{}, context *compiler.Context) (*Schemas, error) {
|
|
errors := make([]error, 0)
|
|
x := &Schemas{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
// repeated NamedSchema additional_properties = 1;
|
|
// MAP: Schema
|
|
x.AdditionalProperties = make([]*NamedSchema, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
pair := &NamedSchema{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSchema(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.AdditionalProperties = append(x.AdditionalProperties, pair)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewScopes(in interface{}, context *compiler.Context) (*Scopes, error) {
|
|
errors := make([]error, 0)
|
|
x := &Scopes{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{name}", "^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedAny name = 1;
|
|
// MAP: Any {name}
|
|
x.Name = make([]*NamedAny, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{name}", k) {
|
|
pair := &NamedAny{}
|
|
pair.Name = k
|
|
result := &Any{}
|
|
handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
|
|
if handled {
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
} else {
|
|
bytes, _ := yaml.Marshal(v)
|
|
result.Yaml = string(bytes)
|
|
result.Value = resultFromExt
|
|
pair.Value = result
|
|
}
|
|
} else {
|
|
pair.Value, err = NewAny(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
x.Name = append(x.Name, pair)
|
|
}
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 2;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewSecurityRequirement(in interface{}, context *compiler.Context) (*SecurityRequirement, error) {
|
|
errors := make([]error, 0)
|
|
x := &SecurityRequirement{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{name}"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedAny name = 1;
|
|
// MAP: Any {name}
|
|
x.Name = make([]*NamedAny, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{name}", k) {
|
|
pair := &NamedAny{}
|
|
pair.Name = k
|
|
result := &Any{}
|
|
handled, resultFromExt, err := compiler.HandleExtension(context, v, k)
|
|
if handled {
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
} else {
|
|
bytes, _ := yaml.Marshal(v)
|
|
result.Yaml = string(bytes)
|
|
result.Value = resultFromExt
|
|
pair.Value = result
|
|
}
|
|
} else {
|
|
pair.Value, err = NewAny(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
x.Name = append(x.Name, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecurityScheme, error) {
|
|
errors := make([]error, 0)
|
|
x := &SecurityScheme{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"type"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"bearerFormat", "description", "flow", "in", "name", "openIdConnectUrl", "scheme", "type"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string type = 1;
|
|
v1 := compiler.MapValueForKey(m, "type")
|
|
if v1 != nil {
|
|
x.Type, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string description = 2;
|
|
v2 := compiler.MapValueForKey(m, "description")
|
|
if v2 != nil {
|
|
x.Description, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string name = 3;
|
|
v3 := compiler.MapValueForKey(m, "name")
|
|
if v3 != nil {
|
|
x.Name, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string in = 4;
|
|
v4 := compiler.MapValueForKey(m, "in")
|
|
if v4 != nil {
|
|
x.In, ok = v4.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v4, v4)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string scheme = 5;
|
|
v5 := compiler.MapValueForKey(m, "scheme")
|
|
if v5 != nil {
|
|
x.Scheme, ok = v5.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for scheme: %+v (%T)", v5, v5)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string bearer_format = 6;
|
|
v6 := compiler.MapValueForKey(m, "bearerFormat")
|
|
if v6 != nil {
|
|
x.BearerFormat, ok = v6.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for bearerFormat: %+v (%T)", v6, v6)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// OauthFlows flow = 7;
|
|
v7 := compiler.MapValueForKey(m, "flow")
|
|
if v7 != nil {
|
|
var err error
|
|
x.Flow, err = NewOauthFlows(v7, compiler.NewContext("flow", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// string open_id_connect_url = 8;
|
|
v8 := compiler.MapValueForKey(m, "openIdConnectUrl")
|
|
if v8 != nil {
|
|
x.OpenIdConnectUrl, ok = v8.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for openIdConnectUrl: %+v (%T)", v8, v8)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 9;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewSecuritySchemes(in interface{}, context *compiler.Context) (*SecuritySchemes, error) {
|
|
errors := make([]error, 0)
|
|
x := &SecuritySchemes{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
// repeated NamedSecurityScheme additional_properties = 1;
|
|
// MAP: SecurityScheme
|
|
x.AdditionalProperties = make([]*NamedSecurityScheme, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
pair := &NamedSecurityScheme{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSecurityScheme(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.AdditionalProperties = append(x.AdditionalProperties, pair)
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewServer(in interface{}, context *compiler.Context) (*Server, error) {
|
|
errors := make([]error, 0)
|
|
x := &Server{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"description", "url", "variables"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string url = 1;
|
|
v1 := compiler.MapValueForKey(m, "url")
|
|
if v1 != nil {
|
|
x.Url, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string description = 2;
|
|
v2 := compiler.MapValueForKey(m, "description")
|
|
if v2 != nil {
|
|
x.Description, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// ServerVariables variables = 3;
|
|
v3 := compiler.MapValueForKey(m, "variables")
|
|
if v3 != nil {
|
|
var err error
|
|
x.Variables, err = NewServerVariables(v3, compiler.NewContext("variables", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 4;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariable, error) {
|
|
errors := make([]error, 0)
|
|
x := &ServerVariable{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"default"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"default", "description", "enum"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated Primitive enum = 1;
|
|
v1 := compiler.MapValueForKey(m, "enum")
|
|
if v1 != nil {
|
|
// repeated Primitive
|
|
x.Enum = make([]*Primitive, 0)
|
|
a, ok := v1.([]interface{})
|
|
if ok {
|
|
for _, item := range a {
|
|
y, err := NewPrimitive(item, compiler.NewContext("enum", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Enum = append(x.Enum, y)
|
|
}
|
|
}
|
|
}
|
|
// Primitive default = 2;
|
|
v2 := compiler.MapValueForKey(m, "default")
|
|
if v2 != nil {
|
|
var err error
|
|
x.Default, err = NewPrimitive(v2, compiler.NewContext("default", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// string description = 3;
|
|
v3 := compiler.MapValueForKey(m, "description")
|
|
if v3 != nil {
|
|
x.Description, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 4;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewServerVariables(in interface{}, context *compiler.Context) (*ServerVariables, error) {
|
|
errors := make([]error, 0)
|
|
x := &ServerVariables{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{}
|
|
allowedPatterns := []string{"{name}", "^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// repeated NamedServerVariable name = 1;
|
|
// MAP: ServerVariable {name}
|
|
x.Name = make([]*NamedServerVariable, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("{name}", k) {
|
|
pair := &NamedServerVariable{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewServerVariable(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.Name = append(x.Name, pair)
|
|
}
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 2;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewSpecificationExtension(in interface{}, context *compiler.Context) (*SpecificationExtension, error) {
|
|
errors := make([]error, 0)
|
|
x := &SpecificationExtension{}
|
|
matched := false
|
|
switch in := in.(type) {
|
|
case bool:
|
|
x.Oneof = &SpecificationExtension_Boolean{Boolean: in}
|
|
matched = true
|
|
case string:
|
|
x.Oneof = &SpecificationExtension_String_{String_: in}
|
|
matched = true
|
|
case int64:
|
|
x.Oneof = &SpecificationExtension_Integer{Integer: in}
|
|
matched = true
|
|
case int32:
|
|
x.Oneof = &SpecificationExtension_Integer{Integer: int64(in)}
|
|
matched = true
|
|
case int:
|
|
x.Oneof = &SpecificationExtension_Integer{Integer: int64(in)}
|
|
matched = true
|
|
case float64:
|
|
x.Oneof = &SpecificationExtension_Number{Number: in}
|
|
matched = true
|
|
case float32:
|
|
x.Oneof = &SpecificationExtension_Number{Number: float64(in)}
|
|
matched = true
|
|
}
|
|
if matched {
|
|
// since the oneof matched one of its possibilities, discard any matching errors
|
|
errors = make([]error, 0)
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, error) {
|
|
errors := make([]error, 0)
|
|
x := &StringArray{}
|
|
a, ok := in.([]interface{})
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for StringArray: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
x.Value = make([]string, 0)
|
|
for _, s := range a {
|
|
x.Value = append(x.Value, s.(string))
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewTag(in interface{}, context *compiler.Context) (*Tag, error) {
|
|
errors := make([]error, 0)
|
|
x := &Tag{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
requiredKeys := []string{"name"}
|
|
missingKeys := compiler.MissingKeysInMap(m, requiredKeys)
|
|
if len(missingKeys) > 0 {
|
|
message := fmt.Sprintf("is missing required %s: %+v", compiler.PluralProperties(len(missingKeys)), strings.Join(missingKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
allowedKeys := []string{"description", "externalDocs", "name"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string description = 2;
|
|
v2 := compiler.MapValueForKey(m, "description")
|
|
if v2 != nil {
|
|
x.Description, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// ExternalDocs external_docs = 3;
|
|
v3 := compiler.MapValueForKey(m, "externalDocs")
|
|
if v3 != nil {
|
|
var err error
|
|
x.ExternalDocs, err = NewExternalDocs(v3, compiler.NewContext("externalDocs", context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 4;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func NewXml(in interface{}, context *compiler.Context) (*Xml, error) {
|
|
errors := make([]error, 0)
|
|
x := &Xml{}
|
|
m, ok := compiler.UnpackMap(in)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
} else {
|
|
allowedKeys := []string{"attribute", "name", "namespace", "prefix", "wrapped"}
|
|
allowedPatterns := []string{"^x-"}
|
|
invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
|
|
if len(invalidKeys) > 0 {
|
|
message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
// string name = 1;
|
|
v1 := compiler.MapValueForKey(m, "name")
|
|
if v1 != nil {
|
|
x.Name, ok = v1.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string namespace = 2;
|
|
v2 := compiler.MapValueForKey(m, "namespace")
|
|
if v2 != nil {
|
|
x.Namespace, ok = v2.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for namespace: %+v (%T)", v2, v2)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// string prefix = 3;
|
|
v3 := compiler.MapValueForKey(m, "prefix")
|
|
if v3 != nil {
|
|
x.Prefix, ok = v3.(string)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for prefix: %+v (%T)", v3, v3)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool attribute = 4;
|
|
v4 := compiler.MapValueForKey(m, "attribute")
|
|
if v4 != nil {
|
|
x.Attribute, ok = v4.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for attribute: %+v (%T)", v4, v4)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// bool wrapped = 5;
|
|
v5 := compiler.MapValueForKey(m, "wrapped")
|
|
if v5 != nil {
|
|
x.Wrapped, ok = v5.(bool)
|
|
if !ok {
|
|
message := fmt.Sprintf("has unexpected value for wrapped: %+v (%T)", v5, v5)
|
|
errors = append(errors, compiler.NewError(context, message))
|
|
}
|
|
}
|
|
// repeated NamedSpecificationExtension specification_extension = 6;
|
|
// MAP: SpecificationExtension ^x-
|
|
x.SpecificationExtension = make([]*NamedSpecificationExtension, 0)
|
|
for _, item := range m {
|
|
k, ok := item.Key.(string)
|
|
if ok {
|
|
v := item.Value
|
|
if compiler.PatternMatches("^x-", k) {
|
|
pair := &NamedSpecificationExtension{}
|
|
pair.Name = k
|
|
var err error
|
|
pair.Value, err = NewSpecificationExtension(v, compiler.NewContext(k, context))
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
x.SpecificationExtension = append(x.SpecificationExtension, pair)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return x, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Any) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *AnyOrExpression) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*AnyOrExpression_Any)
|
|
if ok {
|
|
_, err := p.Any.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*AnyOrExpression_Expression)
|
|
if ok {
|
|
_, err := p.Expression.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Callback) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Expression {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *CallbackOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*CallbackOrReference_Callback)
|
|
if ok {
|
|
_, err := p.Callback.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*CallbackOrReference_Reference)
|
|
if ok {
|
|
_, err := p.Reference.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Callbacks) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Name {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Components) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Schemas != nil {
|
|
_, err := m.Schemas.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Responses != nil {
|
|
_, err := m.Responses.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Parameters != nil {
|
|
_, err := m.Parameters.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Examples != nil {
|
|
_, err := m.Examples.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.RequestBodies != nil {
|
|
_, err := m.RequestBodies.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Headers != nil {
|
|
_, err := m.Headers.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.SecuritySchemes != nil {
|
|
_, err := m.SecuritySchemes.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Links != nil {
|
|
_, err := m.Links.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Callbacks != nil {
|
|
_, err := m.Callbacks.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Contact) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Content) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.MediaType {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Document) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Info != nil {
|
|
_, err := m.Info.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Servers {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.Paths != nil {
|
|
_, err := m.Paths.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Components != nil {
|
|
_, err := m.Components.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Security {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.Tags {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.ExternalDocs != nil {
|
|
_, err := m.ExternalDocs.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Encoding) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Property {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *EncodingProperty) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Headers != nil {
|
|
_, err := m.Headers.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Example) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *ExampleOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*ExampleOrReference_Example)
|
|
if ok {
|
|
_, err := p.Example.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*ExampleOrReference_Reference)
|
|
if ok {
|
|
_, err := p.Reference.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Examples) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Expression) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.AdditionalProperties {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Header) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Schema != nil {
|
|
_, err := m.Schema.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Examples {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.Example != nil {
|
|
_, err := m.Example.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Content != nil {
|
|
_, err := m.Content.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *HeaderOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*HeaderOrReference_Header)
|
|
if ok {
|
|
_, err := p.Header.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*HeaderOrReference_Reference)
|
|
if ok {
|
|
_, err := p.Reference.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Headers) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Name {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Info) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Contact != nil {
|
|
_, err := m.Contact.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.License != nil {
|
|
_, err := m.License.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.SchemaOrReference {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *License) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Link) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Parameters != nil {
|
|
_, err := m.Parameters.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Headers != nil {
|
|
_, err := m.Headers.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *LinkOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*LinkOrReference_Link)
|
|
if ok {
|
|
_, err := p.Link.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*LinkOrReference_Reference)
|
|
if ok {
|
|
_, err := p.Reference.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *LinkParameters) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Name {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Links) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Name {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *MediaType) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Schema != nil {
|
|
_, err := m.Schema.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Examples {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.Example != nil {
|
|
_, err := m.Example.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Encoding != nil {
|
|
_, err := m.Encoding.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedAny) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedAnyOrExpression) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedCallbackOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedEncodingProperty) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedHeaderOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedLinkOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedMediaType) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedRequestBody) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedResponseOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedSecurityScheme) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedServerVariable) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *NamedSpecificationExtension) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Value != nil {
|
|
_, err := m.Value.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *OauthFlow) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Scopes != nil {
|
|
_, err := m.Scopes.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *OauthFlows) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Implicit != nil {
|
|
_, err := m.Implicit.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Password != nil {
|
|
_, err := m.Password.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.ClientCredentials != nil {
|
|
_, err := m.ClientCredentials.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.AuthorizationCode != nil {
|
|
_, err := m.AuthorizationCode.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Object) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.AdditionalProperties {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Operation) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.ExternalDocs != nil {
|
|
_, err := m.ExternalDocs.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Parameters {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.RequestBody != nil {
|
|
_, err := m.RequestBody.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Responses != nil {
|
|
_, err := m.Responses.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Callbacks != nil {
|
|
_, err := m.Callbacks.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Security {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.Servers != nil {
|
|
_, err := m.Servers.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Parameter) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Schema != nil {
|
|
_, err := m.Schema.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Examples {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.Example != nil {
|
|
_, err := m.Example.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Content != nil {
|
|
_, err := m.Content.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *ParameterOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*ParameterOrReference_Parameter)
|
|
if ok {
|
|
_, err := p.Parameter.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*ParameterOrReference_Reference)
|
|
if ok {
|
|
_, err := p.Reference.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Parameters) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.AdditionalProperties {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *PathItem) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.XRef != "" {
|
|
info, err := compiler.ReadInfoForRef(root, m.XRef)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if info != nil {
|
|
replacement, err := NewPathItem(info, nil)
|
|
if err == nil {
|
|
*m = *replacement
|
|
return m.ResolveReferences(root)
|
|
}
|
|
}
|
|
return info, nil
|
|
}
|
|
if m.Get != nil {
|
|
_, err := m.Get.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Put != nil {
|
|
_, err := m.Put.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Post != nil {
|
|
_, err := m.Post.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Delete != nil {
|
|
_, err := m.Delete.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Options != nil {
|
|
_, err := m.Options.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Head != nil {
|
|
_, err := m.Head.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Patch != nil {
|
|
_, err := m.Patch.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Trace != nil {
|
|
_, err := m.Trace.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Servers != nil {
|
|
_, err := m.Servers.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Parameters {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Paths) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Path {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Primitive) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Properties) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.AdditionalProperties {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Reference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.XRef != "" {
|
|
info, err := compiler.ReadInfoForRef(root, m.XRef)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return info, nil
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *RequestBodies) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.AdditionalProperties {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *RequestBody) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Content != nil {
|
|
_, err := m.Content.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *RequestBodyOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*RequestBodyOrReference_RequestBody)
|
|
if ok {
|
|
_, err := p.RequestBody.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*RequestBodyOrReference_Reference)
|
|
if ok {
|
|
_, err := p.Reference.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Response) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Headers != nil {
|
|
_, err := m.Headers.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Content != nil {
|
|
_, err := m.Content.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Links != nil {
|
|
_, err := m.Links.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *ResponseOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*ResponseOrReference_Response)
|
|
if ok {
|
|
_, err := p.Response.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*ResponseOrReference_Reference)
|
|
if ok {
|
|
_, err := p.Reference.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Responses) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Default != nil {
|
|
_, err := m.Default.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.ResponseCode {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Schema) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Xml != nil {
|
|
_, err := m.Xml.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.ExternalDocs != nil {
|
|
_, err := m.ExternalDocs.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.Enum {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.AllOf {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.OneOf {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.AnyOf {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.Not != nil {
|
|
_, err := m.Not.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Items != nil {
|
|
_, err := m.Items.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
if m.Properties != nil {
|
|
_, err := m.Properties.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *SchemaOrReference) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
{
|
|
p, ok := m.Oneof.(*SchemaOrReference_Schema)
|
|
if ok {
|
|
_, err := p.Schema.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
{
|
|
p, ok := m.Oneof.(*SchemaOrReference_Reference)
|
|
if ok {
|
|
_, err := p.Reference.ResolveReferences(root)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Schemas) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.AdditionalProperties {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Scopes) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Name {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Name {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *SecurityScheme) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Flow != nil {
|
|
_, err := m.Flow.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *SecuritySchemes) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.AdditionalProperties {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Server) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.Variables != nil {
|
|
_, err := m.Variables.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *ServerVariable) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Enum {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
if m.Default != nil {
|
|
_, err := m.Default.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *ServerVariables) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.Name {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *SpecificationExtension) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *StringArray) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Tag) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
if m.ExternalDocs != nil {
|
|
_, err := m.ExternalDocs.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|
|
|
|
func (m *Xml) ResolveReferences(root string) (interface{}, error) {
|
|
errors := make([]error, 0)
|
|
for _, item := range m.SpecificationExtension {
|
|
if item != nil {
|
|
_, err := item.ResolveReferences(root)
|
|
if err != nil {
|
|
errors = append(errors, err)
|
|
}
|
|
}
|
|
}
|
|
return nil, compiler.NewErrorGroupOrNil(errors)
|
|
}
|