diff --git a/compiler/context.go b/compiler/context.go index 1250a6c5..1bfe9612 100644 --- a/compiler/context.go +++ b/compiler/context.go @@ -14,30 +14,36 @@ package compiler +import ( + yaml "gopkg.in/yaml.v3" +) + // Context contains state of the compiler as it traverses a document. type Context struct { Parent *Context Name string + Node *yaml.Node ExtensionHandlers *[]ExtensionHandler } // NewContextWithExtensions returns a new object representing the compiler state -func NewContextWithExtensions(name string, parent *Context, extensionHandlers *[]ExtensionHandler) *Context { - return &Context{Name: name, Parent: parent, ExtensionHandlers: extensionHandlers} +func NewContextWithExtensions(name string, node *yaml.Node, parent *Context, extensionHandlers *[]ExtensionHandler) *Context { + return &Context{Name: name, Node: node, Parent: parent, ExtensionHandlers: extensionHandlers} } // NewContext returns a new object representing the compiler state -func NewContext(name string, parent *Context) *Context { +func NewContext(name string, node *yaml.Node, parent *Context) *Context { if parent != nil { - return &Context{Name: name, Parent: parent, ExtensionHandlers: parent.ExtensionHandlers} + return &Context{Name: name, Node: node, Parent: parent, ExtensionHandlers: parent.ExtensionHandlers} } return &Context{Name: name, Parent: parent, ExtensionHandlers: nil} } // Description returns a text description of the compiler state func (context *Context) Description() string { + name := context.Name if context.Parent != nil { - return context.Parent.Description() + "." + context.Name + name = context.Parent.Description() + "." + name } - return context.Name + return name } diff --git a/compiler/error.go b/compiler/error.go index 7db23997..6f40515d 100644 --- a/compiler/error.go +++ b/compiler/error.go @@ -14,6 +14,8 @@ package compiler +import "fmt" + // Error represents compiler errors and their location in the document. type Error struct { Context *Context @@ -25,12 +27,19 @@ func NewError(context *Context, message string) *Error { return &Error{Context: context, Message: message} } +func (err *Error) locationDescription() string { + if err.Context.Node != nil { + return fmt.Sprintf("[%d,%d] %s", err.Context.Node.Line, err.Context.Node.Column, err.Context.Description()) + } + return err.Context.Description() +} + // Error returns the string value of an Error. func (err *Error) Error() string { if err.Context == nil { - return "ERROR " + err.Message + return err.Message } - return "ERROR " + err.Context.Description() + " " + err.Message + return err.locationDescription() + " " + err.Message } // ErrorGroup is a container for groups of Error values. diff --git a/discovery/discovery.go b/discovery/discovery.go index 6625a0aa..ad62277c 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -89,7 +89,7 @@ func NewAuth(in *yaml.Node, context *compiler.Context) (*Auth, error) { v1 := compiler.MapValueForKey(m, "oauth2") if v1 != nil { var err error - x.Oauth2, err = NewOauth2(v1, compiler.NewContext("oauth2", context)) + x.Oauth2, err = NewOauth2(v1, compiler.NewContext("oauth2", v1, context)) if err != nil { errors = append(errors, err) } @@ -196,7 +196,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v9 := compiler.MapValueForKey(m, "icons") if v9 != nil { var err error - x.Icons, err = NewIcons(v9, compiler.NewContext("icons", context)) + x.Icons, err = NewIcons(v9, compiler.NewContext("icons", v9, context)) if err != nil { errors = append(errors, err) } @@ -279,7 +279,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v18 := compiler.MapValueForKey(m, "parameters") if v18 != nil { var err error - x.Parameters, err = NewParameters(v18, compiler.NewContext("parameters", context)) + x.Parameters, err = NewParameters(v18, compiler.NewContext("parameters", v18, context)) if err != nil { errors = append(errors, err) } @@ -288,7 +288,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v19 := compiler.MapValueForKey(m, "auth") if v19 != nil { var err error - x.Auth, err = NewAuth(v19, compiler.NewContext("auth", context)) + x.Auth, err = NewAuth(v19, compiler.NewContext("auth", v19, context)) if err != nil { errors = append(errors, err) } @@ -308,7 +308,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v21 := compiler.MapValueForKey(m, "schemas") if v21 != nil { var err error - x.Schemas, err = NewSchemas(v21, compiler.NewContext("schemas", context)) + x.Schemas, err = NewSchemas(v21, compiler.NewContext("schemas", v21, context)) if err != nil { errors = append(errors, err) } @@ -317,7 +317,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v22 := compiler.MapValueForKey(m, "methods") if v22 != nil { var err error - x.Methods, err = NewMethods(v22, compiler.NewContext("methods", context)) + x.Methods, err = NewMethods(v22, compiler.NewContext("methods", v22, context)) if err != nil { errors = append(errors, err) } @@ -326,7 +326,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v23 := compiler.MapValueForKey(m, "resources") if v23 != nil { var err error - x.Resources, err = NewResources(v23, compiler.NewContext("resources", context)) + x.Resources, err = NewResources(v23, compiler.NewContext("resources", v23, context)) if err != nil { errors = append(errors, err) } @@ -491,7 +491,7 @@ func NewMediaUpload(in *yaml.Node, context *compiler.Context) (*MediaUpload, err v3 := compiler.MapValueForKey(m, "protocols") if v3 != nil { var err error - x.Protocols, err = NewProtocols(v3, compiler.NewContext("protocols", context)) + x.Protocols, err = NewProtocols(v3, compiler.NewContext("protocols", v3, context)) if err != nil { errors = append(errors, err) } @@ -565,7 +565,7 @@ func NewMethod(in *yaml.Node, context *compiler.Context) (*Method, error) { v5 := compiler.MapValueForKey(m, "parameters") if v5 != nil { var err error - x.Parameters, err = NewParameters(v5, compiler.NewContext("parameters", context)) + x.Parameters, err = NewParameters(v5, compiler.NewContext("parameters", v5, context)) if err != nil { errors = append(errors, err) } @@ -585,7 +585,7 @@ func NewMethod(in *yaml.Node, context *compiler.Context) (*Method, error) { v7 := compiler.MapValueForKey(m, "request") if v7 != nil { var err error - x.Request, err = NewRequest(v7, compiler.NewContext("request", context)) + x.Request, err = NewRequest(v7, compiler.NewContext("request", v7, context)) if err != nil { errors = append(errors, err) } @@ -594,7 +594,7 @@ func NewMethod(in *yaml.Node, context *compiler.Context) (*Method, error) { v8 := compiler.MapValueForKey(m, "response") if v8 != nil { var err error - x.Response, err = NewResponse(v8, compiler.NewContext("response", context)) + x.Response, err = NewResponse(v8, compiler.NewContext("response", v8, context)) if err != nil { errors = append(errors, err) } @@ -641,7 +641,7 @@ func NewMethod(in *yaml.Node, context *compiler.Context) (*Method, error) { v13 := compiler.MapValueForKey(m, "mediaUpload") if v13 != nil { var err error - x.MediaUpload, err = NewMediaUpload(v13, compiler.NewContext("mediaUpload", context)) + x.MediaUpload, err = NewMediaUpload(v13, compiler.NewContext("mediaUpload", v13, context)) if err != nil { errors = append(errors, err) } @@ -696,7 +696,7 @@ func NewMethods(in *yaml.Node, context *compiler.Context) (*Methods, error) { pair := &NamedMethod{} pair.Name = k var err error - pair.Value, err = NewMethod(v, compiler.NewContext(k, context)) + pair.Value, err = NewMethod(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -736,7 +736,7 @@ func NewNamedMethod(in *yaml.Node, context *compiler.Context) (*NamedMethod, err v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewMethod(v2, compiler.NewContext("value", context)) + x.Value, err = NewMethod(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -774,7 +774,7 @@ func NewNamedParameter(in *yaml.Node, context *compiler.Context) (*NamedParamete v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewParameter(v2, compiler.NewContext("value", context)) + x.Value, err = NewParameter(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -812,7 +812,7 @@ func NewNamedResource(in *yaml.Node, context *compiler.Context) (*NamedResource, v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewResource(v2, compiler.NewContext("value", context)) + x.Value, err = NewResource(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -850,7 +850,7 @@ func NewNamedSchema(in *yaml.Node, context *compiler.Context) (*NamedSchema, err v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewSchema(v2, compiler.NewContext("value", context)) + x.Value, err = NewSchema(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -888,7 +888,7 @@ func NewNamedScope(in *yaml.Node, context *compiler.Context) (*NamedScope, error v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewScope(v2, compiler.NewContext("value", context)) + x.Value, err = NewScope(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -917,7 +917,7 @@ func NewOauth2(in *yaml.Node, context *compiler.Context) (*Oauth2, error) { v1 := compiler.MapValueForKey(m, "scopes") if v1 != nil { var err error - x.Scopes, err = NewScopes(v1, compiler.NewContext("scopes", context)) + x.Scopes, err = NewScopes(v1, compiler.NewContext("scopes", v1, context)) if err != nil { errors = append(errors, err) } @@ -1076,7 +1076,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) v15 := compiler.MapValueForKey(m, "properties") if v15 != nil { var err error - x.Properties, err = NewSchemas(v15, compiler.NewContext("properties", context)) + x.Properties, err = NewSchemas(v15, compiler.NewContext("properties", v15, context)) if err != nil { errors = append(errors, err) } @@ -1085,7 +1085,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) v16 := compiler.MapValueForKey(m, "additionalProperties") if v16 != nil { var err error - x.AdditionalProperties, err = NewSchema(v16, compiler.NewContext("additionalProperties", context)) + x.AdditionalProperties, err = NewSchema(v16, compiler.NewContext("additionalProperties", v16, context)) if err != nil { errors = append(errors, err) } @@ -1094,7 +1094,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) v17 := compiler.MapValueForKey(m, "items") if v17 != nil { var err error - x.Items, err = NewSchema(v17, compiler.NewContext("items", context)) + x.Items, err = NewSchema(v17, compiler.NewContext("items", v17, context)) if err != nil { errors = append(errors, err) } @@ -1103,7 +1103,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) v18 := compiler.MapValueForKey(m, "annotations") if v18 != nil { var err error - x.Annotations, err = NewAnnotations(v18, compiler.NewContext("annotations", context)) + x.Annotations, err = NewAnnotations(v18, compiler.NewContext("annotations", v18, context)) if err != nil { errors = append(errors, err) } @@ -1131,7 +1131,7 @@ func NewParameters(in *yaml.Node, context *compiler.Context) (*Parameters, error pair := &NamedParameter{} pair.Name = k var err error - pair.Value, err = NewParameter(v, compiler.NewContext(k, context)) + pair.Value, err = NewParameter(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1162,7 +1162,7 @@ func NewProtocols(in *yaml.Node, context *compiler.Context) (*Protocols, error) v1 := compiler.MapValueForKey(m, "simple") if v1 != nil { var err error - x.Simple, err = NewSimple(v1, compiler.NewContext("simple", context)) + x.Simple, err = NewSimple(v1, compiler.NewContext("simple", v1, context)) if err != nil { errors = append(errors, err) } @@ -1171,7 +1171,7 @@ func NewProtocols(in *yaml.Node, context *compiler.Context) (*Protocols, error) v2 := compiler.MapValueForKey(m, "resumable") if v2 != nil { var err error - x.Resumable, err = NewResumable(v2, compiler.NewContext("resumable", context)) + x.Resumable, err = NewResumable(v2, compiler.NewContext("resumable", v2, context)) if err != nil { errors = append(errors, err) } @@ -1238,7 +1238,7 @@ func NewResource(in *yaml.Node, context *compiler.Context) (*Resource, error) { v1 := compiler.MapValueForKey(m, "methods") if v1 != nil { var err error - x.Methods, err = NewMethods(v1, compiler.NewContext("methods", context)) + x.Methods, err = NewMethods(v1, compiler.NewContext("methods", v1, context)) if err != nil { errors = append(errors, err) } @@ -1247,7 +1247,7 @@ func NewResource(in *yaml.Node, context *compiler.Context) (*Resource, error) { v2 := compiler.MapValueForKey(m, "resources") if v2 != nil { var err error - x.Resources, err = NewResources(v2, compiler.NewContext("resources", context)) + x.Resources, err = NewResources(v2, compiler.NewContext("resources", v2, context)) if err != nil { errors = append(errors, err) } @@ -1275,7 +1275,7 @@ func NewResources(in *yaml.Node, context *compiler.Context) (*Resources, error) pair := &NamedResource{} pair.Name = k var err error - pair.Value, err = NewResource(v, compiler.NewContext(k, context)) + pair.Value, err = NewResource(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1494,7 +1494,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v14 := compiler.MapValueForKey(m, "properties") if v14 != nil { var err error - x.Properties, err = NewSchemas(v14, compiler.NewContext("properties", context)) + x.Properties, err = NewSchemas(v14, compiler.NewContext("properties", v14, context)) if err != nil { errors = append(errors, err) } @@ -1503,7 +1503,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v15 := compiler.MapValueForKey(m, "additionalProperties") if v15 != nil { var err error - x.AdditionalProperties, err = NewSchema(v15, compiler.NewContext("additionalProperties", context)) + x.AdditionalProperties, err = NewSchema(v15, compiler.NewContext("additionalProperties", v15, context)) if err != nil { errors = append(errors, err) } @@ -1512,7 +1512,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v16 := compiler.MapValueForKey(m, "items") if v16 != nil { var err error - x.Items, err = NewSchema(v16, compiler.NewContext("items", context)) + x.Items, err = NewSchema(v16, compiler.NewContext("items", v16, context)) if err != nil { errors = append(errors, err) } @@ -1530,7 +1530,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v18 := compiler.MapValueForKey(m, "annotations") if v18 != nil { var err error - x.Annotations, err = NewAnnotations(v18, compiler.NewContext("annotations", context)) + x.Annotations, err = NewAnnotations(v18, compiler.NewContext("annotations", v18, context)) if err != nil { errors = append(errors, err) } @@ -1567,7 +1567,7 @@ func NewSchemas(in *yaml.Node, context *compiler.Context) (*Schemas, error) { pair := &NamedSchema{} pair.Name = k var err error - pair.Value, err = NewSchema(v, compiler.NewContext(k, context)) + pair.Value, err = NewSchema(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1626,7 +1626,7 @@ func NewScopes(in *yaml.Node, context *compiler.Context) (*Scopes, error) { pair := &NamedScope{} pair.Name = k var err error - pair.Value, err = NewScope(v, compiler.NewContext(k, context)) + pair.Value, err = NewScope(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } diff --git a/discovery/document.go b/discovery/document.go index a103a7be..ab6a5c86 100644 --- a/discovery/document.go +++ b/discovery/document.go @@ -29,5 +29,6 @@ func ParseDocument(b []byte) (*Document, error) { if err != nil { return nil, err } - return NewDocument(info.Content[0], compiler.NewContext("$root", nil)) + root := info.Content[0] + return NewDocument(root, compiler.NewContext("$root", root, nil)) } diff --git a/generate-gnostic/generate-compiler.go b/generate-gnostic/generate-compiler.go index ff2514f9..54460519 100644 --- a/generate-gnostic/generate-compiler.go +++ b/generate-gnostic/generate-compiler.go @@ -173,7 +173,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print("} else {") code.Print(" x.Schema = make([]*Schema, 0)") - code.Print(" y, err := NewSchema(m, compiler.NewContext(\"\", context))") + code.Print(" y, err := NewSchema(m, compiler.NewContext(\"\", m, context))") code.Print(" if err != nil {") code.Print(" return nil, err") code.Print(" }") @@ -187,7 +187,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print("} else {") code.Print(" x.SchemaOrReference = make([]*SchemaOrReference, 0)") - code.Print(" y, err := NewSchemaOrReference(m, compiler.NewContext(\"\", context))") + code.Print(" y, err := NewSchemaOrReference(m, compiler.NewContext(\"\", m, context))") code.Print(" if err != nil {") code.Print(" return nil, err") code.Print(" }") @@ -372,7 +372,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" a, ok := compiler.SequenceNodeForNode(v%d)", fieldNumber) code.Print(" if ok {") code.Print(" for _, item := range a.Content {") - code.Print(" y, err := New%s(item, compiler.NewContext(\"%s\", context))", typeModel.Name, propertyName) + code.Print(" y, err := New%s(item, compiler.NewContext(\"%s\", item, context))", typeModel.Name, propertyName) code.Print(" if err != nil {") code.Print(" errors = append(errors, err)") code.Print(" }") @@ -388,7 +388,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" if ok {") } code.Print(" // errors might be ok here, they mean we just don't have the right subtype") - code.Print(" t, matchingError := New%s(m, compiler.NewContext(\"%s\", context))", typeModel.Name, propertyName) + code.Print(" t, matchingError := New%s(m, compiler.NewContext(\"%s\", m, context))", typeModel.Name, propertyName) code.Print(" if matchingError == nil {") code.Print(" x.Oneof = &%s_%s{%s: t}", parentTypeName, typeModel.Name, typeModel.Name) code.Print(" matched = true") @@ -403,8 +403,8 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) code.Print("if (v%d != nil) {", fieldNumber) code.Print(" var err error") - code.Print(" x.%s, err = New%s(v%d, compiler.NewContext(\"%s\", context))", - fieldName, typeModel.Name, fieldNumber, propertyName) + code.Print(" x.%s, err = New%s(v%d, compiler.NewContext(\"%s\", v%d, context))", + fieldName, typeModel.Name, fieldNumber, propertyName, fieldNumber) code.Print(" if err != nil {") code.Print(" errors = append(errors, err)") code.Print(" }") @@ -550,14 +550,14 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" pair.Value = result") code.Print(" }") code.Print("} else {") - code.Print(" pair.Value, err = NewAny(v, compiler.NewContext(k, context))") + code.Print(" pair.Value, err = NewAny(v, compiler.NewContext(k, v, context))") code.Print(" if err != nil {") code.Print(" errors = append(errors, err)") code.Print(" }") code.Print("}") } else { code.Print("var err error") - code.Print("pair.Value, err = New%s(v, compiler.NewContext(k, context))", mapTypeName) + code.Print("pair.Value, err = New%s(v, compiler.NewContext(k, v, context))", mapTypeName) code.Print("if err != nil {") code.Print(" errors = append(errors, err)") code.Print("}") @@ -580,12 +580,12 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print("if matched {") code.Print(" // since the oneof matched one of its possibilities, discard any matching errors") code.Print(" errors = make([]error, 0)") - generateMatchErrors := false // TODO: enable this and update tests for new error messages + generateMatchErrors := true // TODO: enable this and update tests for new error messages if generateMatchErrors { code.Print("} else {") - code.Print(" message := fmt.Sprintf(\"failed to match %s with %%+v\", compiler.Description(in))", typeName) + code.Print(" message := fmt.Sprintf(\"contains an invalid %s\")", typeName) code.Print(" err := compiler.NewError(context, message)") - code.Print(" errors = append(errors, err)") + code.Print(" errors = []error{err}") } code.Print("}") } diff --git a/generate-gnostic/generate-extension.go b/generate-gnostic/generate-extension.go index feddaae6..c5c5a6c5 100644 --- a/generate-gnostic/generate-extension.go +++ b/generate-gnostic/generate-extension.go @@ -72,7 +72,7 @@ const caseStringForObjectTypes = "\n" + " return true, nil, err\n" + "}\n" + "info = *info.Content[0]\n" + - "newObject, err := %s.New%s(&info, compiler.NewContext(\"$root\", nil))\n" + + "newObject, err := %s.New%s(&info, compiler.NewContext(\"$root\", &info, nil))\n" + "return true, newObject, err" const caseStringForWrapperTypes = "\n" + diff --git a/lib/gnostic.go b/lib/gnostic.go index 3cbffd57..c95bc3b1 100644 --- a/lib/gnostic.go +++ b/lib/gnostic.go @@ -442,19 +442,22 @@ func (g *Gnostic) readOpenAPIText(bytes []byte) (message proto.Message, err erro } // Compile to the proto model. if g.sourceFormat == SourceFormatOpenAPI2 { - document, err := openapi_v2.NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, &g.extensionHandlers)) + root := info.Content[0] + document, err := openapi_v2.NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, &g.extensionHandlers)) if err != nil { return nil, err } message = document } else if g.sourceFormat == SourceFormatOpenAPI3 { - document, err := openapi_v3.NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, &g.extensionHandlers)) + root := info.Content[0] + document, err := openapi_v3.NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, &g.extensionHandlers)) if err != nil { return nil, err } message = document } else { - document, err := discovery_v1.NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, &g.extensionHandlers)) + root := info.Content[0] + document, err := discovery_v1.NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, &g.extensionHandlers)) if err != nil { return nil, err } diff --git a/metrics/vocabulary.pb.go b/metrics/vocabulary.pb.go index 49f0c2d8..c143a406 100644 --- a/metrics/vocabulary.pb.go +++ b/metrics/vocabulary.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.3 +// protoc v3.12.0 // source: metrics/vocabulary.proto package gnostic_metrics_v1 diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index 017ef4ed..eb93b65e 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -39,7 +39,7 @@ func NewAdditionalPropertiesItem(in *yaml.Node, context *compiler.Context) (*Add m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewSchema(m, compiler.NewContext("schema", context)) + t, matchingError := NewSchema(m, compiler.NewContext("schema", m, context)) if matchingError == nil { x.Oneof = &AdditionalPropertiesItem_Schema{Schema: t} matched = true @@ -57,6 +57,10 @@ func NewAdditionalPropertiesItem(in *yaml.Node, context *compiler.Context) (*Add if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid AdditionalPropertiesItem") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -162,7 +166,7 @@ func NewApiKeySecurity(in *yaml.Node, context *compiler.Context) (*ApiKeySecurit pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -243,7 +247,7 @@ func NewBasicAuthenticationSecurity(in *yaml.Node, context *compiler.Context) (* pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -324,7 +328,7 @@ func NewBodyParameter(in *yaml.Node, context *compiler.Context) (*BodyParameter, v5 := compiler.MapValueForKey(m, "schema") if v5 != nil { var err error - x.Schema, err = NewSchema(v5, compiler.NewContext("schema", context)) + x.Schema, err = NewSchema(v5, compiler.NewContext("schema", v5, context)) if err != nil { errors = append(errors, err) } @@ -351,7 +355,7 @@ func NewBodyParameter(in *yaml.Node, context *compiler.Context) (*BodyParameter, pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -429,7 +433,7 @@ func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -472,7 +476,7 @@ func NewDefault(in *yaml.Node, context *compiler.Context) (*Default, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -503,7 +507,7 @@ func NewDefinitions(in *yaml.Node, context *compiler.Context) (*Definitions, err pair := &NamedSchema{} pair.Name = k var err error - pair.Value, err = NewSchema(v, compiler.NewContext(k, context)) + pair.Value, err = NewSchema(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -555,7 +559,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v2 := compiler.MapValueForKey(m, "info") if v2 != nil { var err error - x.Info, err = NewInfo(v2, compiler.NewContext("info", context)) + x.Info, err = NewInfo(v2, compiler.NewContext("info", v2, context)) if err != nil { errors = append(errors, err) } @@ -621,7 +625,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v8 := compiler.MapValueForKey(m, "paths") if v8 != nil { var err error - x.Paths, err = NewPaths(v8, compiler.NewContext("paths", context)) + x.Paths, err = NewPaths(v8, compiler.NewContext("paths", v8, context)) if err != nil { errors = append(errors, err) } @@ -630,7 +634,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v9 := compiler.MapValueForKey(m, "definitions") if v9 != nil { var err error - x.Definitions, err = NewDefinitions(v9, compiler.NewContext("definitions", context)) + x.Definitions, err = NewDefinitions(v9, compiler.NewContext("definitions", v9, context)) if err != nil { errors = append(errors, err) } @@ -639,7 +643,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v10 := compiler.MapValueForKey(m, "parameters") if v10 != nil { var err error - x.Parameters, err = NewParameterDefinitions(v10, compiler.NewContext("parameters", context)) + x.Parameters, err = NewParameterDefinitions(v10, compiler.NewContext("parameters", v10, context)) if err != nil { errors = append(errors, err) } @@ -648,7 +652,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v11 := compiler.MapValueForKey(m, "responses") if v11 != nil { var err error - x.Responses, err = NewResponseDefinitions(v11, compiler.NewContext("responses", context)) + x.Responses, err = NewResponseDefinitions(v11, compiler.NewContext("responses", v11, context)) if err != nil { errors = append(errors, err) } @@ -661,7 +665,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { a, ok := compiler.SequenceNodeForNode(v12) if ok { for _, item := range a.Content { - y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) + y, err := NewSecurityRequirement(item, compiler.NewContext("security", item, context)) if err != nil { errors = append(errors, err) } @@ -673,7 +677,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v13 := compiler.MapValueForKey(m, "securityDefinitions") if v13 != nil { var err error - x.SecurityDefinitions, err = NewSecurityDefinitions(v13, compiler.NewContext("securityDefinitions", context)) + x.SecurityDefinitions, err = NewSecurityDefinitions(v13, compiler.NewContext("securityDefinitions", v13, context)) if err != nil { errors = append(errors, err) } @@ -686,7 +690,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { a, ok := compiler.SequenceNodeForNode(v14) if ok { for _, item := range a.Content { - y, err := NewTag(item, compiler.NewContext("tags", context)) + y, err := NewTag(item, compiler.NewContext("tags", item, context)) if err != nil { errors = append(errors, err) } @@ -698,7 +702,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v15 := compiler.MapValueForKey(m, "externalDocs") if v15 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v15, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v15, compiler.NewContext("externalDocs", v15, context)) if err != nil { errors = append(errors, err) } @@ -725,7 +729,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -768,7 +772,7 @@ func NewExamples(in *yaml.Node, context *compiler.Context) (*Examples, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -842,7 +846,7 @@ func NewExternalDocs(in *yaml.Node, context *compiler.Context) (*ExternalDocs, e pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -908,7 +912,7 @@ func NewFileSchema(in *yaml.Node, context *compiler.Context) (*FileSchema, error v4 := compiler.MapValueForKey(m, "default") if v4 != nil { var err error - x.Default, err = NewAny(v4, compiler.NewContext("default", context)) + x.Default, err = NewAny(v4, compiler.NewContext("default", v4, context)) if err != nil { errors = append(errors, err) } @@ -952,7 +956,7 @@ func NewFileSchema(in *yaml.Node, context *compiler.Context) (*FileSchema, error v8 := compiler.MapValueForKey(m, "externalDocs") if v8 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v8, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v8, compiler.NewContext("externalDocs", v8, context)) if err != nil { errors = append(errors, err) } @@ -961,7 +965,7 @@ func NewFileSchema(in *yaml.Node, context *compiler.Context) (*FileSchema, error v9 := compiler.MapValueForKey(m, "example") if v9 != nil { var err error - x.Example, err = NewAny(v9, compiler.NewContext("example", context)) + x.Example, err = NewAny(v9, compiler.NewContext("example", v9, context)) if err != nil { errors = append(errors, err) } @@ -988,7 +992,7 @@ func NewFileSchema(in *yaml.Node, context *compiler.Context) (*FileSchema, error pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1096,7 +1100,7 @@ func NewFormDataParameterSubSchema(in *yaml.Node, context *compiler.Context) (*F v8 := compiler.MapValueForKey(m, "items") if v8 != nil { var err error - x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", context)) + x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", v8, context)) if err != nil { errors = append(errors, err) } @@ -1120,7 +1124,7 @@ func NewFormDataParameterSubSchema(in *yaml.Node, context *compiler.Context) (*F v10 := compiler.MapValueForKey(m, "default") if v10 != nil { var err error - x.Default, err = NewAny(v10, compiler.NewContext("default", context)) + x.Default, err = NewAny(v10, compiler.NewContext("default", v10, context)) if err != nil { errors = append(errors, err) } @@ -1235,7 +1239,7 @@ func NewFormDataParameterSubSchema(in *yaml.Node, context *compiler.Context) (*F a, ok := compiler.SequenceNodeForNode(v21) if ok { for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", context)) + y, err := NewAny(item, compiler.NewContext("enum", item, context)) if err != nil { errors = append(errors, err) } @@ -1276,7 +1280,7 @@ func NewFormDataParameterSubSchema(in *yaml.Node, context *compiler.Context) (*F pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1339,7 +1343,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { v3 := compiler.MapValueForKey(m, "items") if v3 != nil { var err error - x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", context)) + x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", v3, context)) if err != nil { errors = append(errors, err) } @@ -1363,7 +1367,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { v5 := compiler.MapValueForKey(m, "default") if v5 != nil { var err error - x.Default, err = NewAny(v5, compiler.NewContext("default", context)) + x.Default, err = NewAny(v5, compiler.NewContext("default", v5, context)) if err != nil { errors = append(errors, err) } @@ -1478,7 +1482,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { a, ok := compiler.SequenceNodeForNode(v16) if ok { for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", context)) + y, err := NewAny(item, compiler.NewContext("enum", item, context)) if err != nil { errors = append(errors, err) } @@ -1528,7 +1532,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1627,7 +1631,7 @@ func NewHeaderParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Hea v7 := compiler.MapValueForKey(m, "items") if v7 != nil { var err error - x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", context)) + x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", v7, context)) if err != nil { errors = append(errors, err) } @@ -1651,7 +1655,7 @@ func NewHeaderParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Hea v9 := compiler.MapValueForKey(m, "default") if v9 != nil { var err error - x.Default, err = NewAny(v9, compiler.NewContext("default", context)) + x.Default, err = NewAny(v9, compiler.NewContext("default", v9, context)) if err != nil { errors = append(errors, err) } @@ -1766,7 +1770,7 @@ func NewHeaderParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Hea a, ok := compiler.SequenceNodeForNode(v20) if ok { for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", context)) + y, err := NewAny(item, compiler.NewContext("enum", item, context)) if err != nil { errors = append(errors, err) } @@ -1807,7 +1811,7 @@ func NewHeaderParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Hea pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1839,7 +1843,7 @@ func NewHeaders(in *yaml.Node, context *compiler.Context) (*Headers, error) { pair := &NamedHeader{} pair.Name = k var err error - pair.Value, err = NewHeader(v, compiler.NewContext(k, context)) + pair.Value, err = NewHeader(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1912,7 +1916,7 @@ func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { v5 := compiler.MapValueForKey(m, "contact") if v5 != nil { var err error - x.Contact, err = NewContact(v5, compiler.NewContext("contact", context)) + x.Contact, err = NewContact(v5, compiler.NewContext("contact", v5, context)) if err != nil { errors = append(errors, err) } @@ -1921,7 +1925,7 @@ func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { v6 := compiler.MapValueForKey(m, "license") if v6 != nil { var err error - x.License, err = NewLicense(v6, compiler.NewContext("license", context)) + x.License, err = NewLicense(v6, compiler.NewContext("license", v6, context)) if err != nil { errors = append(errors, err) } @@ -1948,7 +1952,7 @@ func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1971,7 +1975,7 @@ func NewItemsItem(in *yaml.Node, context *compiler.Context) (*ItemsItem, error) errors = append(errors, compiler.NewError(context, message)) } else { x.Schema = make([]*Schema, 0) - y, err := NewSchema(m, compiler.NewContext("", context)) + y, err := NewSchema(m, compiler.NewContext("", m, context)) if err != nil { return nil, err } @@ -2079,7 +2083,7 @@ func NewLicense(in *yaml.Node, context *compiler.Context) (*License, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -2121,7 +2125,7 @@ func NewNamedAny(in *yaml.Node, context *compiler.Context) (*NamedAny, error) { v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewAny(v2, compiler.NewContext("value", context)) + x.Value, err = NewAny(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2159,7 +2163,7 @@ func NewNamedHeader(in *yaml.Node, context *compiler.Context) (*NamedHeader, err v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewHeader(v2, compiler.NewContext("value", context)) + x.Value, err = NewHeader(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2197,7 +2201,7 @@ func NewNamedParameter(in *yaml.Node, context *compiler.Context) (*NamedParamete v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewParameter(v2, compiler.NewContext("value", context)) + x.Value, err = NewParameter(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2235,7 +2239,7 @@ func NewNamedPathItem(in *yaml.Node, context *compiler.Context) (*NamedPathItem, v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewPathItem(v2, compiler.NewContext("value", context)) + x.Value, err = NewPathItem(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2273,7 +2277,7 @@ func NewNamedResponse(in *yaml.Node, context *compiler.Context) (*NamedResponse, v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewResponse(v2, compiler.NewContext("value", context)) + x.Value, err = NewResponse(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2311,7 +2315,7 @@ func NewNamedResponseValue(in *yaml.Node, context *compiler.Context) (*NamedResp v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewResponseValue(v2, compiler.NewContext("value", context)) + x.Value, err = NewResponseValue(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2349,7 +2353,7 @@ func NewNamedSchema(in *yaml.Node, context *compiler.Context) (*NamedSchema, err v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewSchema(v2, compiler.NewContext("value", context)) + x.Value, err = NewSchema(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2387,7 +2391,7 @@ func NewNamedSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) ( v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewSecurityDefinitionsItem(v2, compiler.NewContext("value", context)) + x.Value, err = NewSecurityDefinitionsItem(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2463,7 +2467,7 @@ func NewNamedStringArray(in *yaml.Node, context *compiler.Context) (*NamedString v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewStringArray(v2, compiler.NewContext("value", context)) + x.Value, err = NewStringArray(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2491,7 +2495,7 @@ func NewNonBodyParameter(in *yaml.Node, context *compiler.Context) (*NonBodyPara // HeaderParameterSubSchema header_parameter_sub_schema = 1; { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewHeaderParameterSubSchema(m, compiler.NewContext("headerParameterSubSchema", context)) + t, matchingError := NewHeaderParameterSubSchema(m, compiler.NewContext("headerParameterSubSchema", m, context)) if matchingError == nil { x.Oneof = &NonBodyParameter_HeaderParameterSubSchema{HeaderParameterSubSchema: t} matched = true @@ -2502,7 +2506,7 @@ func NewNonBodyParameter(in *yaml.Node, context *compiler.Context) (*NonBodyPara // FormDataParameterSubSchema form_data_parameter_sub_schema = 2; { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewFormDataParameterSubSchema(m, compiler.NewContext("formDataParameterSubSchema", context)) + t, matchingError := NewFormDataParameterSubSchema(m, compiler.NewContext("formDataParameterSubSchema", m, context)) if matchingError == nil { x.Oneof = &NonBodyParameter_FormDataParameterSubSchema{FormDataParameterSubSchema: t} matched = true @@ -2513,7 +2517,7 @@ func NewNonBodyParameter(in *yaml.Node, context *compiler.Context) (*NonBodyPara // QueryParameterSubSchema query_parameter_sub_schema = 3; { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewQueryParameterSubSchema(m, compiler.NewContext("queryParameterSubSchema", context)) + t, matchingError := NewQueryParameterSubSchema(m, compiler.NewContext("queryParameterSubSchema", m, context)) if matchingError == nil { x.Oneof = &NonBodyParameter_QueryParameterSubSchema{QueryParameterSubSchema: t} matched = true @@ -2524,7 +2528,7 @@ func NewNonBodyParameter(in *yaml.Node, context *compiler.Context) (*NonBodyPara // PathParameterSubSchema path_parameter_sub_schema = 4; { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewPathParameterSubSchema(m, compiler.NewContext("pathParameterSubSchema", context)) + t, matchingError := NewPathParameterSubSchema(m, compiler.NewContext("pathParameterSubSchema", m, context)) if matchingError == nil { x.Oneof = &NonBodyParameter_PathParameterSubSchema{PathParameterSubSchema: t} matched = true @@ -2536,6 +2540,10 @@ func NewNonBodyParameter(in *yaml.Node, context *compiler.Context) (*NonBodyPara if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid NonBodyParameter") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -2596,7 +2604,7 @@ func NewOauth2AccessCodeSecurity(in *yaml.Node, context *compiler.Context) (*Oau v3 := compiler.MapValueForKey(m, "scopes") if v3 != nil { var err error - x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context)) + x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", v3, context)) if err != nil { errors = append(errors, err) } @@ -2650,7 +2658,7 @@ func NewOauth2AccessCodeSecurity(in *yaml.Node, context *compiler.Context) (*Oau pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -2719,7 +2727,7 @@ func NewOauth2ApplicationSecurity(in *yaml.Node, context *compiler.Context) (*Oa v3 := compiler.MapValueForKey(m, "scopes") if v3 != nil { var err error - x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context)) + x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", v3, context)) if err != nil { errors = append(errors, err) } @@ -2764,7 +2772,7 @@ func NewOauth2ApplicationSecurity(in *yaml.Node, context *compiler.Context) (*Oa pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -2833,7 +2841,7 @@ func NewOauth2ImplicitSecurity(in *yaml.Node, context *compiler.Context) (*Oauth v3 := compiler.MapValueForKey(m, "scopes") if v3 != nil { var err error - x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context)) + x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", v3, context)) if err != nil { errors = append(errors, err) } @@ -2878,7 +2886,7 @@ func NewOauth2ImplicitSecurity(in *yaml.Node, context *compiler.Context) (*Oauth pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -2947,7 +2955,7 @@ func NewOauth2PasswordSecurity(in *yaml.Node, context *compiler.Context) (*Oauth v3 := compiler.MapValueForKey(m, "scopes") if v3 != nil { var err error - x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", context)) + x.Scopes, err = NewOauth2Scopes(v3, compiler.NewContext("scopes", v3, context)) if err != nil { errors = append(errors, err) } @@ -2992,7 +3000,7 @@ func NewOauth2PasswordSecurity(in *yaml.Node, context *compiler.Context) (*Oauth pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3086,7 +3094,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) v4 := compiler.MapValueForKey(m, "externalDocs") if v4 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v4, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v4, compiler.NewContext("externalDocs", v4, context)) if err != nil { errors = append(errors, err) } @@ -3130,7 +3138,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) a, ok := compiler.SequenceNodeForNode(v8) if ok { for _, item := range a.Content { - y, err := NewParametersItem(item, compiler.NewContext("parameters", context)) + y, err := NewParametersItem(item, compiler.NewContext("parameters", item, context)) if err != nil { errors = append(errors, err) } @@ -3142,7 +3150,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) v9 := compiler.MapValueForKey(m, "responses") if v9 != nil { var err error - x.Responses, err = NewResponses(v9, compiler.NewContext("responses", context)) + x.Responses, err = NewResponses(v9, compiler.NewContext("responses", v9, context)) if err != nil { errors = append(errors, err) } @@ -3181,7 +3189,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) a, ok := compiler.SequenceNodeForNode(v12) if ok { for _, item := range a.Content { - y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) + y, err := NewSecurityRequirement(item, compiler.NewContext("security", item, context)) if err != nil { errors = append(errors, err) } @@ -3211,7 +3219,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3234,7 +3242,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewBodyParameter(m, compiler.NewContext("bodyParameter", context)) + t, matchingError := NewBodyParameter(m, compiler.NewContext("bodyParameter", m, context)) if matchingError == nil { x.Oneof = &Parameter_BodyParameter{BodyParameter: t} matched = true @@ -3248,7 +3256,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewNonBodyParameter(m, compiler.NewContext("nonBodyParameter", context)) + t, matchingError := NewNonBodyParameter(m, compiler.NewContext("nonBodyParameter", m, context)) if matchingError == nil { x.Oneof = &Parameter_NonBodyParameter{NonBodyParameter: t} matched = true @@ -3260,6 +3268,10 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid Parameter") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -3283,7 +3295,7 @@ func NewParameterDefinitions(in *yaml.Node, context *compiler.Context) (*Paramet pair := &NamedParameter{} pair.Name = k var err error - pair.Value, err = NewParameter(v, compiler.NewContext(k, context)) + pair.Value, err = NewParameter(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3304,7 +3316,7 @@ func NewParametersItem(in *yaml.Node, context *compiler.Context) (*ParametersIte m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewParameter(m, compiler.NewContext("parameter", context)) + t, matchingError := NewParameter(m, compiler.NewContext("parameter", m, context)) if matchingError == nil { x.Oneof = &ParametersItem_Parameter{Parameter: t} matched = true @@ -3318,7 +3330,7 @@ func NewParametersItem(in *yaml.Node, context *compiler.Context) (*ParametersIte m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", context)) + t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", m, context)) if matchingError == nil { x.Oneof = &ParametersItem_JsonReference{JsonReference: t} matched = true @@ -3330,6 +3342,10 @@ func NewParametersItem(in *yaml.Node, context *compiler.Context) (*ParametersIte if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid ParametersItem") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -3363,7 +3379,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v2 := compiler.MapValueForKey(m, "get") if v2 != nil { var err error - x.Get, err = NewOperation(v2, compiler.NewContext("get", context)) + x.Get, err = NewOperation(v2, compiler.NewContext("get", v2, context)) if err != nil { errors = append(errors, err) } @@ -3372,7 +3388,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v3 := compiler.MapValueForKey(m, "put") if v3 != nil { var err error - x.Put, err = NewOperation(v3, compiler.NewContext("put", context)) + x.Put, err = NewOperation(v3, compiler.NewContext("put", v3, context)) if err != nil { errors = append(errors, err) } @@ -3381,7 +3397,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v4 := compiler.MapValueForKey(m, "post") if v4 != nil { var err error - x.Post, err = NewOperation(v4, compiler.NewContext("post", context)) + x.Post, err = NewOperation(v4, compiler.NewContext("post", v4, context)) if err != nil { errors = append(errors, err) } @@ -3390,7 +3406,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v5 := compiler.MapValueForKey(m, "delete") if v5 != nil { var err error - x.Delete, err = NewOperation(v5, compiler.NewContext("delete", context)) + x.Delete, err = NewOperation(v5, compiler.NewContext("delete", v5, context)) if err != nil { errors = append(errors, err) } @@ -3399,7 +3415,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v6 := compiler.MapValueForKey(m, "options") if v6 != nil { var err error - x.Options, err = NewOperation(v6, compiler.NewContext("options", context)) + x.Options, err = NewOperation(v6, compiler.NewContext("options", v6, context)) if err != nil { errors = append(errors, err) } @@ -3408,7 +3424,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v7 := compiler.MapValueForKey(m, "head") if v7 != nil { var err error - x.Head, err = NewOperation(v7, compiler.NewContext("head", context)) + x.Head, err = NewOperation(v7, compiler.NewContext("head", v7, context)) if err != nil { errors = append(errors, err) } @@ -3417,7 +3433,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v8 := compiler.MapValueForKey(m, "patch") if v8 != nil { var err error - x.Patch, err = NewOperation(v8, compiler.NewContext("patch", context)) + x.Patch, err = NewOperation(v8, compiler.NewContext("patch", v8, context)) if err != nil { errors = append(errors, err) } @@ -3430,7 +3446,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { a, ok := compiler.SequenceNodeForNode(v9) if ok { for _, item := range a.Content { - y, err := NewParametersItem(item, compiler.NewContext("parameters", context)) + y, err := NewParametersItem(item, compiler.NewContext("parameters", item, context)) if err != nil { errors = append(errors, err) } @@ -3460,7 +3476,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3565,7 +3581,7 @@ func NewPathParameterSubSchema(in *yaml.Node, context *compiler.Context) (*PathP v7 := compiler.MapValueForKey(m, "items") if v7 != nil { var err error - x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", context)) + x.Items, err = NewPrimitivesItems(v7, compiler.NewContext("items", v7, context)) if err != nil { errors = append(errors, err) } @@ -3589,7 +3605,7 @@ func NewPathParameterSubSchema(in *yaml.Node, context *compiler.Context) (*PathP v9 := compiler.MapValueForKey(m, "default") if v9 != nil { var err error - x.Default, err = NewAny(v9, compiler.NewContext("default", context)) + x.Default, err = NewAny(v9, compiler.NewContext("default", v9, context)) if err != nil { errors = append(errors, err) } @@ -3704,7 +3720,7 @@ func NewPathParameterSubSchema(in *yaml.Node, context *compiler.Context) (*PathP a, ok := compiler.SequenceNodeForNode(v20) if ok { for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", context)) + y, err := NewAny(item, compiler.NewContext("enum", item, context)) if err != nil { errors = append(errors, err) } @@ -3745,7 +3761,7 @@ func NewPathParameterSubSchema(in *yaml.Node, context *compiler.Context) (*PathP pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3796,7 +3812,7 @@ func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3816,7 +3832,7 @@ func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { pair := &NamedPathItem{} pair.Name = k var err error - pair.Value, err = NewPathItem(v, compiler.NewContext(k, context)) + pair.Value, err = NewPathItem(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3872,7 +3888,7 @@ func NewPrimitivesItems(in *yaml.Node, context *compiler.Context) (*PrimitivesIt v3 := compiler.MapValueForKey(m, "items") if v3 != nil { var err error - x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", context)) + x.Items, err = NewPrimitivesItems(v3, compiler.NewContext("items", v3, context)) if err != nil { errors = append(errors, err) } @@ -3896,7 +3912,7 @@ func NewPrimitivesItems(in *yaml.Node, context *compiler.Context) (*PrimitivesIt v5 := compiler.MapValueForKey(m, "default") if v5 != nil { var err error - x.Default, err = NewAny(v5, compiler.NewContext("default", context)) + x.Default, err = NewAny(v5, compiler.NewContext("default", v5, context)) if err != nil { errors = append(errors, err) } @@ -4011,7 +4027,7 @@ func NewPrimitivesItems(in *yaml.Node, context *compiler.Context) (*PrimitivesIt a, ok := compiler.SequenceNodeForNode(v16) if ok { for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", context)) + y, err := NewAny(item, compiler.NewContext("enum", item, context)) if err != nil { errors = append(errors, err) } @@ -4052,7 +4068,7 @@ func NewPrimitivesItems(in *yaml.Node, context *compiler.Context) (*PrimitivesIt pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4084,7 +4100,7 @@ func NewProperties(in *yaml.Node, context *compiler.Context) (*Properties, error pair := &NamedSchema{} pair.Name = k var err error - pair.Value, err = NewSchema(v, compiler.NewContext(k, context)) + pair.Value, err = NewSchema(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4190,7 +4206,7 @@ func NewQueryParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Quer v8 := compiler.MapValueForKey(m, "items") if v8 != nil { var err error - x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", context)) + x.Items, err = NewPrimitivesItems(v8, compiler.NewContext("items", v8, context)) if err != nil { errors = append(errors, err) } @@ -4214,7 +4230,7 @@ func NewQueryParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Quer v10 := compiler.MapValueForKey(m, "default") if v10 != nil { var err error - x.Default, err = NewAny(v10, compiler.NewContext("default", context)) + x.Default, err = NewAny(v10, compiler.NewContext("default", v10, context)) if err != nil { errors = append(errors, err) } @@ -4329,7 +4345,7 @@ func NewQueryParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Quer a, ok := compiler.SequenceNodeForNode(v21) if ok { for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", context)) + y, err := NewAny(item, compiler.NewContext("enum", item, context)) if err != nil { errors = append(errors, err) } @@ -4370,7 +4386,7 @@ func NewQueryParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Quer pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4418,7 +4434,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { v2 := compiler.MapValueForKey(m, "schema") if v2 != nil { var err error - x.Schema, err = NewSchemaItem(v2, compiler.NewContext("schema", context)) + x.Schema, err = NewSchemaItem(v2, compiler.NewContext("schema", v2, context)) if err != nil { errors = append(errors, err) } @@ -4427,7 +4443,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { v3 := compiler.MapValueForKey(m, "headers") if v3 != nil { var err error - x.Headers, err = NewHeaders(v3, compiler.NewContext("headers", context)) + x.Headers, err = NewHeaders(v3, compiler.NewContext("headers", v3, context)) if err != nil { errors = append(errors, err) } @@ -4436,7 +4452,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { v4 := compiler.MapValueForKey(m, "examples") if v4 != nil { var err error - x.Examples, err = NewExamples(v4, compiler.NewContext("examples", context)) + x.Examples, err = NewExamples(v4, compiler.NewContext("examples", v4, context)) if err != nil { errors = append(errors, err) } @@ -4463,7 +4479,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4495,7 +4511,7 @@ func NewResponseDefinitions(in *yaml.Node, context *compiler.Context) (*Response pair := &NamedResponse{} pair.Name = k var err error - pair.Value, err = NewResponse(v, compiler.NewContext(k, context)) + pair.Value, err = NewResponse(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4516,7 +4532,7 @@ func NewResponseValue(in *yaml.Node, context *compiler.Context) (*ResponseValue, m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewResponse(m, compiler.NewContext("response", context)) + t, matchingError := NewResponse(m, compiler.NewContext("response", m, context)) if matchingError == nil { x.Oneof = &ResponseValue_Response{Response: t} matched = true @@ -4530,7 +4546,7 @@ func NewResponseValue(in *yaml.Node, context *compiler.Context) (*ResponseValue, m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", context)) + t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", m, context)) if matchingError == nil { x.Oneof = &ResponseValue_JsonReference{JsonReference: t} matched = true @@ -4542,6 +4558,10 @@ func NewResponseValue(in *yaml.Node, context *compiler.Context) (*ResponseValue, if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid ResponseValue") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -4573,7 +4593,7 @@ func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) pair := &NamedResponseValue{} pair.Name = k var err error - pair.Value, err = NewResponseValue(v, compiler.NewContext(k, context)) + pair.Value, err = NewResponseValue(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4603,7 +4623,7 @@ func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4672,7 +4692,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v5 := compiler.MapValueForKey(m, "default") if v5 != nil { var err error - x.Default, err = NewAny(v5, compiler.NewContext("default", context)) + x.Default, err = NewAny(v5, compiler.NewContext("default", v5, context)) if err != nil { errors = append(errors, err) } @@ -4831,7 +4851,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { a, ok := compiler.SequenceNodeForNode(v20) if ok { for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", context)) + y, err := NewAny(item, compiler.NewContext("enum", item, context)) if err != nil { errors = append(errors, err) } @@ -4843,7 +4863,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v21 := compiler.MapValueForKey(m, "additionalProperties") if v21 != nil { var err error - x.AdditionalProperties, err = NewAdditionalPropertiesItem(v21, compiler.NewContext("additionalProperties", context)) + x.AdditionalProperties, err = NewAdditionalPropertiesItem(v21, compiler.NewContext("additionalProperties", v21, context)) if err != nil { errors = append(errors, err) } @@ -4852,7 +4872,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v22 := compiler.MapValueForKey(m, "type") if v22 != nil { var err error - x.Type, err = NewTypeItem(v22, compiler.NewContext("type", context)) + x.Type, err = NewTypeItem(v22, compiler.NewContext("type", v22, context)) if err != nil { errors = append(errors, err) } @@ -4861,7 +4881,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v23 := compiler.MapValueForKey(m, "items") if v23 != nil { var err error - x.Items, err = NewItemsItem(v23, compiler.NewContext("items", context)) + x.Items, err = NewItemsItem(v23, compiler.NewContext("items", v23, context)) if err != nil { errors = append(errors, err) } @@ -4874,7 +4894,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { a, ok := compiler.SequenceNodeForNode(v24) if ok { for _, item := range a.Content { - y, err := NewSchema(item, compiler.NewContext("allOf", context)) + y, err := NewSchema(item, compiler.NewContext("allOf", item, context)) if err != nil { errors = append(errors, err) } @@ -4886,7 +4906,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v25 := compiler.MapValueForKey(m, "properties") if v25 != nil { var err error - x.Properties, err = NewProperties(v25, compiler.NewContext("properties", context)) + x.Properties, err = NewProperties(v25, compiler.NewContext("properties", v25, context)) if err != nil { errors = append(errors, err) } @@ -4913,7 +4933,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v28 := compiler.MapValueForKey(m, "xml") if v28 != nil { var err error - x.Xml, err = NewXml(v28, compiler.NewContext("xml", context)) + x.Xml, err = NewXml(v28, compiler.NewContext("xml", v28, context)) if err != nil { errors = append(errors, err) } @@ -4922,7 +4942,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v29 := compiler.MapValueForKey(m, "externalDocs") if v29 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v29, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v29, compiler.NewContext("externalDocs", v29, context)) if err != nil { errors = append(errors, err) } @@ -4931,7 +4951,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v30 := compiler.MapValueForKey(m, "example") if v30 != nil { var err error - x.Example, err = NewAny(v30, compiler.NewContext("example", context)) + x.Example, err = NewAny(v30, compiler.NewContext("example", v30, context)) if err != nil { errors = append(errors, err) } @@ -4958,7 +4978,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4981,7 +5001,7 @@ func NewSchemaItem(in *yaml.Node, context *compiler.Context) (*SchemaItem, error m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewSchema(m, compiler.NewContext("schema", context)) + t, matchingError := NewSchema(m, compiler.NewContext("schema", m, context)) if matchingError == nil { x.Oneof = &SchemaItem_Schema{Schema: t} matched = true @@ -4995,7 +5015,7 @@ func NewSchemaItem(in *yaml.Node, context *compiler.Context) (*SchemaItem, error m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewFileSchema(m, compiler.NewContext("fileSchema", context)) + t, matchingError := NewFileSchema(m, compiler.NewContext("fileSchema", m, context)) if matchingError == nil { x.Oneof = &SchemaItem_FileSchema{FileSchema: t} matched = true @@ -5007,6 +5027,10 @@ func NewSchemaItem(in *yaml.Node, context *compiler.Context) (*SchemaItem, error if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid SchemaItem") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -5030,7 +5054,7 @@ func NewSecurityDefinitions(in *yaml.Node, context *compiler.Context) (*Security pair := &NamedSecurityDefinitionsItem{} pair.Name = k var err error - pair.Value, err = NewSecurityDefinitionsItem(v, compiler.NewContext(k, context)) + pair.Value, err = NewSecurityDefinitionsItem(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -5051,7 +5075,7 @@ func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*Secu m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewBasicAuthenticationSecurity(m, compiler.NewContext("basicAuthenticationSecurity", context)) + t, matchingError := NewBasicAuthenticationSecurity(m, compiler.NewContext("basicAuthenticationSecurity", m, context)) if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_BasicAuthenticationSecurity{BasicAuthenticationSecurity: t} matched = true @@ -5065,7 +5089,7 @@ func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*Secu m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewApiKeySecurity(m, compiler.NewContext("apiKeySecurity", context)) + t, matchingError := NewApiKeySecurity(m, compiler.NewContext("apiKeySecurity", m, context)) if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_ApiKeySecurity{ApiKeySecurity: t} matched = true @@ -5079,7 +5103,7 @@ func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*Secu m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewOauth2ImplicitSecurity(m, compiler.NewContext("oauth2ImplicitSecurity", context)) + t, matchingError := NewOauth2ImplicitSecurity(m, compiler.NewContext("oauth2ImplicitSecurity", m, context)) if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_Oauth2ImplicitSecurity{Oauth2ImplicitSecurity: t} matched = true @@ -5093,7 +5117,7 @@ func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*Secu m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewOauth2PasswordSecurity(m, compiler.NewContext("oauth2PasswordSecurity", context)) + t, matchingError := NewOauth2PasswordSecurity(m, compiler.NewContext("oauth2PasswordSecurity", m, context)) if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_Oauth2PasswordSecurity{Oauth2PasswordSecurity: t} matched = true @@ -5107,7 +5131,7 @@ func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*Secu m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewOauth2ApplicationSecurity(m, compiler.NewContext("oauth2ApplicationSecurity", context)) + t, matchingError := NewOauth2ApplicationSecurity(m, compiler.NewContext("oauth2ApplicationSecurity", m, context)) if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_Oauth2ApplicationSecurity{Oauth2ApplicationSecurity: t} matched = true @@ -5121,7 +5145,7 @@ func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*Secu m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewOauth2AccessCodeSecurity(m, compiler.NewContext("oauth2AccessCodeSecurity", context)) + t, matchingError := NewOauth2AccessCodeSecurity(m, compiler.NewContext("oauth2AccessCodeSecurity", m, context)) if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_Oauth2AccessCodeSecurity{Oauth2AccessCodeSecurity: t} matched = true @@ -5133,6 +5157,10 @@ func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*Secu if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid SecurityDefinitionsItem") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -5156,7 +5184,7 @@ func NewSecurityRequirement(in *yaml.Node, context *compiler.Context) (*Security pair := &NamedStringArray{} pair.Name = k var err error - pair.Value, err = NewStringArray(v, compiler.NewContext(k, context)) + pair.Value, err = NewStringArray(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -5223,7 +5251,7 @@ func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { v3 := compiler.MapValueForKey(m, "externalDocs") if v3 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v3, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v3, compiler.NewContext("externalDocs", v3, context)) if err != nil { errors = append(errors, err) } @@ -5250,7 +5278,7 @@ func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -5321,7 +5349,7 @@ func NewVendorExtension(in *yaml.Node, context *compiler.Context) (*VendorExtens pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -5416,7 +5444,7 @@ func NewXml(in *yaml.Node, context *compiler.Context) (*Xml, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } diff --git a/openapiv2/document.go b/openapiv2/document.go index ddeed5c8..3a26d319 100644 --- a/openapiv2/document.go +++ b/openapiv2/document.go @@ -22,5 +22,6 @@ func ParseDocument(b []byte) (*Document, error) { if err != nil { return nil, err } - return NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, nil)) + root := info.Content[0] + return NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, nil)) } diff --git a/openapiv3/OpenAPIv3.go b/openapiv3/OpenAPIv3.go index 79dc4939..e2d30de8 100644 --- a/openapiv3/OpenAPIv3.go +++ b/openapiv3/OpenAPIv3.go @@ -39,7 +39,7 @@ func NewAdditionalPropertiesItem(in *yaml.Node, context *compiler.Context) (*Add m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewSchemaOrReference(m, compiler.NewContext("schemaOrReference", context)) + t, matchingError := NewSchemaOrReference(m, compiler.NewContext("schemaOrReference", m, context)) if matchingError == nil { x.Oneof = &AdditionalPropertiesItem_SchemaOrReference{SchemaOrReference: t} matched = true @@ -57,6 +57,10 @@ func NewAdditionalPropertiesItem(in *yaml.Node, context *compiler.Context) (*Add if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid AdditionalPropertiesItem") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -80,7 +84,7 @@ func NewAnyOrExpression(in *yaml.Node, context *compiler.Context) (*AnyOrExpress m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewAny(m, compiler.NewContext("any", context)) + t, matchingError := NewAny(m, compiler.NewContext("any", m, context)) if matchingError == nil { x.Oneof = &AnyOrExpression_Any{Any: t} matched = true @@ -94,7 +98,7 @@ func NewAnyOrExpression(in *yaml.Node, context *compiler.Context) (*AnyOrExpress m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewExpression(m, compiler.NewContext("expression", context)) + t, matchingError := NewExpression(m, compiler.NewContext("expression", m, context)) if matchingError == nil { x.Oneof = &AnyOrExpression_Expression{Expression: t} matched = true @@ -106,6 +110,10 @@ func NewAnyOrExpression(in *yaml.Node, context *compiler.Context) (*AnyOrExpress if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid AnyOrExpression") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -137,7 +145,7 @@ func NewCallback(in *yaml.Node, context *compiler.Context) (*Callback, error) { pair := &NamedPathItem{} pair.Name = k var err error - pair.Value, err = NewPathItem(v, compiler.NewContext(k, context)) + pair.Value, err = NewPathItem(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -167,7 +175,7 @@ func NewCallback(in *yaml.Node, context *compiler.Context) (*Callback, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -190,7 +198,7 @@ func NewCallbackOrReference(in *yaml.Node, context *compiler.Context) (*Callback m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewCallback(m, compiler.NewContext("callback", context)) + t, matchingError := NewCallback(m, compiler.NewContext("callback", m, context)) if matchingError == nil { x.Oneof = &CallbackOrReference_Callback{Callback: t} matched = true @@ -204,7 +212,7 @@ func NewCallbackOrReference(in *yaml.Node, context *compiler.Context) (*Callback m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &CallbackOrReference_Reference{Reference: t} matched = true @@ -216,6 +224,10 @@ func NewCallbackOrReference(in *yaml.Node, context *compiler.Context) (*Callback if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid CallbackOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -239,7 +251,7 @@ func NewCallbacksOrReferences(in *yaml.Node, context *compiler.Context) (*Callba pair := &NamedCallbackOrReference{} pair.Name = k var err error - pair.Value, err = NewCallbackOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewCallbackOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -270,7 +282,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v1 := compiler.MapValueForKey(m, "schemas") if v1 != nil { var err error - x.Schemas, err = NewSchemasOrReferences(v1, compiler.NewContext("schemas", context)) + x.Schemas, err = NewSchemasOrReferences(v1, compiler.NewContext("schemas", v1, context)) if err != nil { errors = append(errors, err) } @@ -279,7 +291,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v2 := compiler.MapValueForKey(m, "responses") if v2 != nil { var err error - x.Responses, err = NewResponsesOrReferences(v2, compiler.NewContext("responses", context)) + x.Responses, err = NewResponsesOrReferences(v2, compiler.NewContext("responses", v2, context)) if err != nil { errors = append(errors, err) } @@ -288,7 +300,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v3 := compiler.MapValueForKey(m, "parameters") if v3 != nil { var err error - x.Parameters, err = NewParametersOrReferences(v3, compiler.NewContext("parameters", context)) + x.Parameters, err = NewParametersOrReferences(v3, compiler.NewContext("parameters", v3, context)) if err != nil { errors = append(errors, err) } @@ -297,7 +309,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v4 := compiler.MapValueForKey(m, "examples") if v4 != nil { var err error - x.Examples, err = NewExamplesOrReferences(v4, compiler.NewContext("examples", context)) + x.Examples, err = NewExamplesOrReferences(v4, compiler.NewContext("examples", v4, context)) if err != nil { errors = append(errors, err) } @@ -306,7 +318,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v5 := compiler.MapValueForKey(m, "requestBodies") if v5 != nil { var err error - x.RequestBodies, err = NewRequestBodiesOrReferences(v5, compiler.NewContext("requestBodies", context)) + x.RequestBodies, err = NewRequestBodiesOrReferences(v5, compiler.NewContext("requestBodies", v5, context)) if err != nil { errors = append(errors, err) } @@ -315,7 +327,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v6 := compiler.MapValueForKey(m, "headers") if v6 != nil { var err error - x.Headers, err = NewHeadersOrReferences(v6, compiler.NewContext("headers", context)) + x.Headers, err = NewHeadersOrReferences(v6, compiler.NewContext("headers", v6, context)) if err != nil { errors = append(errors, err) } @@ -324,7 +336,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v7 := compiler.MapValueForKey(m, "securitySchemes") if v7 != nil { var err error - x.SecuritySchemes, err = NewSecuritySchemesOrReferences(v7, compiler.NewContext("securitySchemes", context)) + x.SecuritySchemes, err = NewSecuritySchemesOrReferences(v7, compiler.NewContext("securitySchemes", v7, context)) if err != nil { errors = append(errors, err) } @@ -333,7 +345,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v8 := compiler.MapValueForKey(m, "links") if v8 != nil { var err error - x.Links, err = NewLinksOrReferences(v8, compiler.NewContext("links", context)) + x.Links, err = NewLinksOrReferences(v8, compiler.NewContext("links", v8, context)) if err != nil { errors = append(errors, err) } @@ -342,7 +354,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error v9 := compiler.MapValueForKey(m, "callbacks") if v9 != nil { var err error - x.Callbacks, err = NewCallbacksOrReferences(v9, compiler.NewContext("callbacks", context)) + x.Callbacks, err = NewCallbacksOrReferences(v9, compiler.NewContext("callbacks", v9, context)) if err != nil { errors = append(errors, err) } @@ -369,7 +381,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -447,7 +459,7 @@ func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -525,7 +537,7 @@ func NewDiscriminator(in *yaml.Node, context *compiler.Context) (*Discriminator, v2 := compiler.MapValueForKey(m, "mapping") if v2 != nil { var err error - x.Mapping, err = NewStrings(v2, compiler.NewContext("mapping", context)) + x.Mapping, err = NewStrings(v2, compiler.NewContext("mapping", v2, context)) if err != nil { errors = append(errors, err) } @@ -552,7 +564,7 @@ func NewDiscriminator(in *yaml.Node, context *compiler.Context) (*Discriminator, pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -600,7 +612,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v2 := compiler.MapValueForKey(m, "info") if v2 != nil { var err error - x.Info, err = NewInfo(v2, compiler.NewContext("info", context)) + x.Info, err = NewInfo(v2, compiler.NewContext("info", v2, context)) if err != nil { errors = append(errors, err) } @@ -613,7 +625,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { a, ok := compiler.SequenceNodeForNode(v3) if ok { for _, item := range a.Content { - y, err := NewServer(item, compiler.NewContext("servers", context)) + y, err := NewServer(item, compiler.NewContext("servers", item, context)) if err != nil { errors = append(errors, err) } @@ -625,7 +637,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v4 := compiler.MapValueForKey(m, "paths") if v4 != nil { var err error - x.Paths, err = NewPaths(v4, compiler.NewContext("paths", context)) + x.Paths, err = NewPaths(v4, compiler.NewContext("paths", v4, context)) if err != nil { errors = append(errors, err) } @@ -634,7 +646,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v5 := compiler.MapValueForKey(m, "components") if v5 != nil { var err error - x.Components, err = NewComponents(v5, compiler.NewContext("components", context)) + x.Components, err = NewComponents(v5, compiler.NewContext("components", v5, context)) if err != nil { errors = append(errors, err) } @@ -647,7 +659,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { a, ok := compiler.SequenceNodeForNode(v6) if ok { for _, item := range a.Content { - y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) + y, err := NewSecurityRequirement(item, compiler.NewContext("security", item, context)) if err != nil { errors = append(errors, err) } @@ -663,7 +675,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { a, ok := compiler.SequenceNodeForNode(v7) if ok { for _, item := range a.Content { - y, err := NewTag(item, compiler.NewContext("tags", context)) + y, err := NewTag(item, compiler.NewContext("tags", item, context)) if err != nil { errors = append(errors, err) } @@ -675,7 +687,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { v8 := compiler.MapValueForKey(m, "externalDocs") if v8 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v8, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v8, compiler.NewContext("externalDocs", v8, context)) if err != nil { errors = append(errors, err) } @@ -702,7 +714,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -744,7 +756,7 @@ func NewEncoding(in *yaml.Node, context *compiler.Context) (*Encoding, error) { v2 := compiler.MapValueForKey(m, "headers") if v2 != nil { var err error - x.Headers, err = NewHeadersOrReferences(v2, compiler.NewContext("headers", context)) + x.Headers, err = NewHeadersOrReferences(v2, compiler.NewContext("headers", v2, context)) if err != nil { errors = append(errors, err) } @@ -798,7 +810,7 @@ func NewEncoding(in *yaml.Node, context *compiler.Context) (*Encoding, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -830,7 +842,7 @@ func NewEncodings(in *yaml.Node, context *compiler.Context) (*Encodings, error) pair := &NamedEncoding{} pair.Name = k var err error - pair.Value, err = NewEncoding(v, compiler.NewContext(k, context)) + pair.Value, err = NewEncoding(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -879,7 +891,7 @@ func NewExample(in *yaml.Node, context *compiler.Context) (*Example, error) { v3 := compiler.MapValueForKey(m, "value") if v3 != nil { var err error - x.Value, err = NewAny(v3, compiler.NewContext("value", context)) + x.Value, err = NewAny(v3, compiler.NewContext("value", v3, context)) if err != nil { errors = append(errors, err) } @@ -915,7 +927,7 @@ func NewExample(in *yaml.Node, context *compiler.Context) (*Example, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -938,7 +950,7 @@ func NewExampleOrReference(in *yaml.Node, context *compiler.Context) (*ExampleOr m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewExample(m, compiler.NewContext("example", context)) + t, matchingError := NewExample(m, compiler.NewContext("example", m, context)) if matchingError == nil { x.Oneof = &ExampleOrReference_Example{Example: t} matched = true @@ -952,7 +964,7 @@ func NewExampleOrReference(in *yaml.Node, context *compiler.Context) (*ExampleOr m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &ExampleOrReference_Reference{Reference: t} matched = true @@ -964,6 +976,10 @@ func NewExampleOrReference(in *yaml.Node, context *compiler.Context) (*ExampleOr if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid ExampleOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -987,7 +1003,7 @@ func NewExamplesOrReferences(in *yaml.Node, context *compiler.Context) (*Example pair := &NamedExampleOrReference{} pair.Name = k var err error - pair.Value, err = NewExampleOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewExampleOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1028,7 +1044,7 @@ func NewExpression(in *yaml.Node, context *compiler.Context) (*Expression, error pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1102,7 +1118,7 @@ func NewExternalDocs(in *yaml.Node, context *compiler.Context) (*ExternalDocs, e pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1198,7 +1214,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { v8 := compiler.MapValueForKey(m, "schema") if v8 != nil { var err error - x.Schema, err = NewSchemaOrReference(v8, compiler.NewContext("schema", context)) + x.Schema, err = NewSchemaOrReference(v8, compiler.NewContext("schema", v8, context)) if err != nil { errors = append(errors, err) } @@ -1207,7 +1223,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { v9 := compiler.MapValueForKey(m, "example") if v9 != nil { var err error - x.Example, err = NewAny(v9, compiler.NewContext("example", context)) + x.Example, err = NewAny(v9, compiler.NewContext("example", v9, context)) if err != nil { errors = append(errors, err) } @@ -1216,7 +1232,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { v10 := compiler.MapValueForKey(m, "examples") if v10 != nil { var err error - x.Examples, err = NewExamplesOrReferences(v10, compiler.NewContext("examples", context)) + x.Examples, err = NewExamplesOrReferences(v10, compiler.NewContext("examples", v10, context)) if err != nil { errors = append(errors, err) } @@ -1225,7 +1241,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { v11 := compiler.MapValueForKey(m, "content") if v11 != nil { var err error - x.Content, err = NewMediaTypes(v11, compiler.NewContext("content", context)) + x.Content, err = NewMediaTypes(v11, compiler.NewContext("content", v11, context)) if err != nil { errors = append(errors, err) } @@ -1252,7 +1268,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1275,7 +1291,7 @@ func NewHeaderOrReference(in *yaml.Node, context *compiler.Context) (*HeaderOrRe m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewHeader(m, compiler.NewContext("header", context)) + t, matchingError := NewHeader(m, compiler.NewContext("header", m, context)) if matchingError == nil { x.Oneof = &HeaderOrReference_Header{Header: t} matched = true @@ -1289,7 +1305,7 @@ func NewHeaderOrReference(in *yaml.Node, context *compiler.Context) (*HeaderOrRe m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &HeaderOrReference_Reference{Reference: t} matched = true @@ -1301,6 +1317,10 @@ func NewHeaderOrReference(in *yaml.Node, context *compiler.Context) (*HeaderOrRe if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid HeaderOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -1324,7 +1344,7 @@ func NewHeadersOrReferences(in *yaml.Node, context *compiler.Context) (*HeadersO pair := &NamedHeaderOrReference{} pair.Name = k var err error - pair.Value, err = NewHeaderOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewHeaderOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1388,7 +1408,7 @@ func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { v4 := compiler.MapValueForKey(m, "contact") if v4 != nil { var err error - x.Contact, err = NewContact(v4, compiler.NewContext("contact", context)) + x.Contact, err = NewContact(v4, compiler.NewContext("contact", v4, context)) if err != nil { errors = append(errors, err) } @@ -1397,7 +1417,7 @@ func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { v5 := compiler.MapValueForKey(m, "license") if v5 != nil { var err error - x.License, err = NewLicense(v5, compiler.NewContext("license", context)) + x.License, err = NewLicense(v5, compiler.NewContext("license", v5, context)) if err != nil { errors = append(errors, err) } @@ -1442,7 +1462,7 @@ func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1465,7 +1485,7 @@ func NewItemsItem(in *yaml.Node, context *compiler.Context) (*ItemsItem, error) errors = append(errors, compiler.NewError(context, message)) } else { x.SchemaOrReference = make([]*SchemaOrReference, 0) - y, err := NewSchemaOrReference(m, compiler.NewContext("", context)) + y, err := NewSchemaOrReference(m, compiler.NewContext("", m, context)) if err != nil { return nil, err } @@ -1536,7 +1556,7 @@ func NewLicense(in *yaml.Node, context *compiler.Context) (*License, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1587,7 +1607,7 @@ func NewLink(in *yaml.Node, context *compiler.Context) (*Link, error) { v3 := compiler.MapValueForKey(m, "parameters") if v3 != nil { var err error - x.Parameters, err = NewAnyOrExpression(v3, compiler.NewContext("parameters", context)) + x.Parameters, err = NewAnyOrExpression(v3, compiler.NewContext("parameters", v3, context)) if err != nil { errors = append(errors, err) } @@ -1596,7 +1616,7 @@ func NewLink(in *yaml.Node, context *compiler.Context) (*Link, error) { v4 := compiler.MapValueForKey(m, "requestBody") if v4 != nil { var err error - x.RequestBody, err = NewAnyOrExpression(v4, compiler.NewContext("requestBody", context)) + x.RequestBody, err = NewAnyOrExpression(v4, compiler.NewContext("requestBody", v4, context)) if err != nil { errors = append(errors, err) } @@ -1614,7 +1634,7 @@ func NewLink(in *yaml.Node, context *compiler.Context) (*Link, error) { v6 := compiler.MapValueForKey(m, "server") if v6 != nil { var err error - x.Server, err = NewServer(v6, compiler.NewContext("server", context)) + x.Server, err = NewServer(v6, compiler.NewContext("server", v6, context)) if err != nil { errors = append(errors, err) } @@ -1641,7 +1661,7 @@ func NewLink(in *yaml.Node, context *compiler.Context) (*Link, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1664,7 +1684,7 @@ func NewLinkOrReference(in *yaml.Node, context *compiler.Context) (*LinkOrRefere m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewLink(m, compiler.NewContext("link", context)) + t, matchingError := NewLink(m, compiler.NewContext("link", m, context)) if matchingError == nil { x.Oneof = &LinkOrReference_Link{Link: t} matched = true @@ -1678,7 +1698,7 @@ func NewLinkOrReference(in *yaml.Node, context *compiler.Context) (*LinkOrRefere m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &LinkOrReference_Reference{Reference: t} matched = true @@ -1690,6 +1710,10 @@ func NewLinkOrReference(in *yaml.Node, context *compiler.Context) (*LinkOrRefere if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid LinkOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -1713,7 +1737,7 @@ func NewLinksOrReferences(in *yaml.Node, context *compiler.Context) (*LinksOrRef pair := &NamedLinkOrReference{} pair.Name = k var err error - pair.Value, err = NewLinkOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewLinkOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1744,7 +1768,7 @@ func NewMediaType(in *yaml.Node, context *compiler.Context) (*MediaType, error) v1 := compiler.MapValueForKey(m, "schema") if v1 != nil { var err error - x.Schema, err = NewSchemaOrReference(v1, compiler.NewContext("schema", context)) + x.Schema, err = NewSchemaOrReference(v1, compiler.NewContext("schema", v1, context)) if err != nil { errors = append(errors, err) } @@ -1753,7 +1777,7 @@ func NewMediaType(in *yaml.Node, context *compiler.Context) (*MediaType, error) v2 := compiler.MapValueForKey(m, "example") if v2 != nil { var err error - x.Example, err = NewAny(v2, compiler.NewContext("example", context)) + x.Example, err = NewAny(v2, compiler.NewContext("example", v2, context)) if err != nil { errors = append(errors, err) } @@ -1762,7 +1786,7 @@ func NewMediaType(in *yaml.Node, context *compiler.Context) (*MediaType, error) v3 := compiler.MapValueForKey(m, "examples") if v3 != nil { var err error - x.Examples, err = NewExamplesOrReferences(v3, compiler.NewContext("examples", context)) + x.Examples, err = NewExamplesOrReferences(v3, compiler.NewContext("examples", v3, context)) if err != nil { errors = append(errors, err) } @@ -1771,7 +1795,7 @@ func NewMediaType(in *yaml.Node, context *compiler.Context) (*MediaType, error) v4 := compiler.MapValueForKey(m, "encoding") if v4 != nil { var err error - x.Encoding, err = NewEncodings(v4, compiler.NewContext("encoding", context)) + x.Encoding, err = NewEncodings(v4, compiler.NewContext("encoding", v4, context)) if err != nil { errors = append(errors, err) } @@ -1798,7 +1822,7 @@ func NewMediaType(in *yaml.Node, context *compiler.Context) (*MediaType, error) pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1830,7 +1854,7 @@ func NewMediaTypes(in *yaml.Node, context *compiler.Context) (*MediaTypes, error pair := &NamedMediaType{} pair.Name = k var err error - pair.Value, err = NewMediaType(v, compiler.NewContext(k, context)) + pair.Value, err = NewMediaType(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -1870,7 +1894,7 @@ func NewNamedAny(in *yaml.Node, context *compiler.Context) (*NamedAny, error) { v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewAny(v2, compiler.NewContext("value", context)) + x.Value, err = NewAny(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -1908,7 +1932,7 @@ func NewNamedCallbackOrReference(in *yaml.Node, context *compiler.Context) (*Nam v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewCallbackOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewCallbackOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -1946,7 +1970,7 @@ func NewNamedEncoding(in *yaml.Node, context *compiler.Context) (*NamedEncoding, v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewEncoding(v2, compiler.NewContext("value", context)) + x.Value, err = NewEncoding(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -1984,7 +2008,7 @@ func NewNamedExampleOrReference(in *yaml.Node, context *compiler.Context) (*Name v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewExampleOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewExampleOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2022,7 +2046,7 @@ func NewNamedHeaderOrReference(in *yaml.Node, context *compiler.Context) (*Named v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewHeaderOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewHeaderOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2060,7 +2084,7 @@ func NewNamedLinkOrReference(in *yaml.Node, context *compiler.Context) (*NamedLi v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewLinkOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewLinkOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2098,7 +2122,7 @@ func NewNamedMediaType(in *yaml.Node, context *compiler.Context) (*NamedMediaTyp v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewMediaType(v2, compiler.NewContext("value", context)) + x.Value, err = NewMediaType(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2136,7 +2160,7 @@ func NewNamedParameterOrReference(in *yaml.Node, context *compiler.Context) (*Na v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewParameterOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewParameterOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2174,7 +2198,7 @@ func NewNamedPathItem(in *yaml.Node, context *compiler.Context) (*NamedPathItem, v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewPathItem(v2, compiler.NewContext("value", context)) + x.Value, err = NewPathItem(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2212,7 +2236,7 @@ func NewNamedRequestBodyOrReference(in *yaml.Node, context *compiler.Context) (* v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewRequestBodyOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewRequestBodyOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2250,7 +2274,7 @@ func NewNamedResponseOrReference(in *yaml.Node, context *compiler.Context) (*Nam v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewResponseOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewResponseOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2288,7 +2312,7 @@ func NewNamedSchemaOrReference(in *yaml.Node, context *compiler.Context) (*Named v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewSchemaOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewSchemaOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2326,7 +2350,7 @@ func NewNamedSecuritySchemeOrReference(in *yaml.Node, context *compiler.Context) v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewSecuritySchemeOrReference(v2, compiler.NewContext("value", context)) + x.Value, err = NewSecuritySchemeOrReference(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2364,7 +2388,7 @@ func NewNamedServerVariable(in *yaml.Node, context *compiler.Context) (*NamedSer v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewServerVariable(v2, compiler.NewContext("value", context)) + x.Value, err = NewServerVariable(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2440,7 +2464,7 @@ func NewNamedStringArray(in *yaml.Node, context *compiler.Context) (*NamedString v2 := compiler.MapValueForKey(m, "value") if v2 != nil { var err error - x.Value, err = NewStringArray(v2, compiler.NewContext("value", context)) + x.Value, err = NewStringArray(v2, compiler.NewContext("value", v2, context)) if err != nil { errors = append(errors, err) } @@ -2496,7 +2520,7 @@ func NewOauthFlow(in *yaml.Node, context *compiler.Context) (*OauthFlow, error) v4 := compiler.MapValueForKey(m, "scopes") if v4 != nil { var err error - x.Scopes, err = NewStrings(v4, compiler.NewContext("scopes", context)) + x.Scopes, err = NewStrings(v4, compiler.NewContext("scopes", v4, context)) if err != nil { errors = append(errors, err) } @@ -2523,7 +2547,7 @@ func NewOauthFlow(in *yaml.Node, context *compiler.Context) (*OauthFlow, error) pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -2556,7 +2580,7 @@ func NewOauthFlows(in *yaml.Node, context *compiler.Context) (*OauthFlows, error v1 := compiler.MapValueForKey(m, "implicit") if v1 != nil { var err error - x.Implicit, err = NewOauthFlow(v1, compiler.NewContext("implicit", context)) + x.Implicit, err = NewOauthFlow(v1, compiler.NewContext("implicit", v1, context)) if err != nil { errors = append(errors, err) } @@ -2565,7 +2589,7 @@ func NewOauthFlows(in *yaml.Node, context *compiler.Context) (*OauthFlows, error v2 := compiler.MapValueForKey(m, "password") if v2 != nil { var err error - x.Password, err = NewOauthFlow(v2, compiler.NewContext("password", context)) + x.Password, err = NewOauthFlow(v2, compiler.NewContext("password", v2, context)) if err != nil { errors = append(errors, err) } @@ -2574,7 +2598,7 @@ func NewOauthFlows(in *yaml.Node, context *compiler.Context) (*OauthFlows, error v3 := compiler.MapValueForKey(m, "clientCredentials") if v3 != nil { var err error - x.ClientCredentials, err = NewOauthFlow(v3, compiler.NewContext("clientCredentials", context)) + x.ClientCredentials, err = NewOauthFlow(v3, compiler.NewContext("clientCredentials", v3, context)) if err != nil { errors = append(errors, err) } @@ -2583,7 +2607,7 @@ func NewOauthFlows(in *yaml.Node, context *compiler.Context) (*OauthFlows, error v4 := compiler.MapValueForKey(m, "authorizationCode") if v4 != nil { var err error - x.AuthorizationCode, err = NewOauthFlow(v4, compiler.NewContext("authorizationCode", context)) + x.AuthorizationCode, err = NewOauthFlow(v4, compiler.NewContext("authorizationCode", v4, context)) if err != nil { errors = append(errors, err) } @@ -2610,7 +2634,7 @@ func NewOauthFlows(in *yaml.Node, context *compiler.Context) (*OauthFlows, error pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -2653,7 +2677,7 @@ func NewObject(in *yaml.Node, context *compiler.Context) (*Object, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -2720,7 +2744,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) v4 := compiler.MapValueForKey(m, "externalDocs") if v4 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v4, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v4, compiler.NewContext("externalDocs", v4, context)) if err != nil { errors = append(errors, err) } @@ -2742,7 +2766,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) a, ok := compiler.SequenceNodeForNode(v6) if ok { for _, item := range a.Content { - y, err := NewParameterOrReference(item, compiler.NewContext("parameters", context)) + y, err := NewParameterOrReference(item, compiler.NewContext("parameters", item, context)) if err != nil { errors = append(errors, err) } @@ -2754,7 +2778,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) v7 := compiler.MapValueForKey(m, "requestBody") if v7 != nil { var err error - x.RequestBody, err = NewRequestBodyOrReference(v7, compiler.NewContext("requestBody", context)) + x.RequestBody, err = NewRequestBodyOrReference(v7, compiler.NewContext("requestBody", v7, context)) if err != nil { errors = append(errors, err) } @@ -2763,7 +2787,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) v8 := compiler.MapValueForKey(m, "responses") if v8 != nil { var err error - x.Responses, err = NewResponses(v8, compiler.NewContext("responses", context)) + x.Responses, err = NewResponses(v8, compiler.NewContext("responses", v8, context)) if err != nil { errors = append(errors, err) } @@ -2772,7 +2796,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) v9 := compiler.MapValueForKey(m, "callbacks") if v9 != nil { var err error - x.Callbacks, err = NewCallbacksOrReferences(v9, compiler.NewContext("callbacks", context)) + x.Callbacks, err = NewCallbacksOrReferences(v9, compiler.NewContext("callbacks", v9, context)) if err != nil { errors = append(errors, err) } @@ -2794,7 +2818,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) a, ok := compiler.SequenceNodeForNode(v11) if ok { for _, item := range a.Content { - y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) + y, err := NewSecurityRequirement(item, compiler.NewContext("security", item, context)) if err != nil { errors = append(errors, err) } @@ -2810,7 +2834,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) a, ok := compiler.SequenceNodeForNode(v12) if ok { for _, item := range a.Content { - y, err := NewServer(item, compiler.NewContext("servers", context)) + y, err := NewServer(item, compiler.NewContext("servers", item, context)) if err != nil { errors = append(errors, err) } @@ -2840,7 +2864,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -2960,7 +2984,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) v10 := compiler.MapValueForKey(m, "schema") if v10 != nil { var err error - x.Schema, err = NewSchemaOrReference(v10, compiler.NewContext("schema", context)) + x.Schema, err = NewSchemaOrReference(v10, compiler.NewContext("schema", v10, context)) if err != nil { errors = append(errors, err) } @@ -2969,7 +2993,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) v11 := compiler.MapValueForKey(m, "example") if v11 != nil { var err error - x.Example, err = NewAny(v11, compiler.NewContext("example", context)) + x.Example, err = NewAny(v11, compiler.NewContext("example", v11, context)) if err != nil { errors = append(errors, err) } @@ -2978,7 +3002,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) v12 := compiler.MapValueForKey(m, "examples") if v12 != nil { var err error - x.Examples, err = NewExamplesOrReferences(v12, compiler.NewContext("examples", context)) + x.Examples, err = NewExamplesOrReferences(v12, compiler.NewContext("examples", v12, context)) if err != nil { errors = append(errors, err) } @@ -2987,7 +3011,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) v13 := compiler.MapValueForKey(m, "content") if v13 != nil { var err error - x.Content, err = NewMediaTypes(v13, compiler.NewContext("content", context)) + x.Content, err = NewMediaTypes(v13, compiler.NewContext("content", v13, context)) if err != nil { errors = append(errors, err) } @@ -3014,7 +3038,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3037,7 +3061,7 @@ func NewParameterOrReference(in *yaml.Node, context *compiler.Context) (*Paramet m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewParameter(m, compiler.NewContext("parameter", context)) + t, matchingError := NewParameter(m, compiler.NewContext("parameter", m, context)) if matchingError == nil { x.Oneof = &ParameterOrReference_Parameter{Parameter: t} matched = true @@ -3051,7 +3075,7 @@ func NewParameterOrReference(in *yaml.Node, context *compiler.Context) (*Paramet m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &ParameterOrReference_Reference{Reference: t} matched = true @@ -3063,6 +3087,10 @@ func NewParameterOrReference(in *yaml.Node, context *compiler.Context) (*Paramet if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid ParameterOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -3086,7 +3114,7 @@ func NewParametersOrReferences(in *yaml.Node, context *compiler.Context) (*Param pair := &NamedParameterOrReference{} pair.Name = k var err error - pair.Value, err = NewParameterOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewParameterOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3144,7 +3172,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v4 := compiler.MapValueForKey(m, "get") if v4 != nil { var err error - x.Get, err = NewOperation(v4, compiler.NewContext("get", context)) + x.Get, err = NewOperation(v4, compiler.NewContext("get", v4, context)) if err != nil { errors = append(errors, err) } @@ -3153,7 +3181,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v5 := compiler.MapValueForKey(m, "put") if v5 != nil { var err error - x.Put, err = NewOperation(v5, compiler.NewContext("put", context)) + x.Put, err = NewOperation(v5, compiler.NewContext("put", v5, context)) if err != nil { errors = append(errors, err) } @@ -3162,7 +3190,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v6 := compiler.MapValueForKey(m, "post") if v6 != nil { var err error - x.Post, err = NewOperation(v6, compiler.NewContext("post", context)) + x.Post, err = NewOperation(v6, compiler.NewContext("post", v6, context)) if err != nil { errors = append(errors, err) } @@ -3171,7 +3199,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v7 := compiler.MapValueForKey(m, "delete") if v7 != nil { var err error - x.Delete, err = NewOperation(v7, compiler.NewContext("delete", context)) + x.Delete, err = NewOperation(v7, compiler.NewContext("delete", v7, context)) if err != nil { errors = append(errors, err) } @@ -3180,7 +3208,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v8 := compiler.MapValueForKey(m, "options") if v8 != nil { var err error - x.Options, err = NewOperation(v8, compiler.NewContext("options", context)) + x.Options, err = NewOperation(v8, compiler.NewContext("options", v8, context)) if err != nil { errors = append(errors, err) } @@ -3189,7 +3217,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v9 := compiler.MapValueForKey(m, "head") if v9 != nil { var err error - x.Head, err = NewOperation(v9, compiler.NewContext("head", context)) + x.Head, err = NewOperation(v9, compiler.NewContext("head", v9, context)) if err != nil { errors = append(errors, err) } @@ -3198,7 +3226,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v10 := compiler.MapValueForKey(m, "patch") if v10 != nil { var err error - x.Patch, err = NewOperation(v10, compiler.NewContext("patch", context)) + x.Patch, err = NewOperation(v10, compiler.NewContext("patch", v10, context)) if err != nil { errors = append(errors, err) } @@ -3207,7 +3235,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { v11 := compiler.MapValueForKey(m, "trace") if v11 != nil { var err error - x.Trace, err = NewOperation(v11, compiler.NewContext("trace", context)) + x.Trace, err = NewOperation(v11, compiler.NewContext("trace", v11, context)) if err != nil { errors = append(errors, err) } @@ -3220,7 +3248,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { a, ok := compiler.SequenceNodeForNode(v12) if ok { for _, item := range a.Content { - y, err := NewServer(item, compiler.NewContext("servers", context)) + y, err := NewServer(item, compiler.NewContext("servers", item, context)) if err != nil { errors = append(errors, err) } @@ -3236,7 +3264,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { a, ok := compiler.SequenceNodeForNode(v13) if ok { for _, item := range a.Content { - y, err := NewParameterOrReference(item, compiler.NewContext("parameters", context)) + y, err := NewParameterOrReference(item, compiler.NewContext("parameters", item, context)) if err != nil { errors = append(errors, err) } @@ -3266,7 +3294,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3306,7 +3334,7 @@ func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { pair := &NamedPathItem{} pair.Name = k var err error - pair.Value, err = NewPathItem(v, compiler.NewContext(k, context)) + pair.Value, err = NewPathItem(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3336,7 +3364,7 @@ func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3368,7 +3396,7 @@ func NewProperties(in *yaml.Node, context *compiler.Context) (*Properties, error pair := &NamedSchemaOrReference{} pair.Name = k var err error - pair.Value, err = NewSchemaOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewSchemaOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3426,7 +3454,7 @@ func NewRequestBodiesOrReferences(in *yaml.Node, context *compiler.Context) (*Re pair := &NamedRequestBodyOrReference{} pair.Name = k var err error - pair.Value, err = NewRequestBodyOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewRequestBodyOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3472,7 +3500,7 @@ func NewRequestBody(in *yaml.Node, context *compiler.Context) (*RequestBody, err v2 := compiler.MapValueForKey(m, "content") if v2 != nil { var err error - x.Content, err = NewMediaTypes(v2, compiler.NewContext("content", context)) + x.Content, err = NewMediaTypes(v2, compiler.NewContext("content", v2, context)) if err != nil { errors = append(errors, err) } @@ -3508,7 +3536,7 @@ func NewRequestBody(in *yaml.Node, context *compiler.Context) (*RequestBody, err pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3531,7 +3559,7 @@ func NewRequestBodyOrReference(in *yaml.Node, context *compiler.Context) (*Reque m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewRequestBody(m, compiler.NewContext("requestBody", context)) + t, matchingError := NewRequestBody(m, compiler.NewContext("requestBody", m, context)) if matchingError == nil { x.Oneof = &RequestBodyOrReference_RequestBody{RequestBody: t} matched = true @@ -3545,7 +3573,7 @@ func NewRequestBodyOrReference(in *yaml.Node, context *compiler.Context) (*Reque m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &RequestBodyOrReference_Reference{Reference: t} matched = true @@ -3557,6 +3585,10 @@ func NewRequestBodyOrReference(in *yaml.Node, context *compiler.Context) (*Reque if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid RequestBodyOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -3596,7 +3628,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { v2 := compiler.MapValueForKey(m, "headers") if v2 != nil { var err error - x.Headers, err = NewHeadersOrReferences(v2, compiler.NewContext("headers", context)) + x.Headers, err = NewHeadersOrReferences(v2, compiler.NewContext("headers", v2, context)) if err != nil { errors = append(errors, err) } @@ -3605,7 +3637,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { v3 := compiler.MapValueForKey(m, "content") if v3 != nil { var err error - x.Content, err = NewMediaTypes(v3, compiler.NewContext("content", context)) + x.Content, err = NewMediaTypes(v3, compiler.NewContext("content", v3, context)) if err != nil { errors = append(errors, err) } @@ -3614,7 +3646,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { v4 := compiler.MapValueForKey(m, "links") if v4 != nil { var err error - x.Links, err = NewLinksOrReferences(v4, compiler.NewContext("links", context)) + x.Links, err = NewLinksOrReferences(v4, compiler.NewContext("links", v4, context)) if err != nil { errors = append(errors, err) } @@ -3641,7 +3673,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3664,7 +3696,7 @@ func NewResponseOrReference(in *yaml.Node, context *compiler.Context) (*Response m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewResponse(m, compiler.NewContext("response", context)) + t, matchingError := NewResponse(m, compiler.NewContext("response", m, context)) if matchingError == nil { x.Oneof = &ResponseOrReference_Response{Response: t} matched = true @@ -3678,7 +3710,7 @@ func NewResponseOrReference(in *yaml.Node, context *compiler.Context) (*Response m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &ResponseOrReference_Reference{Reference: t} matched = true @@ -3690,6 +3722,10 @@ func NewResponseOrReference(in *yaml.Node, context *compiler.Context) (*Response if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid ResponseOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -3714,7 +3750,7 @@ func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) v1 := compiler.MapValueForKey(m, "default") if v1 != nil { var err error - x.Default, err = NewResponseOrReference(v1, compiler.NewContext("default", context)) + x.Default, err = NewResponseOrReference(v1, compiler.NewContext("default", v1, context)) if err != nil { errors = append(errors, err) } @@ -3730,7 +3766,7 @@ func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) pair := &NamedResponseOrReference{} pair.Name = k var err error - pair.Value, err = NewResponseOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewResponseOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3760,7 +3796,7 @@ func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3792,7 +3828,7 @@ func NewResponsesOrReferences(in *yaml.Node, context *compiler.Context) (*Respon pair := &NamedResponseOrReference{} pair.Name = k var err error - pair.Value, err = NewResponseOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewResponseOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -3832,7 +3868,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v2 := compiler.MapValueForKey(m, "discriminator") if v2 != nil { var err error - x.Discriminator, err = NewDiscriminator(v2, compiler.NewContext("discriminator", context)) + x.Discriminator, err = NewDiscriminator(v2, compiler.NewContext("discriminator", v2, context)) if err != nil { errors = append(errors, err) } @@ -3859,7 +3895,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v5 := compiler.MapValueForKey(m, "xml") if v5 != nil { var err error - x.Xml, err = NewXml(v5, compiler.NewContext("xml", context)) + x.Xml, err = NewXml(v5, compiler.NewContext("xml", v5, context)) if err != nil { errors = append(errors, err) } @@ -3868,7 +3904,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v6 := compiler.MapValueForKey(m, "externalDocs") if v6 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v6, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v6, compiler.NewContext("externalDocs", v6, context)) if err != nil { errors = append(errors, err) } @@ -3877,7 +3913,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v7 := compiler.MapValueForKey(m, "example") if v7 != nil { var err error - x.Example, err = NewAny(v7, compiler.NewContext("example", context)) + x.Example, err = NewAny(v7, compiler.NewContext("example", v7, context)) if err != nil { errors = append(errors, err) } @@ -4054,7 +4090,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { a, ok := compiler.SequenceNodeForNode(v24) if ok { for _, item := range a.Content { - y, err := NewAny(item, compiler.NewContext("enum", context)) + y, err := NewAny(item, compiler.NewContext("enum", item, context)) if err != nil { errors = append(errors, err) } @@ -4079,7 +4115,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { a, ok := compiler.SequenceNodeForNode(v26) if ok { for _, item := range a.Content { - y, err := NewSchemaOrReference(item, compiler.NewContext("allOf", context)) + y, err := NewSchemaOrReference(item, compiler.NewContext("allOf", item, context)) if err != nil { errors = append(errors, err) } @@ -4095,7 +4131,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { a, ok := compiler.SequenceNodeForNode(v27) if ok { for _, item := range a.Content { - y, err := NewSchemaOrReference(item, compiler.NewContext("oneOf", context)) + y, err := NewSchemaOrReference(item, compiler.NewContext("oneOf", item, context)) if err != nil { errors = append(errors, err) } @@ -4111,7 +4147,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { a, ok := compiler.SequenceNodeForNode(v28) if ok { for _, item := range a.Content { - y, err := NewSchemaOrReference(item, compiler.NewContext("anyOf", context)) + y, err := NewSchemaOrReference(item, compiler.NewContext("anyOf", item, context)) if err != nil { errors = append(errors, err) } @@ -4123,7 +4159,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v29 := compiler.MapValueForKey(m, "not") if v29 != nil { var err error - x.Not, err = NewSchema(v29, compiler.NewContext("not", context)) + x.Not, err = NewSchema(v29, compiler.NewContext("not", v29, context)) if err != nil { errors = append(errors, err) } @@ -4132,7 +4168,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v30 := compiler.MapValueForKey(m, "items") if v30 != nil { var err error - x.Items, err = NewItemsItem(v30, compiler.NewContext("items", context)) + x.Items, err = NewItemsItem(v30, compiler.NewContext("items", v30, context)) if err != nil { errors = append(errors, err) } @@ -4141,7 +4177,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v31 := compiler.MapValueForKey(m, "properties") if v31 != nil { var err error - x.Properties, err = NewProperties(v31, compiler.NewContext("properties", context)) + x.Properties, err = NewProperties(v31, compiler.NewContext("properties", v31, context)) if err != nil { errors = append(errors, err) } @@ -4150,7 +4186,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v32 := compiler.MapValueForKey(m, "additionalProperties") if v32 != nil { var err error - x.AdditionalProperties, err = NewAdditionalPropertiesItem(v32, compiler.NewContext("additionalProperties", context)) + x.AdditionalProperties, err = NewAdditionalPropertiesItem(v32, compiler.NewContext("additionalProperties", v32, context)) if err != nil { errors = append(errors, err) } @@ -4159,7 +4195,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { v33 := compiler.MapValueForKey(m, "default") if v33 != nil { var err error - x.Default, err = NewDefaultType(v33, compiler.NewContext("default", context)) + x.Default, err = NewDefaultType(v33, compiler.NewContext("default", v33, context)) if err != nil { errors = append(errors, err) } @@ -4204,7 +4240,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4227,7 +4263,7 @@ func NewSchemaOrReference(in *yaml.Node, context *compiler.Context) (*SchemaOrRe m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewSchema(m, compiler.NewContext("schema", context)) + t, matchingError := NewSchema(m, compiler.NewContext("schema", m, context)) if matchingError == nil { x.Oneof = &SchemaOrReference_Schema{Schema: t} matched = true @@ -4241,7 +4277,7 @@ func NewSchemaOrReference(in *yaml.Node, context *compiler.Context) (*SchemaOrRe m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &SchemaOrReference_Reference{Reference: t} matched = true @@ -4253,6 +4289,10 @@ func NewSchemaOrReference(in *yaml.Node, context *compiler.Context) (*SchemaOrRe if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid SchemaOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -4276,7 +4316,7 @@ func NewSchemasOrReferences(in *yaml.Node, context *compiler.Context) (*SchemasO pair := &NamedSchemaOrReference{} pair.Name = k var err error - pair.Value, err = NewSchemaOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewSchemaOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4306,7 +4346,7 @@ func NewSecurityRequirement(in *yaml.Node, context *compiler.Context) (*Security pair := &NamedStringArray{} pair.Name = k var err error - pair.Value, err = NewStringArray(v, compiler.NewContext(k, context)) + pair.Value, err = NewStringArray(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4397,7 +4437,7 @@ func NewSecurityScheme(in *yaml.Node, context *compiler.Context) (*SecuritySchem v7 := compiler.MapValueForKey(m, "flows") if v7 != nil { var err error - x.Flows, err = NewOauthFlows(v7, compiler.NewContext("flows", context)) + x.Flows, err = NewOauthFlows(v7, compiler.NewContext("flows", v7, context)) if err != nil { errors = append(errors, err) } @@ -4433,7 +4473,7 @@ func NewSecurityScheme(in *yaml.Node, context *compiler.Context) (*SecuritySchem pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4456,7 +4496,7 @@ func NewSecuritySchemeOrReference(in *yaml.Node, context *compiler.Context) (*Se m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewSecurityScheme(m, compiler.NewContext("securityScheme", context)) + t, matchingError := NewSecurityScheme(m, compiler.NewContext("securityScheme", m, context)) if matchingError == nil { x.Oneof = &SecuritySchemeOrReference_SecurityScheme{SecurityScheme: t} matched = true @@ -4470,7 +4510,7 @@ func NewSecuritySchemeOrReference(in *yaml.Node, context *compiler.Context) (*Se m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matchingError := NewReference(m, compiler.NewContext("reference", context)) + t, matchingError := NewReference(m, compiler.NewContext("reference", m, context)) if matchingError == nil { x.Oneof = &SecuritySchemeOrReference_Reference{Reference: t} matched = true @@ -4482,6 +4522,10 @@ func NewSecuritySchemeOrReference(in *yaml.Node, context *compiler.Context) (*Se if matched { // since the oneof matched one of its possibilities, discard any matching errors errors = make([]error, 0) + } else { + message := fmt.Sprintf("contains an invalid SecuritySchemeOrReference") + err := compiler.NewError(context, message) + errors = []error{err} } return x, compiler.NewErrorGroupOrNil(errors) } @@ -4505,7 +4549,7 @@ func NewSecuritySchemesOrReferences(in *yaml.Node, context *compiler.Context) (* pair := &NamedSecuritySchemeOrReference{} pair.Name = k var err error - pair.Value, err = NewSecuritySchemeOrReference(v, compiler.NewContext(k, context)) + pair.Value, err = NewSecuritySchemeOrReference(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4560,7 +4604,7 @@ func NewServer(in *yaml.Node, context *compiler.Context) (*Server, error) { v3 := compiler.MapValueForKey(m, "variables") if v3 != nil { var err error - x.Variables, err = NewServerVariables(v3, compiler.NewContext("variables", context)) + x.Variables, err = NewServerVariables(v3, compiler.NewContext("variables", v3, context)) if err != nil { errors = append(errors, err) } @@ -4587,7 +4631,7 @@ func NewServer(in *yaml.Node, context *compiler.Context) (*Server, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4673,7 +4717,7 @@ func NewServerVariable(in *yaml.Node, context *compiler.Context) (*ServerVariabl pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4705,7 +4749,7 @@ func NewServerVariables(in *yaml.Node, context *compiler.Context) (*ServerVariab pair := &NamedServerVariable{} pair.Name = k var err error - pair.Value, err = NewServerVariable(v, compiler.NewContext(k, context)) + pair.Value, err = NewServerVariable(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4828,7 +4872,7 @@ func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { v3 := compiler.MapValueForKey(m, "externalDocs") if v3 != nil { var err error - x.ExternalDocs, err = NewExternalDocs(v3, compiler.NewContext("externalDocs", context)) + x.ExternalDocs, err = NewExternalDocs(v3, compiler.NewContext("externalDocs", v3, context)) if err != nil { errors = append(errors, err) } @@ -4855,7 +4899,7 @@ func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } @@ -4951,7 +4995,7 @@ func NewXml(in *yaml.Node, context *compiler.Context) (*Xml, error) { pair.Value = result } } else { - pair.Value, err = NewAny(v, compiler.NewContext(k, context)) + pair.Value, err = NewAny(v, compiler.NewContext(k, v, context)) if err != nil { errors = append(errors, err) } diff --git a/openapiv3/document.go b/openapiv3/document.go index 4d08e508..583a82ba 100644 --- a/openapiv3/document.go +++ b/openapiv3/document.go @@ -22,5 +22,6 @@ func ParseDocument(b []byte) (*Document, error) { if err != nil { return nil, err } - return NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, nil)) + root := info.Content[0] + return NewDocument(root, compiler.NewContextWithExtensions("$root", root, nil, nil)) } diff --git a/testdata/errors/petstore-badproperties.errors b/testdata/errors/petstore-badproperties.errors index 2fe38292..0b30245c 100644 --- a/testdata/errors/petstore-badproperties.errors +++ b/testdata/errors/petstore-badproperties.errors @@ -1,15 +1,5 @@ Errors reading examples/errors/petstore-badproperties.yaml -ERROR $root.info is missing required property: version -ERROR $root.info has invalid property: myproperty -ERROR $root.paths./pets.get.parameters.parameter.bodyParameter is missing required property: schema -ERROR $root.paths./pets.get.parameters.parameter.bodyParameter has invalid properties: type, format, myproperty -ERROR $root.paths./pets.get.parameters.parameter.bodyParameter has unexpected value for in: query (string) -ERROR $root.paths./pets.get.parameters.parameter.nonBodyParameter.headerParameterSubSchema has invalid property: myproperty -ERROR $root.paths./pets.get.parameters.parameter.nonBodyParameter.headerParameterSubSchema has unexpected value for in: query (string) -ERROR $root.paths./pets.get.parameters.parameter.nonBodyParameter.formDataParameterSubSchema has invalid property: myproperty -ERROR $root.paths./pets.get.parameters.parameter.nonBodyParameter.formDataParameterSubSchema has unexpected value for in: query (string) -ERROR $root.paths./pets.get.parameters.parameter.nonBodyParameter.queryParameterSubSchema has invalid property: myproperty -ERROR $root.paths./pets.get.parameters.parameter.nonBodyParameter.pathParameterSubSchema has invalid property: myproperty -ERROR $root.paths./pets.get.parameters.parameter.nonBodyParameter.pathParameterSubSchema has unexpected value for in: query (string) -ERROR $root.paths./pets.get.parameters.jsonReference is missing required property: $ref -ERROR $root.paths./pets.post has unexpected value for tags: pets (string) \ No newline at end of file +[3,3] $root.info is missing required property: version +[3,3] $root.info has invalid property: myproperty +[23,11] $root.paths./pets.get.parameters contains an invalid ParametersItem +[44,7] $root.paths./pets.post has unexpected value for tags: pets (string) \ No newline at end of file diff --git a/testdata/errors/petstore-unresolvedrefs.errors b/testdata/errors/petstore-unresolvedrefs.errors index dd8035b4..9a7203fa 100644 --- a/testdata/errors/petstore-unresolvedrefs.errors +++ b/testdata/errors/petstore-unresolvedrefs.errors @@ -1,3 +1,3 @@ Errors reading examples/errors/petstore-unresolvedrefs.yaml -ERROR could not resolve #/definitions/Pet -ERROR could not resolve #/definitions/Error \ No newline at end of file +could not resolve #/definitions/Pet +could not resolve #/definitions/Error \ No newline at end of file