From 7a458730d7d3eca8ee66ee6ce299aa978f2f09a4 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Mon, 31 Jul 2017 01:24:19 -0400 Subject: [PATCH] bump(github.com/googleapis/gnostic):0c5108395e2de Pick up performance improvements to OpenAPI serialization. --- Godeps/Godeps.json | 6 +- .../Godeps/Godeps.json | 6 +- .../src/k8s.io/apiserver/Godeps/Godeps.json | 6 +- .../src/k8s.io/client-go/Godeps/Godeps.json | 6 +- .../k8s.io/kube-aggregator/Godeps/Godeps.json | 6 +- .../src/k8s.io/kube-gen/Godeps/Godeps.json | 6 +- staging/src/k8s.io/metrics/Godeps/Godeps.json | 6 +- .../sample-apiserver/Godeps/Godeps.json | 6 +- .../googleapis/gnostic/OpenAPIv2/OpenAPIv2.go | 2112 +++++++++++++++-- .../gnostic/OpenAPIv2/OpenAPIv2.pb.go | 10 +- .../googleapis/gnostic/compiler/context.go | 10 +- .../googleapis/gnostic/compiler/error.go | 12 +- .../gnostic/compiler/extension-handler.go | 4 +- .../googleapis/gnostic/compiler/helpers.go | 70 +- .../googleapis/gnostic/compiler/reader.go | 116 +- .../googleapis/gnostic/extensions/BUILD | 1 - .../gnostic/extensions/COMPILE-EXTENSION.sh | 2 - .../gnostic/extensions/extensions.go | 23 +- 18 files changed, 2099 insertions(+), 309 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index d676d14092..d3e35f3b68 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1565,15 +1565,15 @@ }, { "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/gophercloud/gophercloud", diff --git a/staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json b/staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json index 5548e34b26..8a986fdaab 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json +++ b/staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json @@ -168,15 +168,15 @@ }, { "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/grpc-ecosystem/go-grpc-prometheus", diff --git a/staging/src/k8s.io/apiserver/Godeps/Godeps.json b/staging/src/k8s.io/apiserver/Godeps/Godeps.json index 6fc05270be..db67313a31 100644 --- a/staging/src/k8s.io/apiserver/Godeps/Godeps.json +++ b/staging/src/k8s.io/apiserver/Godeps/Godeps.json @@ -392,15 +392,15 @@ }, { "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/gophercloud/gophercloud", diff --git a/staging/src/k8s.io/client-go/Godeps/Godeps.json b/staging/src/k8s.io/client-go/Godeps/Godeps.json index cc8a4d68b4..02f6aaca9c 100644 --- a/staging/src/k8s.io/client-go/Godeps/Godeps.json +++ b/staging/src/k8s.io/client-go/Godeps/Godeps.json @@ -160,15 +160,15 @@ }, { "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/hashicorp/golang-lru", diff --git a/staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json b/staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json index aa29e81b99..f82fedab3b 100644 --- a/staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json +++ b/staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json @@ -176,15 +176,15 @@ }, { "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/grpc-ecosystem/go-grpc-prometheus", diff --git a/staging/src/k8s.io/kube-gen/Godeps/Godeps.json b/staging/src/k8s.io/kube-gen/Godeps/Godeps.json index 54028264e4..313bba759e 100644 --- a/staging/src/k8s.io/kube-gen/Godeps/Godeps.json +++ b/staging/src/k8s.io/kube-gen/Godeps/Godeps.json @@ -180,15 +180,15 @@ }, { "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/juju/ratelimit", diff --git a/staging/src/k8s.io/metrics/Godeps/Godeps.json b/staging/src/k8s.io/metrics/Godeps/Godeps.json index fd0580ef32..84161570f6 100644 --- a/staging/src/k8s.io/metrics/Godeps/Godeps.json +++ b/staging/src/k8s.io/metrics/Godeps/Godeps.json @@ -88,15 +88,15 @@ }, { "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/juju/ratelimit", diff --git a/staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json b/staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json index cb9378e42a..9ece9c5d8a 100644 --- a/staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json +++ b/staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json @@ -168,15 +168,15 @@ }, { "ImportPath": "github.com/googleapis/gnostic/OpenAPIv2", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/compiler", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/googleapis/gnostic/extensions", - "Rev": "68f4ded48ba9414dab2ae69b3f0d69971da73aa5" + "Rev": "0c5108395e2debce0d731cf0287ddf7242066aba" }, { "ImportPath": "github.com/grpc-ecosystem/go-grpc-prometheus", diff --git a/vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go b/vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go index dc431e1ecb..0e32451a32 100644 --- a/vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go +++ b/vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go @@ -20,13 +20,16 @@ import ( "fmt" "github.com/googleapis/gnostic/compiler" "gopkg.in/yaml.v2" + "regexp" "strings" ) +// Version returns the package name (and OpenAPI version). func Version() string { return "openapi_v2" } +// NewAdditionalPropertiesItem creates an object of type AdditionalPropertiesItem if possible, returning an error if not. func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*AdditionalPropertiesItem, error) { errors := make([]error, 0) x := &AdditionalPropertiesItem{} @@ -36,12 +39,12 @@ func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*Ad m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewSchema(m, compiler.NewContext("schema", context)) - if matching_error == nil { + t, matchingError := NewSchema(m, compiler.NewContext("schema", context)) + if matchingError == nil { x.Oneof = &AdditionalPropertiesItem_Schema{Schema: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -57,6 +60,7 @@ func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*Ad return x, compiler.NewErrorGroupOrNil(errors) } +// NewAny creates an object of type Any if possible, returning an error if not. func NewAny(in interface{}, context *compiler.Context) (*Any, error) { errors := make([]error, 0) x := &Any{} @@ -65,6 +69,7 @@ func NewAny(in interface{}, context *compiler.Context) (*Any, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewApiKeySecurity creates an object of type ApiKeySecurity if possible, returning an error if not. func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecurity, error) { errors := make([]error, 0) x := &ApiKeySecurity{} @@ -80,7 +85,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"description", "in", "name", "type"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -138,10 +143,10 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -169,6 +174,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri return x, compiler.NewErrorGroupOrNil(errors) } +// NewBasicAuthenticationSecurity creates an object of type BasicAuthenticationSecurity if possible, returning an error if not. func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) (*BasicAuthenticationSecurity, error) { errors := make([]error, 0) x := &BasicAuthenticationSecurity{} @@ -184,7 +190,7 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"description", "type"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -218,10 +224,10 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -249,6 +255,7 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( return x, compiler.NewErrorGroupOrNil(errors) } +// NewBodyParameter creates an object of type BodyParameter if possible, returning an error if not. func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter, error) { errors := make([]error, 0) x := &BodyParameter{} @@ -264,7 +271,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"description", "in", "name", "required", "schema"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -325,10 +332,10 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -356,6 +363,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter return x, compiler.NewErrorGroupOrNil(errors) } +// NewContact creates an object of type Contact if possible, returning an error if not. func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { errors := make([]error, 0) x := &Contact{} @@ -365,7 +373,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"email", "name", "url"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -402,10 +410,10 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -433,6 +441,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewDefault creates an object of type Default if possible, returning an error if not. func NewDefault(in interface{}, context *compiler.Context) (*Default, error) { errors := make([]error, 0) x := &Default{} @@ -445,7 +454,7 @@ func NewDefault(in interface{}, context *compiler.Context) (*Default, error) { // MAP: Any x.AdditionalProperties = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedAny{} @@ -474,6 +483,7 @@ func NewDefault(in interface{}, context *compiler.Context) (*Default, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewDefinitions creates an object of type Definitions if possible, returning an error if not. func NewDefinitions(in interface{}, context *compiler.Context) (*Definitions, error) { errors := make([]error, 0) x := &Definitions{} @@ -486,7 +496,7 @@ func NewDefinitions(in interface{}, context *compiler.Context) (*Definitions, er // MAP: Schema x.AdditionalProperties = make([]*NamedSchema, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedSchema{} @@ -503,6 +513,7 @@ func NewDefinitions(in interface{}, context *compiler.Context) (*Definitions, er return x, compiler.NewErrorGroupOrNil(errors) } +// NewDocument creates an object of type Document if possible, returning an error if not. func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { errors := make([]error, 0) x := &Document{} @@ -518,7 +529,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"basePath", "consumes", "definitions", "externalDocs", "host", "info", "parameters", "paths", "produces", "responses", "schemes", "security", "securityDefinitions", "swagger", "tags"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -695,10 +706,10 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -726,6 +737,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewExamples creates an object of type Examples if possible, returning an error if not. func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) { errors := make([]error, 0) x := &Examples{} @@ -738,7 +750,7 @@ func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) { // MAP: Any x.AdditionalProperties = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedAny{} @@ -767,6 +779,7 @@ func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewExternalDocs creates an object of type ExternalDocs if possible, returning an error if not. func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, error) { errors := make([]error, 0) x := &ExternalDocs{} @@ -782,7 +795,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"description", "url"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -810,10 +823,10 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -841,6 +854,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, return x, compiler.NewErrorGroupOrNil(errors) } +// NewFileSchema creates an object of type FileSchema if possible, returning an error if not. func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, error) { errors := make([]error, 0) x := &FileSchema{} @@ -856,7 +870,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"default", "description", "example", "externalDocs", "format", "readOnly", "required", "title", "type"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -955,10 +969,10 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -986,6 +1000,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro return x, compiler.NewErrorGroupOrNil(errors) } +// NewFormDataParameterSubSchema creates an object of type FormDataParameterSubSchema if possible, returning an error if not. func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (*FormDataParameterSubSchema, error) { errors := make([]error, 0) x := &FormDataParameterSubSchema{} @@ -995,7 +1010,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"allowEmptyValue", "collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -1278,10 +1293,10 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -1309,6 +1324,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* return x, compiler.NewErrorGroupOrNil(errors) } +// NewHeader creates an object of type Header if possible, returning an error if not. func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { errors := make([]error, 0) x := &Header{} @@ -1324,7 +1340,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "pattern", "type", "uniqueItems"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -1565,10 +1581,10 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -1596,6 +1612,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewHeaderParameterSubSchema creates an object of type HeaderParameterSubSchema if possible, returning an error if not. func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*HeaderParameterSubSchema, error) { errors := make([]error, 0) x := &HeaderParameterSubSchema{} @@ -1605,7 +1622,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -1879,10 +1896,10 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -1910,6 +1927,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He return x, compiler.NewErrorGroupOrNil(errors) } +// NewHeaders creates an object of type Headers if possible, returning an error if not. func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) { errors := make([]error, 0) x := &Headers{} @@ -1922,7 +1940,7 @@ func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) { // MAP: Header x.AdditionalProperties = make([]*NamedHeader, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedHeader{} @@ -1939,6 +1957,7 @@ func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewInfo creates an object of type Info if possible, returning an error if not. func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { errors := make([]error, 0) x := &Info{} @@ -1954,7 +1973,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"contact", "description", "license", "termsOfService", "title", "version"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2018,10 +2037,10 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -2049,6 +2068,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewItemsItem creates an object of type ItemsItem if possible, returning an error if not. func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) { errors := make([]error, 0) x := &ItemsItem{} @@ -2067,6 +2087,7 @@ func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) return x, compiler.NewErrorGroupOrNil(errors) } +// NewJsonReference creates an object of type JsonReference if possible, returning an error if not. func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference, error) { errors := make([]error, 0) x := &JsonReference{} @@ -2082,7 +2103,7 @@ func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"$ref", "description"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2110,6 +2131,7 @@ func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference return x, compiler.NewErrorGroupOrNil(errors) } +// NewLicense creates an object of type License if possible, returning an error if not. func NewLicense(in interface{}, context *compiler.Context) (*License, error) { errors := make([]error, 0) x := &License{} @@ -2125,7 +2147,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"name", "url"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2153,10 +2175,10 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -2184,6 +2206,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedAny creates an object of type NamedAny if possible, returning an error if not. func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { errors := make([]error, 0) x := &NamedAny{} @@ -2193,7 +2216,7 @@ func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2221,6 +2244,7 @@ func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedHeader creates an object of type NamedHeader if possible, returning an error if not. func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, error) { errors := make([]error, 0) x := &NamedHeader{} @@ -2230,7 +2254,7 @@ func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, er errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2258,6 +2282,7 @@ func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, er return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedParameter creates an object of type NamedParameter if possible, returning an error if not. func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParameter, error) { errors := make([]error, 0) x := &NamedParameter{} @@ -2267,7 +2292,7 @@ func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParamet errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2295,6 +2320,7 @@ func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParamet return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedPathItem creates an object of type NamedPathItem if possible, returning an error if not. func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem, error) { errors := make([]error, 0) x := &NamedPathItem{} @@ -2304,7 +2330,7 @@ func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2332,6 +2358,7 @@ func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedResponse creates an object of type NamedResponse if possible, returning an error if not. func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse, error) { errors := make([]error, 0) x := &NamedResponse{} @@ -2341,7 +2368,7 @@ func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2369,6 +2396,7 @@ func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedResponseValue creates an object of type NamedResponseValue if possible, returning an error if not. func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedResponseValue, error) { errors := make([]error, 0) x := &NamedResponseValue{} @@ -2378,7 +2406,7 @@ func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedRes errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2406,6 +2434,7 @@ func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedRes return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedSchema creates an object of type NamedSchema if possible, returning an error if not. func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, error) { errors := make([]error, 0) x := &NamedSchema{} @@ -2415,7 +2444,7 @@ func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, er errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2443,6 +2472,7 @@ func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, er return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedSecurityDefinitionsItem creates an object of type NamedSecurityDefinitionsItem if possible, returning an error if not. func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*NamedSecurityDefinitionsItem, error) { errors := make([]error, 0) x := &NamedSecurityDefinitionsItem{} @@ -2452,7 +2482,7 @@ func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2480,6 +2510,7 @@ func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedString creates an object of type NamedString if possible, returning an error if not. func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, error) { errors := make([]error, 0) x := &NamedString{} @@ -2489,7 +2520,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2517,6 +2548,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er return x, compiler.NewErrorGroupOrNil(errors) } +// NewNamedStringArray creates an object of type NamedStringArray if possible, returning an error if not. func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStringArray, error) { errors := make([]error, 0) x := &NamedStringArray{} @@ -2526,7 +2558,7 @@ func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStrin errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"name", "value"} - allowedPatterns := []string{} + var allowedPatterns []*regexp.Regexp invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2554,6 +2586,7 @@ func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStrin return x, compiler.NewErrorGroupOrNil(errors) } +// NewNonBodyParameter creates an object of type NonBodyParameter if possible, returning an error if not. func NewNonBodyParameter(in interface{}, context *compiler.Context) (*NonBodyParameter, error) { errors := make([]error, 0) x := &NonBodyParameter{} @@ -2572,45 +2605,45 @@ func NewNonBodyParameter(in interface{}, context *compiler.Context) (*NonBodyPar // HeaderParameterSubSchema header_parameter_sub_schema = 1; { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewHeaderParameterSubSchema(m, compiler.NewContext("headerParameterSubSchema", context)) - if matching_error == nil { + t, matchingError := NewHeaderParameterSubSchema(m, compiler.NewContext("headerParameterSubSchema", context)) + if matchingError == nil { x.Oneof = &NonBodyParameter_HeaderParameterSubSchema{HeaderParameterSubSchema: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } // FormDataParameterSubSchema form_data_parameter_sub_schema = 2; { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewFormDataParameterSubSchema(m, compiler.NewContext("formDataParameterSubSchema", context)) - if matching_error == nil { + t, matchingError := NewFormDataParameterSubSchema(m, compiler.NewContext("formDataParameterSubSchema", context)) + if matchingError == nil { x.Oneof = &NonBodyParameter_FormDataParameterSubSchema{FormDataParameterSubSchema: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } // QueryParameterSubSchema query_parameter_sub_schema = 3; { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewQueryParameterSubSchema(m, compiler.NewContext("queryParameterSubSchema", context)) - if matching_error == nil { + t, matchingError := NewQueryParameterSubSchema(m, compiler.NewContext("queryParameterSubSchema", context)) + if matchingError == nil { x.Oneof = &NonBodyParameter_QueryParameterSubSchema{QueryParameterSubSchema: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } // PathParameterSubSchema path_parameter_sub_schema = 4; { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewPathParameterSubSchema(m, compiler.NewContext("pathParameterSubSchema", context)) - if matching_error == nil { + t, matchingError := NewPathParameterSubSchema(m, compiler.NewContext("pathParameterSubSchema", context)) + if matchingError == nil { x.Oneof = &NonBodyParameter_PathParameterSubSchema{PathParameterSubSchema: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -2621,6 +2654,7 @@ func NewNonBodyParameter(in interface{}, context *compiler.Context) (*NonBodyPar return x, compiler.NewErrorGroupOrNil(errors) } +// NewOauth2AccessCodeSecurity creates an object of type Oauth2AccessCodeSecurity if possible, returning an error if not. func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oauth2AccessCodeSecurity, error) { errors := make([]error, 0) x := &Oauth2AccessCodeSecurity{} @@ -2636,7 +2670,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"authorizationUrl", "description", "flow", "scopes", "tokenUrl", "type"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2712,10 +2746,10 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -2743,6 +2777,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa return x, compiler.NewErrorGroupOrNil(errors) } +// NewOauth2ApplicationSecurity creates an object of type Oauth2ApplicationSecurity if possible, returning an error if not. func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*Oauth2ApplicationSecurity, error) { errors := make([]error, 0) x := &Oauth2ApplicationSecurity{} @@ -2758,7 +2793,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"description", "flow", "scopes", "tokenUrl", "type"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2825,10 +2860,10 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -2856,6 +2891,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O return x, compiler.NewErrorGroupOrNil(errors) } +// NewOauth2ImplicitSecurity creates an object of type Oauth2ImplicitSecurity if possible, returning an error if not. func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oauth2ImplicitSecurity, error) { errors := make([]error, 0) x := &Oauth2ImplicitSecurity{} @@ -2871,7 +2907,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"authorizationUrl", "description", "flow", "scopes", "type"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -2938,10 +2974,10 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -2969,6 +3005,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut return x, compiler.NewErrorGroupOrNil(errors) } +// NewOauth2PasswordSecurity creates an object of type Oauth2PasswordSecurity if possible, returning an error if not. func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oauth2PasswordSecurity, error) { errors := make([]error, 0) x := &Oauth2PasswordSecurity{} @@ -2984,7 +3021,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"description", "flow", "scopes", "tokenUrl", "type"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -3051,10 +3088,10 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -3082,6 +3119,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut return x, compiler.NewErrorGroupOrNil(errors) } +// NewOauth2Scopes creates an object of type Oauth2Scopes if possible, returning an error if not. func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, error) { errors := make([]error, 0) x := &Oauth2Scopes{} @@ -3094,7 +3132,7 @@ func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, // MAP: string x.AdditionalProperties = make([]*NamedString, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedString{} @@ -3107,6 +3145,7 @@ func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, return x, compiler.NewErrorGroupOrNil(errors) } +// NewOperation creates an object of type Operation if possible, returning an error if not. func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) { errors := make([]error, 0) x := &Operation{} @@ -3122,7 +3161,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"consumes", "deprecated", "description", "externalDocs", "operationId", "parameters", "produces", "responses", "schemes", "security", "summary", "tags"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -3268,10 +3307,10 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -3299,6 +3338,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) return x, compiler.NewErrorGroupOrNil(errors) } +// NewParameter creates an object of type Parameter if possible, returning an error if not. func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) { errors := make([]error, 0) x := &Parameter{} @@ -3308,12 +3348,12 @@ func NewParameter(in interface{}, 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, matching_error := NewBodyParameter(m, compiler.NewContext("bodyParameter", context)) - if matching_error == nil { + t, matchingError := NewBodyParameter(m, compiler.NewContext("bodyParameter", context)) + if matchingError == nil { x.Oneof = &Parameter_BodyParameter{BodyParameter: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -3322,12 +3362,12 @@ func NewParameter(in interface{}, 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, matching_error := NewNonBodyParameter(m, compiler.NewContext("nonBodyParameter", context)) - if matching_error == nil { + t, matchingError := NewNonBodyParameter(m, compiler.NewContext("nonBodyParameter", context)) + if matchingError == nil { x.Oneof = &Parameter_NonBodyParameter{NonBodyParameter: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -3338,6 +3378,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) return x, compiler.NewErrorGroupOrNil(errors) } +// NewParameterDefinitions creates an object of type ParameterDefinitions if possible, returning an error if not. func NewParameterDefinitions(in interface{}, context *compiler.Context) (*ParameterDefinitions, error) { errors := make([]error, 0) x := &ParameterDefinitions{} @@ -3350,7 +3391,7 @@ func NewParameterDefinitions(in interface{}, context *compiler.Context) (*Parame // MAP: Parameter x.AdditionalProperties = make([]*NamedParameter, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedParameter{} @@ -3367,6 +3408,7 @@ func NewParameterDefinitions(in interface{}, context *compiler.Context) (*Parame return x, compiler.NewErrorGroupOrNil(errors) } +// NewParametersItem creates an object of type ParametersItem if possible, returning an error if not. func NewParametersItem(in interface{}, context *compiler.Context) (*ParametersItem, error) { errors := make([]error, 0) x := &ParametersItem{} @@ -3376,12 +3418,12 @@ func NewParametersItem(in interface{}, context *compiler.Context) (*ParametersIt m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewParameter(m, compiler.NewContext("parameter", context)) - if matching_error == nil { + t, matchingError := NewParameter(m, compiler.NewContext("parameter", context)) + if matchingError == nil { x.Oneof = &ParametersItem_Parameter{Parameter: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -3390,12 +3432,12 @@ func NewParametersItem(in interface{}, context *compiler.Context) (*ParametersIt m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewJsonReference(m, compiler.NewContext("jsonReference", context)) - if matching_error == nil { + t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", context)) + if matchingError == nil { x.Oneof = &ParametersItem_JsonReference{JsonReference: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -3406,6 +3448,7 @@ func NewParametersItem(in interface{}, context *compiler.Context) (*ParametersIt return x, compiler.NewErrorGroupOrNil(errors) } +// NewPathItem creates an object of type PathItem if possible, returning an error if not. func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { errors := make([]error, 0) x := &PathItem{} @@ -3415,7 +3458,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"$ref", "delete", "get", "head", "options", "parameters", "patch", "post", "put"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -3513,10 +3556,10 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -3544,6 +3587,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewPathParameterSubSchema creates an object of type PathParameterSubSchema if possible, returning an error if not. func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*PathParameterSubSchema, error) { errors := make([]error, 0) x := &PathParameterSubSchema{} @@ -3559,7 +3603,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -3833,10 +3877,10 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -3864,6 +3908,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path return x, compiler.NewErrorGroupOrNil(errors) } +// NewPaths creates an object of type Paths if possible, returning an error if not. func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { errors := make([]error, 0) x := &Paths{} @@ -3873,7 +3918,7 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{} - allowedPatterns := []string{"^x-", "^/"} + allowedPatterns := []*regexp.Regexp{pattern0, pattern1} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -3883,10 +3928,10 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -3914,10 +3959,10 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { // MAP: PathItem ^/ x.Path = make([]*NamedPathItem, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^/", k) { + if strings.HasPrefix(k, "/") { pair := &NamedPathItem{} pair.Name = k var err error @@ -3933,6 +3978,7 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewPrimitivesItems creates an object of type PrimitivesItems if possible, returning an error if not. func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesItems, error) { errors := make([]error, 0) x := &PrimitivesItems{} @@ -3942,7 +3988,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"collectionFormat", "default", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "pattern", "type", "uniqueItems"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -4174,10 +4220,10 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -4205,6 +4251,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI return x, compiler.NewErrorGroupOrNil(errors) } +// NewProperties creates an object of type Properties if possible, returning an error if not. func NewProperties(in interface{}, context *compiler.Context) (*Properties, error) { errors := make([]error, 0) x := &Properties{} @@ -4217,7 +4264,7 @@ func NewProperties(in interface{}, context *compiler.Context) (*Properties, erro // MAP: Schema x.AdditionalProperties = make([]*NamedSchema, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedSchema{} @@ -4234,6 +4281,7 @@ func NewProperties(in interface{}, context *compiler.Context) (*Properties, erro return x, compiler.NewErrorGroupOrNil(errors) } +// NewQueryParameterSubSchema creates an object of type QueryParameterSubSchema if possible, returning an error if not. func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*QueryParameterSubSchema, error) { errors := make([]error, 0) x := &QueryParameterSubSchema{} @@ -4243,7 +4291,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"allowEmptyValue", "collectionFormat", "default", "description", "enum", "exclusiveMaximum", "exclusiveMinimum", "format", "in", "items", "maxItems", "maxLength", "maximum", "minItems", "minLength", "minimum", "multipleOf", "name", "pattern", "required", "type", "uniqueItems"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -4526,10 +4574,10 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -4557,6 +4605,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que return x, compiler.NewErrorGroupOrNil(errors) } +// NewResponse creates an object of type Response if possible, returning an error if not. func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { errors := make([]error, 0) x := &Response{} @@ -4572,7 +4621,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"description", "examples", "headers", "schema"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -4618,10 +4667,10 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -4649,6 +4698,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewResponseDefinitions creates an object of type ResponseDefinitions if possible, returning an error if not. func NewResponseDefinitions(in interface{}, context *compiler.Context) (*ResponseDefinitions, error) { errors := make([]error, 0) x := &ResponseDefinitions{} @@ -4661,7 +4711,7 @@ func NewResponseDefinitions(in interface{}, context *compiler.Context) (*Respons // MAP: Response x.AdditionalProperties = make([]*NamedResponse, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedResponse{} @@ -4678,6 +4728,7 @@ func NewResponseDefinitions(in interface{}, context *compiler.Context) (*Respons return x, compiler.NewErrorGroupOrNil(errors) } +// NewResponseValue creates an object of type ResponseValue if possible, returning an error if not. func NewResponseValue(in interface{}, context *compiler.Context) (*ResponseValue, error) { errors := make([]error, 0) x := &ResponseValue{} @@ -4687,12 +4738,12 @@ func NewResponseValue(in interface{}, 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, matching_error := NewResponse(m, compiler.NewContext("response", context)) - if matching_error == nil { + t, matchingError := NewResponse(m, compiler.NewContext("response", context)) + if matchingError == nil { x.Oneof = &ResponseValue_Response{Response: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -4701,12 +4752,12 @@ func NewResponseValue(in interface{}, 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, matching_error := NewJsonReference(m, compiler.NewContext("jsonReference", context)) - if matching_error == nil { + t, matchingError := NewJsonReference(m, compiler.NewContext("jsonReference", context)) + if matchingError == nil { x.Oneof = &ResponseValue_JsonReference{JsonReference: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -4717,6 +4768,7 @@ func NewResponseValue(in interface{}, context *compiler.Context) (*ResponseValue return x, compiler.NewErrorGroupOrNil(errors) } +// NewResponses creates an object of type Responses if possible, returning an error if not. func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) { errors := make([]error, 0) x := &Responses{} @@ -4726,7 +4778,7 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{} - allowedPatterns := []string{"^([0-9]{3})$|^(default)$", "^x-"} + allowedPatterns := []*regexp.Regexp{pattern2, pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -4736,10 +4788,10 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) // MAP: ResponseValue ^([0-9]{3})$|^(default)$ x.ResponseCode = make([]*NamedResponseValue, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^([0-9]{3})$|^(default)$", k) { + if pattern2.MatchString(k) { pair := &NamedResponseValue{} pair.Name = k var err error @@ -4755,10 +4807,10 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -4786,6 +4838,7 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) return x, compiler.NewErrorGroupOrNil(errors) } +// NewSchema creates an object of type Schema if possible, returning an error if not. func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { errors := make([]error, 0) x := &Schema{} @@ -4795,7 +4848,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"$ref", "additionalProperties", "allOf", "default", "description", "discriminator", "enum", "example", "exclusiveMaximum", "exclusiveMinimum", "externalDocs", "format", "items", "maxItems", "maxLength", "maxProperties", "maximum", "minItems", "minLength", "minProperties", "minimum", "multipleOf", "pattern", "properties", "readOnly", "required", "title", "type", "uniqueItems", "xml"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -5145,10 +5198,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -5176,6 +5229,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewSchemaItem creates an object of type SchemaItem if possible, returning an error if not. func NewSchemaItem(in interface{}, context *compiler.Context) (*SchemaItem, error) { errors := make([]error, 0) x := &SchemaItem{} @@ -5185,12 +5239,12 @@ func NewSchemaItem(in interface{}, context *compiler.Context) (*SchemaItem, erro m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewSchema(m, compiler.NewContext("schema", context)) - if matching_error == nil { + t, matchingError := NewSchema(m, compiler.NewContext("schema", context)) + if matchingError == nil { x.Oneof = &SchemaItem_Schema{Schema: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -5199,12 +5253,12 @@ func NewSchemaItem(in interface{}, context *compiler.Context) (*SchemaItem, erro m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewFileSchema(m, compiler.NewContext("fileSchema", context)) - if matching_error == nil { + t, matchingError := NewFileSchema(m, compiler.NewContext("fileSchema", context)) + if matchingError == nil { x.Oneof = &SchemaItem_FileSchema{FileSchema: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -5215,6 +5269,7 @@ func NewSchemaItem(in interface{}, context *compiler.Context) (*SchemaItem, erro return x, compiler.NewErrorGroupOrNil(errors) } +// NewSecurityDefinitions creates an object of type SecurityDefinitions if possible, returning an error if not. func NewSecurityDefinitions(in interface{}, context *compiler.Context) (*SecurityDefinitions, error) { errors := make([]error, 0) x := &SecurityDefinitions{} @@ -5227,7 +5282,7 @@ func NewSecurityDefinitions(in interface{}, context *compiler.Context) (*Securit // MAP: SecurityDefinitionsItem x.AdditionalProperties = make([]*NamedSecurityDefinitionsItem, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedSecurityDefinitionsItem{} @@ -5244,6 +5299,7 @@ func NewSecurityDefinitions(in interface{}, context *compiler.Context) (*Securit return x, compiler.NewErrorGroupOrNil(errors) } +// NewSecurityDefinitionsItem creates an object of type SecurityDefinitionsItem if possible, returning an error if not. func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*SecurityDefinitionsItem, error) { errors := make([]error, 0) x := &SecurityDefinitionsItem{} @@ -5253,12 +5309,12 @@ func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*Sec m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewBasicAuthenticationSecurity(m, compiler.NewContext("basicAuthenticationSecurity", context)) - if matching_error == nil { + t, matchingError := NewBasicAuthenticationSecurity(m, compiler.NewContext("basicAuthenticationSecurity", context)) + if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_BasicAuthenticationSecurity{BasicAuthenticationSecurity: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -5267,12 +5323,12 @@ func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*Sec m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewApiKeySecurity(m, compiler.NewContext("apiKeySecurity", context)) - if matching_error == nil { + t, matchingError := NewApiKeySecurity(m, compiler.NewContext("apiKeySecurity", context)) + if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_ApiKeySecurity{ApiKeySecurity: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -5281,12 +5337,12 @@ func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*Sec m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewOauth2ImplicitSecurity(m, compiler.NewContext("oauth2ImplicitSecurity", context)) - if matching_error == nil { + t, matchingError := NewOauth2ImplicitSecurity(m, compiler.NewContext("oauth2ImplicitSecurity", context)) + if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_Oauth2ImplicitSecurity{Oauth2ImplicitSecurity: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -5295,12 +5351,12 @@ func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*Sec m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewOauth2PasswordSecurity(m, compiler.NewContext("oauth2PasswordSecurity", context)) - if matching_error == nil { + t, matchingError := NewOauth2PasswordSecurity(m, compiler.NewContext("oauth2PasswordSecurity", context)) + if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_Oauth2PasswordSecurity{Oauth2PasswordSecurity: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -5309,12 +5365,12 @@ func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*Sec m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewOauth2ApplicationSecurity(m, compiler.NewContext("oauth2ApplicationSecurity", context)) - if matching_error == nil { + t, matchingError := NewOauth2ApplicationSecurity(m, compiler.NewContext("oauth2ApplicationSecurity", context)) + if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_Oauth2ApplicationSecurity{Oauth2ApplicationSecurity: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -5323,12 +5379,12 @@ func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*Sec m, ok := compiler.UnpackMap(in) if ok { // errors might be ok here, they mean we just don't have the right subtype - t, matching_error := NewOauth2AccessCodeSecurity(m, compiler.NewContext("oauth2AccessCodeSecurity", context)) - if matching_error == nil { + t, matchingError := NewOauth2AccessCodeSecurity(m, compiler.NewContext("oauth2AccessCodeSecurity", context)) + if matchingError == nil { x.Oneof = &SecurityDefinitionsItem_Oauth2AccessCodeSecurity{Oauth2AccessCodeSecurity: t} matched = true } else { - errors = append(errors, matching_error) + errors = append(errors, matchingError) } } } @@ -5339,6 +5395,7 @@ func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*Sec return x, compiler.NewErrorGroupOrNil(errors) } +// NewSecurityRequirement creates an object of type SecurityRequirement if possible, returning an error if not. func NewSecurityRequirement(in interface{}, context *compiler.Context) (*SecurityRequirement, error) { errors := make([]error, 0) x := &SecurityRequirement{} @@ -5351,7 +5408,7 @@ func NewSecurityRequirement(in interface{}, context *compiler.Context) (*Securit // MAP: StringArray x.AdditionalProperties = make([]*NamedStringArray, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedStringArray{} @@ -5368,6 +5425,7 @@ func NewSecurityRequirement(in interface{}, context *compiler.Context) (*Securit return x, compiler.NewErrorGroupOrNil(errors) } +// NewStringArray creates an object of type StringArray if possible, returning an error if not. func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, error) { errors := make([]error, 0) x := &StringArray{} @@ -5384,6 +5442,7 @@ func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, er return x, compiler.NewErrorGroupOrNil(errors) } +// NewTag creates an object of type Tag if possible, returning an error if not. func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { errors := make([]error, 0) x := &Tag{} @@ -5399,7 +5458,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { errors = append(errors, compiler.NewError(context, message)) } allowedKeys := []string{"description", "externalDocs", "name"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -5436,10 +5495,10 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -5467,6 +5526,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewTypeItem creates an object of type TypeItem if possible, returning an error if not. func NewTypeItem(in interface{}, context *compiler.Context) (*TypeItem, error) { errors := make([]error, 0) x := &TypeItem{} @@ -5492,6 +5552,7 @@ func NewTypeItem(in interface{}, context *compiler.Context) (*TypeItem, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// NewVendorExtension creates an object of type VendorExtension if possible, returning an error if not. func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExtension, error) { errors := make([]error, 0) x := &VendorExtension{} @@ -5504,7 +5565,7 @@ func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExten // MAP: Any x.AdditionalProperties = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value pair := &NamedAny{} @@ -5533,6 +5594,7 @@ func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExten return x, compiler.NewErrorGroupOrNil(errors) } +// NewXml creates an object of type Xml if possible, returning an error if not. func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { errors := make([]error, 0) x := &Xml{} @@ -5542,7 +5604,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { errors = append(errors, compiler.NewError(context, message)) } else { allowedKeys := []string{"attribute", "name", "namespace", "prefix", "wrapped"} - allowedPatterns := []string{"^x-"} + allowedPatterns := []*regexp.Regexp{pattern0} invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns) if len(invalidKeys) > 0 { message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", ")) @@ -5597,10 +5659,10 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) for _, item := range m { - k, ok := item.Key.(string) + k, ok := compiler.StringValue(item.Key) if ok { v := item.Value - if compiler.PatternMatches("^x-", k) { + if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k result := &Any{} @@ -5628,6 +5690,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { return x, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside AdditionalPropertiesItem objects. func (m *AdditionalPropertiesItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) { @@ -5642,11 +5705,13 @@ func (m *AdditionalPropertiesItem) ResolveReferences(root string) (interface{}, return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Any objects. func (m *Any) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside ApiKeySecurity objects. func (m *ApiKeySecurity) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { @@ -5660,6 +5725,7 @@ func (m *ApiKeySecurity) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside BasicAuthenticationSecurity objects. func (m *BasicAuthenticationSecurity) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { @@ -5673,6 +5739,7 @@ func (m *BasicAuthenticationSecurity) ResolveReferences(root string) (interface{ return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside BodyParameter objects. func (m *BodyParameter) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Schema != nil { @@ -5692,6 +5759,7 @@ func (m *BodyParameter) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Contact objects. func (m *Contact) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { @@ -5705,6 +5773,7 @@ func (m *Contact) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Default objects. func (m *Default) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -5718,6 +5787,7 @@ func (m *Default) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Definitions objects. func (m *Definitions) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -5731,6 +5801,7 @@ func (m *Definitions) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Document objects. func (m *Document) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Info != nil { @@ -5802,6 +5873,7 @@ func (m *Document) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Examples objects. func (m *Examples) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -5815,6 +5887,7 @@ func (m *Examples) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside ExternalDocs objects. func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { @@ -5828,6 +5901,7 @@ func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside FileSchema objects. func (m *FileSchema) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Default != nil { @@ -5859,6 +5933,7 @@ func (m *FileSchema) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside FormDataParameterSubSchema objects. func (m *FormDataParameterSubSchema) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Items != nil { @@ -5892,6 +5967,7 @@ func (m *FormDataParameterSubSchema) ResolveReferences(root string) (interface{} return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Header objects. func (m *Header) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Items != nil { @@ -5925,6 +6001,7 @@ func (m *Header) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside HeaderParameterSubSchema objects. func (m *HeaderParameterSubSchema) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Items != nil { @@ -5958,6 +6035,7 @@ func (m *HeaderParameterSubSchema) ResolveReferences(root string) (interface{}, return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Headers objects. func (m *Headers) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -5971,6 +6049,7 @@ func (m *Headers) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Info objects. func (m *Info) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Contact != nil { @@ -5996,6 +6075,7 @@ func (m *Info) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside ItemsItem objects. func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.Schema { @@ -6009,6 +6089,7 @@ func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside JsonReference objects. func (m *JsonReference) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.XRef != "" { @@ -6028,6 +6109,7 @@ func (m *JsonReference) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside License objects. func (m *License) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { @@ -6041,6 +6123,7 @@ func (m *License) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedAny objects. func (m *NamedAny) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6052,6 +6135,7 @@ func (m *NamedAny) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedHeader objects. func (m *NamedHeader) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6063,6 +6147,7 @@ func (m *NamedHeader) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedParameter objects. func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6074,6 +6159,7 @@ func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedPathItem objects. func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6085,6 +6171,7 @@ func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedResponse objects. func (m *NamedResponse) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6096,6 +6183,7 @@ func (m *NamedResponse) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedResponseValue objects. func (m *NamedResponseValue) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6107,6 +6195,7 @@ func (m *NamedResponseValue) ResolveReferences(root string) (interface{}, error) return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedSchema objects. func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6118,6 +6207,7 @@ func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedSecurityDefinitionsItem objects. func (m *NamedSecurityDefinitionsItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6129,11 +6219,13 @@ func (m *NamedSecurityDefinitionsItem) ResolveReferences(root string) (interface return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedString objects. func (m *NamedString) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NamedStringArray objects. func (m *NamedStringArray) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Value != nil { @@ -6145,6 +6237,7 @@ func (m *NamedStringArray) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside NonBodyParameter objects. func (m *NonBodyParameter) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) { @@ -6186,6 +6279,7 @@ func (m *NonBodyParameter) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Oauth2AccessCodeSecurity objects. func (m *Oauth2AccessCodeSecurity) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Scopes != nil { @@ -6205,6 +6299,7 @@ func (m *Oauth2AccessCodeSecurity) ResolveReferences(root string) (interface{}, return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Oauth2ApplicationSecurity objects. func (m *Oauth2ApplicationSecurity) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Scopes != nil { @@ -6224,6 +6319,7 @@ func (m *Oauth2ApplicationSecurity) ResolveReferences(root string) (interface{}, return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Oauth2ImplicitSecurity objects. func (m *Oauth2ImplicitSecurity) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Scopes != nil { @@ -6243,6 +6339,7 @@ func (m *Oauth2ImplicitSecurity) ResolveReferences(root string) (interface{}, er return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Oauth2PasswordSecurity objects. func (m *Oauth2PasswordSecurity) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Scopes != nil { @@ -6262,6 +6359,7 @@ func (m *Oauth2PasswordSecurity) ResolveReferences(root string) (interface{}, er return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Oauth2Scopes objects. func (m *Oauth2Scopes) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -6275,6 +6373,7 @@ func (m *Oauth2Scopes) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Operation objects. func (m *Operation) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.ExternalDocs != nil { @@ -6316,6 +6415,7 @@ func (m *Operation) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Parameter objects. func (m *Parameter) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) { @@ -6339,6 +6439,7 @@ func (m *Parameter) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside ParameterDefinitions objects. func (m *ParameterDefinitions) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -6352,6 +6453,7 @@ func (m *ParameterDefinitions) ResolveReferences(root string) (interface{}, erro return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside ParametersItem objects. func (m *ParametersItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) { @@ -6383,6 +6485,7 @@ func (m *ParametersItem) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside PathItem objects. func (m *PathItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.XRef != "" { @@ -6460,6 +6563,7 @@ func (m *PathItem) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside PathParameterSubSchema objects. func (m *PathParameterSubSchema) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Items != nil { @@ -6493,6 +6597,7 @@ func (m *PathParameterSubSchema) ResolveReferences(root string) (interface{}, er return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Paths objects. func (m *Paths) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { @@ -6514,6 +6619,7 @@ func (m *Paths) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside PrimitivesItems objects. func (m *PrimitivesItems) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Items != nil { @@ -6547,6 +6653,7 @@ func (m *PrimitivesItems) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Properties objects. func (m *Properties) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -6560,6 +6667,7 @@ func (m *Properties) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside QueryParameterSubSchema objects. func (m *QueryParameterSubSchema) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Items != nil { @@ -6593,6 +6701,7 @@ func (m *QueryParameterSubSchema) ResolveReferences(root string) (interface{}, e return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Response objects. func (m *Response) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.Schema != nil { @@ -6624,6 +6733,7 @@ func (m *Response) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside ResponseDefinitions objects. func (m *ResponseDefinitions) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -6637,6 +6747,7 @@ func (m *ResponseDefinitions) ResolveReferences(root string) (interface{}, error return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside ResponseValue objects. func (m *ResponseValue) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) { @@ -6668,6 +6779,7 @@ func (m *ResponseValue) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Responses objects. func (m *Responses) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.ResponseCode { @@ -6689,6 +6801,7 @@ func (m *Responses) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Schema objects. func (m *Schema) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.XRef != "" { @@ -6780,6 +6893,7 @@ func (m *Schema) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside SchemaItem objects. func (m *SchemaItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) { @@ -6803,6 +6917,7 @@ func (m *SchemaItem) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside SecurityDefinitions objects. func (m *SecurityDefinitions) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -6816,6 +6931,7 @@ func (m *SecurityDefinitions) ResolveReferences(root string) (interface{}, error return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside SecurityDefinitionsItem objects. func (m *SecurityDefinitionsItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) { @@ -6875,6 +6991,7 @@ func (m *SecurityDefinitionsItem) ResolveReferences(root string) (interface{}, e return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside SecurityRequirement objects. func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -6888,11 +7005,13 @@ func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside StringArray objects. func (m *StringArray) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Tag objects. func (m *Tag) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) if m.ExternalDocs != nil { @@ -6912,11 +7031,13 @@ func (m *Tag) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside TypeItem objects. func (m *TypeItem) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside VendorExtension objects. func (m *VendorExtension) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { @@ -6930,6 +7051,7 @@ func (m *VendorExtension) ResolveReferences(root string) (interface{}, error) { return nil, compiler.NewErrorGroupOrNil(errors) } +// ResolveReferences resolves references found inside Xml objects. func (m *Xml) ResolveReferences(root string) (interface{}, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { @@ -6942,3 +7064,1665 @@ func (m *Xml) ResolveReferences(root string) (interface{}, error) { } return nil, compiler.NewErrorGroupOrNil(errors) } + +// ToRawInfo returns a description of AdditionalPropertiesItem suitable for JSON or YAML export. +func (m *AdditionalPropertiesItem) ToRawInfo() interface{} { + // ONE OF WRAPPER + // AdditionalPropertiesItem + // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetSchema() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if v1, ok := m.GetOneof().(*AdditionalPropertiesItem_Boolean); ok { + return v1.Boolean + } + return nil +} + +// ToRawInfo returns a description of Any suitable for JSON or YAML export. +func (m *Any) ToRawInfo() interface{} { + var err error + var info1 []yaml.MapSlice + err = yaml.Unmarshal([]byte(m.Yaml), &info1) + if err == nil { + return info1 + } + var info2 yaml.MapSlice + err = yaml.Unmarshal([]byte(m.Yaml), &info2) + if err == nil { + return info2 + } + var info3 interface{} + err = yaml.Unmarshal([]byte(m.Yaml), &info3) + if err == nil { + return info3 + } + return nil +} + +// ToRawInfo returns a description of ApiKeySecurity suitable for JSON or YAML export. +func (m *ApiKeySecurity) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.In != "" { + info = append(info, yaml.MapItem{"in", m.In}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of BasicAuthenticationSecurity suitable for JSON or YAML export. +func (m *BasicAuthenticationSecurity) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of BodyParameter suitable for JSON or YAML export. +func (m *BodyParameter) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.In != "" { + info = append(info, yaml.MapItem{"in", m.In}) + } + if m.Required != false { + info = append(info, yaml.MapItem{"required", m.Required}) + } + if m.Schema != nil { + info = append(info, yaml.MapItem{"schema", m.Schema.ToRawInfo()}) + } + // &{Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Contact suitable for JSON or YAML export. +func (m *Contact) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.Url != "" { + info = append(info, yaml.MapItem{"url", m.Url}) + } + if m.Email != "" { + info = append(info, yaml.MapItem{"email", m.Email}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Default suitable for JSON or YAML export. +func (m *Default) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:false Description:} + return info +} + +// ToRawInfo returns a description of Definitions suitable for JSON or YAML export. +func (m *Definitions) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Document suitable for JSON or YAML export. +func (m *Document) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Swagger != "" { + info = append(info, yaml.MapItem{"swagger", m.Swagger}) + } + if m.Info != nil { + info = append(info, yaml.MapItem{"info", m.Info.ToRawInfo()}) + } + // &{Name:info Type:Info StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Host != "" { + info = append(info, yaml.MapItem{"host", m.Host}) + } + if m.BasePath != "" { + info = append(info, yaml.MapItem{"basePath", m.BasePath}) + } + if len(m.Schemes) != 0 { + info = append(info, yaml.MapItem{"schemes", m.Schemes}) + } + if len(m.Consumes) != 0 { + info = append(info, yaml.MapItem{"consumes", m.Consumes}) + } + if len(m.Produces) != 0 { + info = append(info, yaml.MapItem{"produces", m.Produces}) + } + if m.Paths != nil { + info = append(info, yaml.MapItem{"paths", m.Paths.ToRawInfo()}) + } + // &{Name:paths Type:Paths StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Definitions != nil { + info = append(info, yaml.MapItem{"definitions", m.Definitions.ToRawInfo()}) + } + // &{Name:definitions Type:Definitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Parameters != nil { + info = append(info, yaml.MapItem{"parameters", m.Parameters.ToRawInfo()}) + } + // &{Name:parameters Type:ParameterDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Responses != nil { + info = append(info, yaml.MapItem{"responses", m.Responses.ToRawInfo()}) + } + // &{Name:responses Type:ResponseDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if len(m.Security) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Security { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"security", items}) + } + // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.SecurityDefinitions != nil { + info = append(info, yaml.MapItem{"securityDefinitions", m.SecurityDefinitions.ToRawInfo()}) + } + // &{Name:securityDefinitions Type:SecurityDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if len(m.Tags) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Tags { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"tags", items}) + } + // &{Name:tags Type:Tag StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.ExternalDocs != nil { + info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()}) + } + // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Examples suitable for JSON or YAML export. +func (m *Examples) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of ExternalDocs suitable for JSON or YAML export. +func (m *ExternalDocs) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Url != "" { + info = append(info, yaml.MapItem{"url", m.Url}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of FileSchema suitable for JSON or YAML export. +func (m *FileSchema) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Format != "" { + info = append(info, yaml.MapItem{"format", m.Format}) + } + if m.Title != "" { + info = append(info, yaml.MapItem{"title", m.Title}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Default != nil { + info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()}) + } + // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if len(m.Required) != 0 { + info = append(info, yaml.MapItem{"required", m.Required}) + } + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.ReadOnly != false { + info = append(info, yaml.MapItem{"readOnly", m.ReadOnly}) + } + if m.ExternalDocs != nil { + info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()}) + } + // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Example != nil { + info = append(info, yaml.MapItem{"example", m.Example.ToRawInfo()}) + } + // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of FormDataParameterSubSchema suitable for JSON or YAML export. +func (m *FormDataParameterSubSchema) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Required != false { + info = append(info, yaml.MapItem{"required", m.Required}) + } + if m.In != "" { + info = append(info, yaml.MapItem{"in", m.In}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.AllowEmptyValue != false { + info = append(info, yaml.MapItem{"allowEmptyValue", m.AllowEmptyValue}) + } + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Format != "" { + info = append(info, yaml.MapItem{"format", m.Format}) + } + if m.Items != nil { + info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()}) + } + // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.CollectionFormat != "" { + info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat}) + } + if m.Default != nil { + info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()}) + } + // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Maximum != 0.0 { + info = append(info, yaml.MapItem{"maximum", m.Maximum}) + } + if m.ExclusiveMaximum != false { + info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum}) + } + if m.Minimum != 0.0 { + info = append(info, yaml.MapItem{"minimum", m.Minimum}) + } + if m.ExclusiveMinimum != false { + info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum}) + } + if m.MaxLength != 0 { + info = append(info, yaml.MapItem{"maxLength", m.MaxLength}) + } + if m.MinLength != 0 { + info = append(info, yaml.MapItem{"minLength", m.MinLength}) + } + if m.Pattern != "" { + info = append(info, yaml.MapItem{"pattern", m.Pattern}) + } + if m.MaxItems != 0 { + info = append(info, yaml.MapItem{"maxItems", m.MaxItems}) + } + if m.MinItems != 0 { + info = append(info, yaml.MapItem{"minItems", m.MinItems}) + } + if m.UniqueItems != false { + info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems}) + } + if len(m.Enum) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Enum { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"enum", items}) + } + // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.MultipleOf != 0.0 { + info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Header suitable for JSON or YAML export. +func (m *Header) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Format != "" { + info = append(info, yaml.MapItem{"format", m.Format}) + } + if m.Items != nil { + info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()}) + } + // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.CollectionFormat != "" { + info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat}) + } + if m.Default != nil { + info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()}) + } + // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Maximum != 0.0 { + info = append(info, yaml.MapItem{"maximum", m.Maximum}) + } + if m.ExclusiveMaximum != false { + info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum}) + } + if m.Minimum != 0.0 { + info = append(info, yaml.MapItem{"minimum", m.Minimum}) + } + if m.ExclusiveMinimum != false { + info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum}) + } + if m.MaxLength != 0 { + info = append(info, yaml.MapItem{"maxLength", m.MaxLength}) + } + if m.MinLength != 0 { + info = append(info, yaml.MapItem{"minLength", m.MinLength}) + } + if m.Pattern != "" { + info = append(info, yaml.MapItem{"pattern", m.Pattern}) + } + if m.MaxItems != 0 { + info = append(info, yaml.MapItem{"maxItems", m.MaxItems}) + } + if m.MinItems != 0 { + info = append(info, yaml.MapItem{"minItems", m.MinItems}) + } + if m.UniqueItems != false { + info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems}) + } + if len(m.Enum) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Enum { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"enum", items}) + } + // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.MultipleOf != 0.0 { + info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of HeaderParameterSubSchema suitable for JSON or YAML export. +func (m *HeaderParameterSubSchema) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Required != false { + info = append(info, yaml.MapItem{"required", m.Required}) + } + if m.In != "" { + info = append(info, yaml.MapItem{"in", m.In}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Format != "" { + info = append(info, yaml.MapItem{"format", m.Format}) + } + if m.Items != nil { + info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()}) + } + // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.CollectionFormat != "" { + info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat}) + } + if m.Default != nil { + info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()}) + } + // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Maximum != 0.0 { + info = append(info, yaml.MapItem{"maximum", m.Maximum}) + } + if m.ExclusiveMaximum != false { + info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum}) + } + if m.Minimum != 0.0 { + info = append(info, yaml.MapItem{"minimum", m.Minimum}) + } + if m.ExclusiveMinimum != false { + info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum}) + } + if m.MaxLength != 0 { + info = append(info, yaml.MapItem{"maxLength", m.MaxLength}) + } + if m.MinLength != 0 { + info = append(info, yaml.MapItem{"minLength", m.MinLength}) + } + if m.Pattern != "" { + info = append(info, yaml.MapItem{"pattern", m.Pattern}) + } + if m.MaxItems != 0 { + info = append(info, yaml.MapItem{"maxItems", m.MaxItems}) + } + if m.MinItems != 0 { + info = append(info, yaml.MapItem{"minItems", m.MinItems}) + } + if m.UniqueItems != false { + info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems}) + } + if len(m.Enum) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Enum { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"enum", items}) + } + // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.MultipleOf != 0.0 { + info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Headers suitable for JSON or YAML export. +func (m *Headers) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedHeader StringEnumValues:[] MapType:Header Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Info suitable for JSON or YAML export. +func (m *Info) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Title != "" { + info = append(info, yaml.MapItem{"title", m.Title}) + } + if m.Version != "" { + info = append(info, yaml.MapItem{"version", m.Version}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.TermsOfService != "" { + info = append(info, yaml.MapItem{"termsOfService", m.TermsOfService}) + } + if m.Contact != nil { + info = append(info, yaml.MapItem{"contact", m.Contact.ToRawInfo()}) + } + // &{Name:contact Type:Contact StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.License != nil { + info = append(info, yaml.MapItem{"license", m.License.ToRawInfo()}) + } + // &{Name:license Type:License StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of ItemsItem suitable for JSON or YAML export. +func (m *ItemsItem) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if len(m.Schema) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Schema { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"schema", items}) + } + // &{Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + return info +} + +// ToRawInfo returns a description of JsonReference suitable for JSON or YAML export. +func (m *JsonReference) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.XRef != "" { + info = append(info, yaml.MapItem{"$ref", m.XRef}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + return info +} + +// ToRawInfo returns a description of License suitable for JSON or YAML export. +func (m *License) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.Url != "" { + info = append(info, yaml.MapItem{"url", m.Url}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of NamedAny suitable for JSON or YAML export. +func (m *NamedAny) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedHeader suitable for JSON or YAML export. +func (m *NamedHeader) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:Header StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedParameter suitable for JSON or YAML export. +func (m *NamedParameter) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedPathItem suitable for JSON or YAML export. +func (m *NamedPathItem) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:PathItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedResponse suitable for JSON or YAML export. +func (m *NamedResponse) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedResponseValue suitable for JSON or YAML export. +func (m *NamedResponseValue) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:ResponseValue StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedSchema suitable for JSON or YAML export. +func (m *NamedSchema) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedSecurityDefinitionsItem suitable for JSON or YAML export. +func (m *NamedSecurityDefinitionsItem) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:SecurityDefinitionsItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NamedString suitable for JSON or YAML export. +func (m *NamedString) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.Value != "" { + info = append(info, yaml.MapItem{"value", m.Value}) + } + return info +} + +// ToRawInfo returns a description of NamedStringArray suitable for JSON or YAML export. +func (m *NamedStringArray) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + // &{Name:value Type:StringArray StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} + return info +} + +// ToRawInfo returns a description of NonBodyParameter suitable for JSON or YAML export. +func (m *NonBodyParameter) ToRawInfo() interface{} { + // ONE OF WRAPPER + // NonBodyParameter + // {Name:headerParameterSubSchema Type:HeaderParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetHeaderParameterSubSchema() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:formDataParameterSubSchema Type:FormDataParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetFormDataParameterSubSchema() + if v1 != nil { + return v1.ToRawInfo() + } + // {Name:queryParameterSubSchema Type:QueryParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v2 := m.GetQueryParameterSubSchema() + if v2 != nil { + return v2.ToRawInfo() + } + // {Name:pathParameterSubSchema Type:PathParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v3 := m.GetPathParameterSubSchema() + if v3 != nil { + return v3.ToRawInfo() + } + return nil +} + +// ToRawInfo returns a description of Oauth2AccessCodeSecurity suitable for JSON or YAML export. +func (m *Oauth2AccessCodeSecurity) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Flow != "" { + info = append(info, yaml.MapItem{"flow", m.Flow}) + } + if m.Scopes != nil { + info = append(info, yaml.MapItem{"scopes", m.Scopes.ToRawInfo()}) + } + // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.AuthorizationUrl != "" { + info = append(info, yaml.MapItem{"authorizationUrl", m.AuthorizationUrl}) + } + if m.TokenUrl != "" { + info = append(info, yaml.MapItem{"tokenUrl", m.TokenUrl}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Oauth2ApplicationSecurity suitable for JSON or YAML export. +func (m *Oauth2ApplicationSecurity) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Flow != "" { + info = append(info, yaml.MapItem{"flow", m.Flow}) + } + if m.Scopes != nil { + info = append(info, yaml.MapItem{"scopes", m.Scopes.ToRawInfo()}) + } + // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.TokenUrl != "" { + info = append(info, yaml.MapItem{"tokenUrl", m.TokenUrl}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Oauth2ImplicitSecurity suitable for JSON or YAML export. +func (m *Oauth2ImplicitSecurity) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Flow != "" { + info = append(info, yaml.MapItem{"flow", m.Flow}) + } + if m.Scopes != nil { + info = append(info, yaml.MapItem{"scopes", m.Scopes.ToRawInfo()}) + } + // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.AuthorizationUrl != "" { + info = append(info, yaml.MapItem{"authorizationUrl", m.AuthorizationUrl}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Oauth2PasswordSecurity suitable for JSON or YAML export. +func (m *Oauth2PasswordSecurity) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Flow != "" { + info = append(info, yaml.MapItem{"flow", m.Flow}) + } + if m.Scopes != nil { + info = append(info, yaml.MapItem{"scopes", m.Scopes.ToRawInfo()}) + } + // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.TokenUrl != "" { + info = append(info, yaml.MapItem{"tokenUrl", m.TokenUrl}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Oauth2Scopes suitable for JSON or YAML export. +func (m *Oauth2Scopes) ToRawInfo() interface{} { + info := yaml.MapSlice{} + // &{Name:additionalProperties Type:NamedString StringEnumValues:[] MapType:string Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Operation suitable for JSON or YAML export. +func (m *Operation) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if len(m.Tags) != 0 { + info = append(info, yaml.MapItem{"tags", m.Tags}) + } + if m.Summary != "" { + info = append(info, yaml.MapItem{"summary", m.Summary}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.ExternalDocs != nil { + info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()}) + } + // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.OperationId != "" { + info = append(info, yaml.MapItem{"operationId", m.OperationId}) + } + if len(m.Produces) != 0 { + info = append(info, yaml.MapItem{"produces", m.Produces}) + } + if len(m.Consumes) != 0 { + info = append(info, yaml.MapItem{"consumes", m.Consumes}) + } + if len(m.Parameters) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Parameters { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"parameters", items}) + } + // &{Name:parameters Type:ParametersItem StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:The parameters needed to send a valid API call.} + if m.Responses != nil { + info = append(info, yaml.MapItem{"responses", m.Responses.ToRawInfo()}) + } + // &{Name:responses Type:Responses StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if len(m.Schemes) != 0 { + info = append(info, yaml.MapItem{"schemes", m.Schemes}) + } + if m.Deprecated != false { + info = append(info, yaml.MapItem{"deprecated", m.Deprecated}) + } + if len(m.Security) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Security { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"security", items}) + } + // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Parameter suitable for JSON or YAML export. +func (m *Parameter) ToRawInfo() interface{} { + // ONE OF WRAPPER + // Parameter + // {Name:bodyParameter Type:BodyParameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetBodyParameter() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:nonBodyParameter Type:NonBodyParameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetNonBodyParameter() + if v1 != nil { + return v1.ToRawInfo() + } + return nil +} + +// ToRawInfo returns a description of ParameterDefinitions suitable for JSON or YAML export. +func (m *ParameterDefinitions) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedParameter StringEnumValues:[] MapType:Parameter Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of ParametersItem suitable for JSON or YAML export. +func (m *ParametersItem) ToRawInfo() interface{} { + // ONE OF WRAPPER + // ParametersItem + // {Name:parameter Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetParameter() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:jsonReference Type:JsonReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetJsonReference() + if v1 != nil { + return v1.ToRawInfo() + } + return nil +} + +// ToRawInfo returns a description of PathItem suitable for JSON or YAML export. +func (m *PathItem) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.XRef != "" { + info = append(info, yaml.MapItem{"$ref", m.XRef}) + } + if m.Get != nil { + info = append(info, yaml.MapItem{"get", m.Get.ToRawInfo()}) + } + // &{Name:get Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Put != nil { + info = append(info, yaml.MapItem{"put", m.Put.ToRawInfo()}) + } + // &{Name:put Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Post != nil { + info = append(info, yaml.MapItem{"post", m.Post.ToRawInfo()}) + } + // &{Name:post Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Delete != nil { + info = append(info, yaml.MapItem{"delete", m.Delete.ToRawInfo()}) + } + // &{Name:delete Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Options != nil { + info = append(info, yaml.MapItem{"options", m.Options.ToRawInfo()}) + } + // &{Name:options Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Head != nil { + info = append(info, yaml.MapItem{"head", m.Head.ToRawInfo()}) + } + // &{Name:head Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Patch != nil { + info = append(info, yaml.MapItem{"patch", m.Patch.ToRawInfo()}) + } + // &{Name:patch Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if len(m.Parameters) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Parameters { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"parameters", items}) + } + // &{Name:parameters Type:ParametersItem StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:The parameters needed to send a valid API call.} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of PathParameterSubSchema suitable for JSON or YAML export. +func (m *PathParameterSubSchema) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Required != false { + info = append(info, yaml.MapItem{"required", m.Required}) + } + if m.In != "" { + info = append(info, yaml.MapItem{"in", m.In}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Format != "" { + info = append(info, yaml.MapItem{"format", m.Format}) + } + if m.Items != nil { + info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()}) + } + // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.CollectionFormat != "" { + info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat}) + } + if m.Default != nil { + info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()}) + } + // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Maximum != 0.0 { + info = append(info, yaml.MapItem{"maximum", m.Maximum}) + } + if m.ExclusiveMaximum != false { + info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum}) + } + if m.Minimum != 0.0 { + info = append(info, yaml.MapItem{"minimum", m.Minimum}) + } + if m.ExclusiveMinimum != false { + info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum}) + } + if m.MaxLength != 0 { + info = append(info, yaml.MapItem{"maxLength", m.MaxLength}) + } + if m.MinLength != 0 { + info = append(info, yaml.MapItem{"minLength", m.MinLength}) + } + if m.Pattern != "" { + info = append(info, yaml.MapItem{"pattern", m.Pattern}) + } + if m.MaxItems != 0 { + info = append(info, yaml.MapItem{"maxItems", m.MaxItems}) + } + if m.MinItems != 0 { + info = append(info, yaml.MapItem{"minItems", m.MinItems}) + } + if m.UniqueItems != false { + info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems}) + } + if len(m.Enum) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Enum { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"enum", items}) + } + // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.MultipleOf != 0.0 { + info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Paths suitable for JSON or YAML export. +func (m *Paths) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + if m.Path != nil { + for _, item := range m.Path { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:Path Type:NamedPathItem StringEnumValues:[] MapType:PathItem Repeated:true Pattern:^/ Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of PrimitivesItems suitable for JSON or YAML export. +func (m *PrimitivesItems) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Format != "" { + info = append(info, yaml.MapItem{"format", m.Format}) + } + if m.Items != nil { + info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()}) + } + // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.CollectionFormat != "" { + info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat}) + } + if m.Default != nil { + info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()}) + } + // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Maximum != 0.0 { + info = append(info, yaml.MapItem{"maximum", m.Maximum}) + } + if m.ExclusiveMaximum != false { + info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum}) + } + if m.Minimum != 0.0 { + info = append(info, yaml.MapItem{"minimum", m.Minimum}) + } + if m.ExclusiveMinimum != false { + info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum}) + } + if m.MaxLength != 0 { + info = append(info, yaml.MapItem{"maxLength", m.MaxLength}) + } + if m.MinLength != 0 { + info = append(info, yaml.MapItem{"minLength", m.MinLength}) + } + if m.Pattern != "" { + info = append(info, yaml.MapItem{"pattern", m.Pattern}) + } + if m.MaxItems != 0 { + info = append(info, yaml.MapItem{"maxItems", m.MaxItems}) + } + if m.MinItems != 0 { + info = append(info, yaml.MapItem{"minItems", m.MinItems}) + } + if m.UniqueItems != false { + info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems}) + } + if len(m.Enum) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Enum { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"enum", items}) + } + // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.MultipleOf != 0.0 { + info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Properties suitable for JSON or YAML export. +func (m *Properties) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of QueryParameterSubSchema suitable for JSON or YAML export. +func (m *QueryParameterSubSchema) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Required != false { + info = append(info, yaml.MapItem{"required", m.Required}) + } + if m.In != "" { + info = append(info, yaml.MapItem{"in", m.In}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.AllowEmptyValue != false { + info = append(info, yaml.MapItem{"allowEmptyValue", m.AllowEmptyValue}) + } + if m.Type != "" { + info = append(info, yaml.MapItem{"type", m.Type}) + } + if m.Format != "" { + info = append(info, yaml.MapItem{"format", m.Format}) + } + if m.Items != nil { + info = append(info, yaml.MapItem{"items", m.Items.ToRawInfo()}) + } + // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.CollectionFormat != "" { + info = append(info, yaml.MapItem{"collectionFormat", m.CollectionFormat}) + } + if m.Default != nil { + info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()}) + } + // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Maximum != 0.0 { + info = append(info, yaml.MapItem{"maximum", m.Maximum}) + } + if m.ExclusiveMaximum != false { + info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum}) + } + if m.Minimum != 0.0 { + info = append(info, yaml.MapItem{"minimum", m.Minimum}) + } + if m.ExclusiveMinimum != false { + info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum}) + } + if m.MaxLength != 0 { + info = append(info, yaml.MapItem{"maxLength", m.MaxLength}) + } + if m.MinLength != 0 { + info = append(info, yaml.MapItem{"minLength", m.MinLength}) + } + if m.Pattern != "" { + info = append(info, yaml.MapItem{"pattern", m.Pattern}) + } + if m.MaxItems != 0 { + info = append(info, yaml.MapItem{"maxItems", m.MaxItems}) + } + if m.MinItems != 0 { + info = append(info, yaml.MapItem{"minItems", m.MinItems}) + } + if m.UniqueItems != false { + info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems}) + } + if len(m.Enum) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Enum { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"enum", items}) + } + // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.MultipleOf != 0.0 { + info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Response suitable for JSON or YAML export. +func (m *Response) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Schema != nil { + info = append(info, yaml.MapItem{"schema", m.Schema.ToRawInfo()}) + } + // &{Name:schema Type:SchemaItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Headers != nil { + info = append(info, yaml.MapItem{"headers", m.Headers.ToRawInfo()}) + } + // &{Name:headers Type:Headers StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Examples != nil { + info = append(info, yaml.MapItem{"examples", m.Examples.ToRawInfo()}) + } + // &{Name:examples Type:Examples StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of ResponseDefinitions suitable for JSON or YAML export. +func (m *ResponseDefinitions) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedResponse StringEnumValues:[] MapType:Response Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of ResponseValue suitable for JSON or YAML export. +func (m *ResponseValue) ToRawInfo() interface{} { + // ONE OF WRAPPER + // ResponseValue + // {Name:response Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetResponse() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:jsonReference Type:JsonReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetJsonReference() + if v1 != nil { + return v1.ToRawInfo() + } + return nil +} + +// ToRawInfo returns a description of Responses suitable for JSON or YAML export. +func (m *Responses) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.ResponseCode != nil { + for _, item := range m.ResponseCode { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:ResponseCode Type:NamedResponseValue StringEnumValues:[] MapType:ResponseValue Repeated:true Pattern:^([0-9]{3})$|^(default)$ Implicit:true Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Schema suitable for JSON or YAML export. +func (m *Schema) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.XRef != "" { + info = append(info, yaml.MapItem{"$ref", m.XRef}) + } + if m.Format != "" { + info = append(info, yaml.MapItem{"format", m.Format}) + } + if m.Title != "" { + info = append(info, yaml.MapItem{"title", m.Title}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.Default != nil { + info = append(info, yaml.MapItem{"default", m.Default.ToRawInfo()}) + } + // &{Name:default Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.MultipleOf != 0.0 { + info = append(info, yaml.MapItem{"multipleOf", m.MultipleOf}) + } + if m.Maximum != 0.0 { + info = append(info, yaml.MapItem{"maximum", m.Maximum}) + } + if m.ExclusiveMaximum != false { + info = append(info, yaml.MapItem{"exclusiveMaximum", m.ExclusiveMaximum}) + } + if m.Minimum != 0.0 { + info = append(info, yaml.MapItem{"minimum", m.Minimum}) + } + if m.ExclusiveMinimum != false { + info = append(info, yaml.MapItem{"exclusiveMinimum", m.ExclusiveMinimum}) + } + if m.MaxLength != 0 { + info = append(info, yaml.MapItem{"maxLength", m.MaxLength}) + } + if m.MinLength != 0 { + info = append(info, yaml.MapItem{"minLength", m.MinLength}) + } + if m.Pattern != "" { + info = append(info, yaml.MapItem{"pattern", m.Pattern}) + } + if m.MaxItems != 0 { + info = append(info, yaml.MapItem{"maxItems", m.MaxItems}) + } + if m.MinItems != 0 { + info = append(info, yaml.MapItem{"minItems", m.MinItems}) + } + if m.UniqueItems != false { + info = append(info, yaml.MapItem{"uniqueItems", m.UniqueItems}) + } + if m.MaxProperties != 0 { + info = append(info, yaml.MapItem{"maxProperties", m.MaxProperties}) + } + if m.MinProperties != 0 { + info = append(info, yaml.MapItem{"minProperties", m.MinProperties}) + } + if len(m.Required) != 0 { + info = append(info, yaml.MapItem{"required", m.Required}) + } + if len(m.Enum) != 0 { + items := make([]interface{}, 0) + for _, item := range m.Enum { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"enum", items}) + } + // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.AdditionalProperties != nil { + info = append(info, yaml.MapItem{"additionalProperties", m.AdditionalProperties.ToRawInfo()}) + } + // &{Name:additionalProperties Type:AdditionalPropertiesItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Type != nil { + if len(m.Type.Value) == 1 { + info = append(info, yaml.MapItem{"type", m.Type.Value[0]}) + } else { + info = append(info, yaml.MapItem{"type", m.Type.Value}) + } + } + // &{Name:type Type:TypeItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Items != nil { + items := make([]interface{}, 0) + for _, item := range m.Items.Schema { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"items", items[0]}) + } + // &{Name:items Type:ItemsItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if len(m.AllOf) != 0 { + items := make([]interface{}, 0) + for _, item := range m.AllOf { + items = append(items, item.ToRawInfo()) + } + info = append(info, yaml.MapItem{"allOf", items}) + } + // &{Name:allOf Type:Schema StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} + if m.Properties != nil { + info = append(info, yaml.MapItem{"properties", m.Properties.ToRawInfo()}) + } + // &{Name:properties Type:Properties StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Discriminator != "" { + info = append(info, yaml.MapItem{"discriminator", m.Discriminator}) + } + if m.ReadOnly != false { + info = append(info, yaml.MapItem{"readOnly", m.ReadOnly}) + } + if m.Xml != nil { + info = append(info, yaml.MapItem{"xml", m.Xml.ToRawInfo()}) + } + // &{Name:xml Type:Xml StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.ExternalDocs != nil { + info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()}) + } + // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.Example != nil { + info = append(info, yaml.MapItem{"example", m.Example.ToRawInfo()}) + } + // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of SchemaItem suitable for JSON or YAML export. +func (m *SchemaItem) ToRawInfo() interface{} { + // ONE OF WRAPPER + // SchemaItem + // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetSchema() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:fileSchema Type:FileSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetFileSchema() + if v1 != nil { + return v1.ToRawInfo() + } + return nil +} + +// ToRawInfo returns a description of SecurityDefinitions suitable for JSON or YAML export. +func (m *SecurityDefinitions) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedSecurityDefinitionsItem StringEnumValues:[] MapType:SecurityDefinitionsItem Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of SecurityDefinitionsItem suitable for JSON or YAML export. +func (m *SecurityDefinitionsItem) ToRawInfo() interface{} { + // ONE OF WRAPPER + // SecurityDefinitionsItem + // {Name:basicAuthenticationSecurity Type:BasicAuthenticationSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v0 := m.GetBasicAuthenticationSecurity() + if v0 != nil { + return v0.ToRawInfo() + } + // {Name:apiKeySecurity Type:ApiKeySecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v1 := m.GetApiKeySecurity() + if v1 != nil { + return v1.ToRawInfo() + } + // {Name:oauth2ImplicitSecurity Type:Oauth2ImplicitSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v2 := m.GetOauth2ImplicitSecurity() + if v2 != nil { + return v2.ToRawInfo() + } + // {Name:oauth2PasswordSecurity Type:Oauth2PasswordSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v3 := m.GetOauth2PasswordSecurity() + if v3 != nil { + return v3.ToRawInfo() + } + // {Name:oauth2ApplicationSecurity Type:Oauth2ApplicationSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v4 := m.GetOauth2ApplicationSecurity() + if v4 != nil { + return v4.ToRawInfo() + } + // {Name:oauth2AccessCodeSecurity Type:Oauth2AccessCodeSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + v5 := m.GetOauth2AccessCodeSecurity() + if v5 != nil { + return v5.ToRawInfo() + } + return nil +} + +// ToRawInfo returns a description of SecurityRequirement suitable for JSON or YAML export. +func (m *SecurityRequirement) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedStringArray StringEnumValues:[] MapType:StringArray Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of StringArray suitable for JSON or YAML export. +func (m *StringArray) ToRawInfo() interface{} { + return m.Value +} + +// ToRawInfo returns a description of Tag suitable for JSON or YAML export. +func (m *Tag) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.Description != "" { + info = append(info, yaml.MapItem{"description", m.Description}) + } + if m.ExternalDocs != nil { + info = append(info, yaml.MapItem{"externalDocs", m.ExternalDocs.ToRawInfo()}) + } + // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of TypeItem suitable for JSON or YAML export. +func (m *TypeItem) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if len(m.Value) != 0 { + info = append(info, yaml.MapItem{"value", m.Value}) + } + return info +} + +// ToRawInfo returns a description of VendorExtension suitable for JSON or YAML export. +func (m *VendorExtension) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.AdditionalProperties != nil { + for _, item := range m.AdditionalProperties { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:} + return info +} + +// ToRawInfo returns a description of Xml suitable for JSON or YAML export. +func (m *Xml) ToRawInfo() interface{} { + info := yaml.MapSlice{} + if m.Name != "" { + info = append(info, yaml.MapItem{"name", m.Name}) + } + if m.Namespace != "" { + info = append(info, yaml.MapItem{"namespace", m.Namespace}) + } + if m.Prefix != "" { + info = append(info, yaml.MapItem{"prefix", m.Prefix}) + } + if m.Attribute != false { + info = append(info, yaml.MapItem{"attribute", m.Attribute}) + } + if m.Wrapped != false { + info = append(info, yaml.MapItem{"wrapped", m.Wrapped}) + } + if m.VendorExtension != nil { + for _, item := range m.VendorExtension { + info = append(info, yaml.MapItem{item.Name, item.Value.ToRawInfo()}) + } + } + // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} + return info +} + +var ( + pattern0 = regexp.MustCompile("^x-") + pattern1 = regexp.MustCompile("^/") + pattern2 = regexp.MustCompile("^([0-9]{3})$|^(default)$") +) diff --git a/vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go b/vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go index c815ae969e..37da7df256 100644 --- a/vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go +++ b/vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go @@ -1376,7 +1376,7 @@ func (m *ItemsItem) GetSchema() []*Schema { } type JsonReference struct { - XRef string `protobuf:"bytes,1,opt,name=_ref,json=ref" json:"_ref,omitempty"` + XRef string `protobuf:"bytes,1,opt,name=_ref,json=Ref" json:"_ref,omitempty"` Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` } @@ -2513,7 +2513,7 @@ func _ParametersItem_OneofSizer(msg proto.Message) (n int) { } type PathItem struct { - XRef string `protobuf:"bytes,1,opt,name=_ref,json=ref" json:"_ref,omitempty"` + XRef string `protobuf:"bytes,1,opt,name=_ref,json=Ref" json:"_ref,omitempty"` Get *Operation `protobuf:"bytes,2,opt,name=get" json:"get,omitempty"` Put *Operation `protobuf:"bytes,3,opt,name=put" json:"put,omitempty"` Post *Operation `protobuf:"bytes,4,opt,name=post" json:"post,omitempty"` @@ -3392,7 +3392,7 @@ func (m *Responses) GetVendorExtension() []*NamedAny { // A deterministic version of a JSON Schema object. type Schema struct { - XRef string `protobuf:"bytes,1,opt,name=_ref,json=ref" json:"_ref,omitempty"` + XRef string `protobuf:"bytes,1,opt,name=_ref,json=Ref" json:"_ref,omitempty"` Format string `protobuf:"bytes,2,opt,name=format" json:"format,omitempty"` Title string `protobuf:"bytes,3,opt,name=title" json:"title,omitempty"` Description string `protobuf:"bytes,4,opt,name=description" json:"description,omitempty"` @@ -4351,7 +4351,7 @@ var fileDescriptor0 = []byte{ 0xfe, 0x90, 0x83, 0x0c, 0x89, 0xa3, 0x14, 0x7e, 0x7d, 0x1e, 0xe1, 0xbf, 0x05, 0x4d, 0xa6, 0x0c, 0xac, 0x56, 0x77, 0x23, 0x51, 0xab, 0x2b, 0x4f, 0x2e, 0xac, 0x6c, 0xdd, 0x85, 0xd6, 0x37, 0x02, 0xe2, 0x1a, 0x78, 0x80, 0x7d, 0xec, 0xf6, 0xb0, 0xb6, 0x0c, 0x15, 0xd3, 0xc7, 0x03, 0x21, 0xe3, - 0xb2, 0x8f, 0x07, 0xd3, 0xeb, 0x4f, 0x5b, 0x1e, 0xd4, 0xc5, 0x33, 0xcd, 0x58, 0x5c, 0x39, 0xf3, + 0xb2, 0x81, 0x07, 0xd3, 0xeb, 0x4f, 0x5b, 0x1e, 0xd4, 0xc5, 0x33, 0xcd, 0x58, 0x5c, 0x39, 0xf3, 0x59, 0xe6, 0x1e, 0x34, 0x24, 0x50, 0xb9, 0xe5, 0x2b, 0xb2, 0xaa, 0x58, 0x52, 0x3b, 0x20, 0x0e, 0xdd, 0x7a, 0x17, 0x16, 0x12, 0x0a, 0xa8, 0xa4, 0x74, 0x2d, 0x4d, 0x29, 0x25, 0x4c, 0xa1, 0xb7, 0x82, 0xd8, 0xfb, 0xd0, 0x66, 0xc4, 0xe2, 0x22, 0x9a, 0x8a, 0xde, 0xeb, 0x69, 0x7a, 0x17, 0x94, @@ -4452,5 +4452,5 @@ var fileDescriptor0 = []byte{ 0xf3, 0x70, 0x5f, 0x1c, 0xc1, 0xe5, 0xf0, 0xcc, 0x7d, 0xcc, 0xdb, 0xaf, 0x42, 0x9b, 0xf8, 0x47, 0x12, 0xd7, 0x3c, 0xd9, 0xb9, 0xbd, 0x28, 0xbe, 0x5d, 0xdd, 0xf7, 0x49, 0x48, 0xf6, 0x8b, 0xbf, 0x28, 0x95, 0xf7, 0x76, 0x0f, 0x0e, 0x6b, 0xec, 0x63, 0xd0, 0x37, 0xff, 0x19, 0x00, 0x00, 0xff, - 0xff, 0x3c, 0x01, 0x3f, 0x38, 0xe4, 0x3a, 0x00, 0x00, + 0xff, 0xd4, 0x0a, 0xef, 0xca, 0xe4, 0x3a, 0x00, 0x00, } diff --git a/vendor/github.com/googleapis/gnostic/compiler/context.go b/vendor/github.com/googleapis/gnostic/compiler/context.go index 2e5242ee7f..a64c1b75db 100644 --- a/vendor/github.com/googleapis/gnostic/compiler/context.go +++ b/vendor/github.com/googleapis/gnostic/compiler/context.go @@ -14,28 +14,30 @@ package compiler +// Context contains state of the compiler as it traverses a document. type Context struct { Parent *Context Name string 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} } +// NewContext returns a new object representing the compiler state func NewContext(name string, parent *Context) *Context { if parent != nil { return &Context{Name: name, Parent: parent, ExtensionHandlers: parent.ExtensionHandlers} - } else { - return &Context{Name: name, Parent: parent, ExtensionHandlers: nil} } + return &Context{Name: name, Parent: parent, ExtensionHandlers: nil} } +// Description returns a text description of the compiler state func (context *Context) Description() string { if context.Parent != nil { return context.Parent.Description() + "." + context.Name - } else { - return context.Name } + return context.Name } diff --git a/vendor/github.com/googleapis/gnostic/compiler/error.go b/vendor/github.com/googleapis/gnostic/compiler/error.go index 942536a799..d8672c1008 100644 --- a/vendor/github.com/googleapis/gnostic/compiler/error.go +++ b/vendor/github.com/googleapis/gnostic/compiler/error.go @@ -14,29 +14,31 @@ package compiler -// basic error type +// Error represents compiler errors and their location in the document. type Error struct { Context *Context Message string } +// NewError creates an Error. func NewError(context *Context, message string) *Error { return &Error{Context: context, Message: message} } +// Error returns the string value of an Error. func (err *Error) Error() string { - if err.Context != nil { - return "ERROR " + err.Context.Description() + " " + err.Message - } else { + if err.Context == nil { return "ERROR " + err.Message } + return "ERROR " + err.Context.Description() + " " + err.Message } -// container for groups of errors +// ErrorGroup is a container for groups of Error values. type ErrorGroup struct { Errors []error } +// NewErrorGroupOrNil returns a new ErrorGroup for a slice of errors or nil if the slice is empty. func NewErrorGroupOrNil(errors []error) error { if len(errors) == 0 { return nil diff --git a/vendor/github.com/googleapis/gnostic/compiler/extension-handler.go b/vendor/github.com/googleapis/gnostic/compiler/extension-handler.go index 426663c2b7..1f85b650e8 100644 --- a/vendor/github.com/googleapis/gnostic/compiler/extension-handler.go +++ b/vendor/github.com/googleapis/gnostic/compiler/extension-handler.go @@ -29,16 +29,18 @@ import ( yaml "gopkg.in/yaml.v2" ) +// ExtensionHandler describes a binary that is called by the compiler to handle specification extensions. type ExtensionHandler struct { Name string } +// HandleExtension calls a binary extension handler. func HandleExtension(context *Context, in interface{}, extensionName string) (bool, *any.Any, error) { handled := false var errFromPlugin error var outFromPlugin *any.Any - if context.ExtensionHandlers != nil && len(*(context.ExtensionHandlers)) != 0 { + if context != nil && context.ExtensionHandlers != nil && len(*(context.ExtensionHandlers)) != 0 { for _, customAnyProtoGenerator := range *(context.ExtensionHandlers) { outFromPlugin, errFromPlugin = customAnyProtoGenerator.handle(in, extensionName) if outFromPlugin == nil { diff --git a/vendor/github.com/googleapis/gnostic/compiler/helpers.go b/vendor/github.com/googleapis/gnostic/compiler/helpers.go index 56306c40f8..76df635ff9 100644 --- a/vendor/github.com/googleapis/gnostic/compiler/helpers.go +++ b/vendor/github.com/googleapis/gnostic/compiler/helpers.go @@ -19,27 +19,27 @@ import ( "gopkg.in/yaml.v2" "regexp" "sort" - "strings" + "strconv" ) // compiler helper functions, usually called from generated code +// UnpackMap gets a yaml.MapSlice if possible. func UnpackMap(in interface{}) (yaml.MapSlice, bool) { m, ok := in.(yaml.MapSlice) if ok { - return m, ok - } else { - // do we have an empty array? - a, ok := in.([]interface{}) - if ok && len(a) == 0 { - // if so, return an empty map - return yaml.MapSlice{}, ok - } else { - return nil, ok - } + return m, true } + // do we have an empty array? + a, ok := in.([]interface{}) + if ok && len(a) == 0 { + // if so, return an empty map + return yaml.MapSlice{}, true + } + return nil, false } +// SortedKeysForMap returns the sorted keys of a yaml.MapSlice. func SortedKeysForMap(m yaml.MapSlice) []string { keys := make([]string, 0) for _, item := range m { @@ -49,6 +49,7 @@ func SortedKeysForMap(m yaml.MapSlice) []string { return keys } +// MapHasKey returns true if a yaml.MapSlice contains a specified key. func MapHasKey(m yaml.MapSlice, key string) bool { for _, item := range m { itemKey, ok := item.Key.(string) @@ -59,6 +60,7 @@ func MapHasKey(m yaml.MapSlice, key string) bool { return false } +// MapValueForKey gets the value of a map value for a specified key. func MapValueForKey(m yaml.MapSlice, key string) interface{} { for _, item := range m { itemKey, ok := item.Key.(string) @@ -69,6 +71,7 @@ func MapValueForKey(m yaml.MapSlice, key string) interface{} { return nil } +// ConvertInterfaceArrayToStringArray converts an array of interfaces to an array of strings, if possible. func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string { stringArray := make([]string, 0) for _, item := range interfaceArray { @@ -80,22 +83,7 @@ func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string { return stringArray } -func PatternMatches(pattern string, value string) bool { - // if pattern contains a subpattern like "{path}", replace it with ".*" - if pattern[0] != '^' { - subpatternPattern := regexp.MustCompile("^.*(\\{.*\\}).*$") - if matches := subpatternPattern.FindSubmatch([]byte(pattern)); matches != nil { - match := string(matches[1]) - pattern = strings.Replace(pattern, match, ".*", -1) - } - } - matched, err := regexp.Match(pattern, []byte(value)) - if err != nil { - panic(err) - } - return matched -} - +// MissingKeysInMap identifies which keys from a list of required keys are not in a map. func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string { missingKeys := make([]string, 0) for _, k := range requiredKeys { @@ -106,7 +94,8 @@ func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string { return missingKeys } -func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []string) []string { +// InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns. +func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string { invalidKeys := make([]string, 0) for _, item := range m { itemKey, ok := item.Key.(string) @@ -123,7 +112,7 @@ func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []s if !found { // does the key match an allowed pattern? for _, allowedPattern := range allowedPatterns { - if PatternMatches(allowedPattern, key) { + if allowedPattern.MatchString(key) { found = true break } @@ -137,13 +126,13 @@ func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []s return invalidKeys } -// describe a map (for debugging purposes) +// DescribeMap describes a map (for debugging purposes). func DescribeMap(in interface{}, indent string) string { description := "" m, ok := in.(map[string]interface{}) if ok { keys := make([]string, 0) - for k, _ := range m { + for k := range m { keys = append(keys, k) } sort.Strings(keys) @@ -166,14 +155,15 @@ func DescribeMap(in interface{}, indent string) string { return description } +// PluralProperties returns the string "properties" pluralized. func PluralProperties(count int) string { if count == 1 { return "property" - } else { - return "properties" } + return "properties" } +// StringArrayContainsValue returns true if a string array contains a specified value. func StringArrayContainsValue(array []string, value string) bool { for _, item := range array { if item == value { @@ -183,6 +173,7 @@ func StringArrayContainsValue(array []string, value string) bool { return false } +// StringArrayContainsValues returns true if a string array contains all of a list of specified values. func StringArrayContainsValues(array []string, values []string) bool { for _, value := range values { if !StringArrayContainsValue(array, value) { @@ -191,3 +182,16 @@ func StringArrayContainsValues(array []string, values []string) bool { } return true } + +// StringValue returns the string value of an item. +func StringValue(item interface{}) (value string, ok bool) { + value, ok = item.(string) + if ok { + return value, ok + } + intValue, ok := item.(int) + if ok { + return strconv.Itoa(intValue), true + } + return "", false +} diff --git a/vendor/github.com/googleapis/gnostic/compiler/reader.go b/vendor/github.com/googleapis/gnostic/compiler/reader.go index 1878e06080..604a46a6a1 100644 --- a/vendor/github.com/googleapis/gnostic/compiler/reader.go +++ b/vendor/github.com/googleapis/gnostic/compiler/reader.go @@ -25,29 +25,30 @@ import ( "strings" ) -var file_cache map[string][]byte -var info_cache map[string]interface{} +var fileCache map[string][]byte +var infoCache map[string]interface{} var count int64 -var VERBOSE_READER = false +var verboseReader = false func initializeFileCache() { - if file_cache == nil { - file_cache = make(map[string][]byte, 0) + if fileCache == nil { + fileCache = make(map[string][]byte, 0) } } func initializeInfoCache() { - if info_cache == nil { - info_cache = make(map[string]interface{}, 0) + if infoCache == nil { + infoCache = make(map[string]interface{}, 0) } } +// FetchFile gets a specified file from the local filesystem or a remote location. func FetchFile(fileurl string) ([]byte, error) { initializeFileCache() - bytes, ok := file_cache[fileurl] + bytes, ok := fileCache[fileurl] if ok { - if VERBOSE_READER { + if verboseReader { log.Printf("Cache hit %s", fileurl) } return bytes, nil @@ -56,30 +57,17 @@ func FetchFile(fileurl string) ([]byte, error) { response, err := http.Get(fileurl) if err != nil { return nil, err - } else { - defer response.Body.Close() - bytes, err := ioutil.ReadAll(response.Body) - if err == nil { - file_cache[fileurl] = bytes - } - return bytes, err } + defer response.Body.Close() + bytes, err = ioutil.ReadAll(response.Body) + if err == nil { + fileCache[fileurl] = bytes + } + return bytes, err } -// read a file and unmarshal it as a yaml.MapSlice -func ReadInfoForFile(filename string) (interface{}, error) { - initializeInfoCache() - info, ok := info_cache[filename] - if ok { - if VERBOSE_READER { - log.Printf("Cache hit info for file %s", filename) - } - return info, nil - } - if VERBOSE_READER { - log.Printf("Reading info for file %s", filename) - } - +// ReadBytesForFile reads the bytes of a file. +func ReadBytesForFile(filename string) ([]byte, error) { // is the filename a url? fileurl, _ := url.Parse(filename) if fileurl.Scheme != "" { @@ -88,43 +76,51 @@ func ReadInfoForFile(filename string) (interface{}, error) { if err != nil { return nil, err } - var info yaml.MapSlice - err = yaml.Unmarshal(bytes, &info) - if err != nil { - return nil, err - } - info_cache[filename] = info - return info, nil - } else { - // no, it's a local filename - bytes, err := ioutil.ReadFile(filename) - if err != nil { - log.Printf("File error: %v\n", err) - return nil, err - } - var info yaml.MapSlice - err = yaml.Unmarshal(bytes, &info) - if err != nil { - return nil, err - } - info_cache[filename] = info - return info, nil + return bytes, nil } + // no, it's a local filename + bytes, err := ioutil.ReadFile(filename) + if err != nil { + return nil, err + } + return bytes, nil } -// read a file and return the fragment needed to resolve a $ref +// ReadInfoFromBytes unmarshals a file as a yaml.MapSlice. +func ReadInfoFromBytes(filename string, bytes []byte) (interface{}, error) { + initializeInfoCache() + cachedInfo, ok := infoCache[filename] + if ok { + if verboseReader { + log.Printf("Cache hit info for file %s", filename) + } + return cachedInfo, nil + } + if verboseReader { + log.Printf("Reading info for file %s", filename) + } + var info yaml.MapSlice + err := yaml.Unmarshal(bytes, &info) + if err != nil { + return nil, err + } + infoCache[filename] = info + return info, nil +} + +// ReadInfoForRef reads a file and return the fragment needed to resolve a $ref. func ReadInfoForRef(basefile string, ref string) (interface{}, error) { initializeInfoCache() { - info, ok := info_cache[ref] + info, ok := infoCache[ref] if ok { - if VERBOSE_READER { + if verboseReader { log.Printf("Cache hit for ref %s#%s", basefile, ref) } return info, nil } } - if VERBOSE_READER { + if verboseReader { log.Printf("Reading info for ref %s#%s", basefile, ref) } count = count + 1 @@ -136,7 +132,11 @@ func ReadInfoForRef(basefile string, ref string) (interface{}, error) { } else { filename = basefile } - info, err := ReadInfoForFile(filename) + bytes, err := ReadBytesForFile(filename) + if err != nil { + return nil, err + } + info, err := ReadInfoFromBytes(filename, bytes) if err != nil { log.Printf("File error: %v\n", err) } else { @@ -154,7 +154,7 @@ func ReadInfoForRef(basefile string, ref string) (interface{}, error) { } } if !found { - info_cache[ref] = nil + infoCache[ref] = nil return nil, NewError(nil, fmt.Sprintf("could not resolve %s", ref)) } } @@ -162,6 +162,6 @@ func ReadInfoForRef(basefile string, ref string) (interface{}, error) { } } } - info_cache[ref] = info + infoCache[ref] = info return info, nil } diff --git a/vendor/github.com/googleapis/gnostic/extensions/BUILD b/vendor/github.com/googleapis/gnostic/extensions/BUILD index 9268e3bf24..da13d97931 100644 --- a/vendor/github.com/googleapis/gnostic/extensions/BUILD +++ b/vendor/github.com/googleapis/gnostic/extensions/BUILD @@ -18,7 +18,6 @@ go_library( "//vendor/github.com/golang/protobuf/proto:go_default_library", "//vendor/github.com/golang/protobuf/ptypes:go_default_library", "//vendor/github.com/golang/protobuf/ptypes/any:go_default_library", - "//vendor/gopkg.in/yaml.v2:go_default_library", ], ) diff --git a/vendor/github.com/googleapis/gnostic/extensions/COMPILE-EXTENSION.sh b/vendor/github.com/googleapis/gnostic/extensions/COMPILE-EXTENSION.sh index 64badc4035..68d02a02ac 100755 --- a/vendor/github.com/googleapis/gnostic/extensions/COMPILE-EXTENSION.sh +++ b/vendor/github.com/googleapis/gnostic/extensions/COMPILE-EXTENSION.sh @@ -3,5 +3,3 @@ go get github.com/golang/protobuf/protoc-gen-go protoc \ --go_out=Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. *.proto -go build -go install diff --git a/vendor/github.com/googleapis/gnostic/extensions/extensions.go b/vendor/github.com/googleapis/gnostic/extensions/extensions.go index 12800ac58b..94a8e62a77 100644 --- a/vendor/github.com/googleapis/gnostic/extensions/extensions.go +++ b/vendor/github.com/googleapis/gnostic/extensions/extensions.go @@ -21,40 +21,39 @@ import ( "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" - "gopkg.in/yaml.v2" ) type documentHandler func(version string, extensionName string, document string) -type extensionHandler func(name string, info yaml.MapSlice) (bool, proto.Message, error) +type extensionHandler func(name string, yamlInput string) (bool, proto.Message, error) func forInputYamlFromOpenapic(handler documentHandler) { data, err := ioutil.ReadAll(os.Stdin) - if err != nil { fmt.Println("File error:", err.Error()) os.Exit(1) } + if len(data) == 0 { + fmt.Println("No input data.") + os.Exit(1) + } request := &ExtensionHandlerRequest{} err = proto.Unmarshal(data, request) + if err != nil { + fmt.Println("Input error:", err.Error()) + os.Exit(1) + } handler(request.Wrapper.Version, request.Wrapper.ExtensionName, request.Wrapper.Yaml) } +// ProcessExtension calles the handler for a specified extension. func ProcessExtension(handleExtension extensionHandler) { response := &ExtensionHandlerResponse{} forInputYamlFromOpenapic( func(version string, extensionName string, yamlInput string) { - var info yaml.MapSlice var newObject proto.Message var err error - err = yaml.Unmarshal([]byte(yamlInput), &info) - if err != nil { - response.Error = append(response.Error, err.Error()) - responseBytes, _ := proto.Marshal(response) - os.Stdout.Write(responseBytes) - os.Exit(0) - } - handled, newObject, err := handleExtension(extensionName, info) + handled, newObject, err := handleExtension(extensionName, yamlInput) if !handled { responseBytes, _ := proto.Marshal(response) os.Stdout.Write(responseBytes)