From 28e75e203c7f86e8d17524077bb76826481fcf26 Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Tue, 7 Jul 2020 15:43:46 -0700 Subject: [PATCH 01/13] small steps toward yaml.v3 conversion --- jsonschema/writer.go | 323 ++++++++++++++++++++++++------------------- 1 file changed, 179 insertions(+), 144 deletions(-) diff --git a/jsonschema/writer.go b/jsonschema/writer.go index 3187c455..3bdfe0b1 100644 --- a/jsonschema/writer.go +++ b/jsonschema/writer.go @@ -16,74 +16,55 @@ package jsonschema import ( "fmt" - "gopkg.in/yaml.v2" + + "gopkg.in/yaml.v3" ) const indentation = " " -func renderMap(info interface{}, indent string) (result string) { +func renderMappingNode(node *yaml.Node, indent string) (result string) { result = "{\n" innerIndent := indent + indentation - switch pairs := info.(type) { - case yaml.MapSlice: - for i, pair := range pairs { - // first print the key - result += fmt.Sprintf("%s\"%+v\": ", innerIndent, pair.Key) - // then the value - switch value := pair.Value.(type) { - case string: - result += "\"" + value + "\"" - case bool: - if value { - result += "true" - } else { - result += "false" - } - case []interface{}: - result += renderArray(value, innerIndent) - case yaml.MapSlice: - result += renderMap(value, innerIndent) - case int: - result += fmt.Sprintf("%d", value) - case int64: - result += fmt.Sprintf("%d", value) - case []string: - result += renderStringArray(value, innerIndent) - default: - result += fmt.Sprintf("???MapItem(Key:%+v, Value:%T)", value, value) - } - if i < len(pairs)-1 { - result += "," - } - result += "\n" + for i := 0; i < len(node.Content); i += 2 { + // first print the key + key := node.Content[i].Value + result += fmt.Sprintf("%s\"%+v\": ", innerIndent, key) + // then the value + value := node.Content[i+1] + switch value.Kind { + case yaml.ScalarNode: + result += "\"" + value.Value + "\"" + case yaml.MappingNode: + result += renderMappingNode(value, innerIndent) + case yaml.SequenceNode: + result += renderSequenceNode(value, innerIndent) + default: + result += fmt.Sprintf("???MapItem(Key:%+v, Value:%T)", value, value) } - default: - // t is some other type that we didn't name. + if i < len(node.Content)-2 { + result += "," + } + result += "\n" } result += indent + "}" return result } -func renderArray(array []interface{}, indent string) (result string) { +func renderSequenceNode(node *yaml.Node, indent string) (result string) { result = "[\n" innerIndent := indent + indentation - for i, item := range array { - switch item := item.(type) { - case string: - result += innerIndent + "\"" + item + "\"" - case bool: - if item { - result += innerIndent + "true" - } else { - result += innerIndent + "false" - } - case yaml.MapSlice: - result += innerIndent + renderMap(item, innerIndent) + "" + for i := 0; i < len(node.Content); i++ { + item := node.Content[i] + switch item.Kind { + case yaml.ScalarNode: + result += innerIndent + "\"" + item.Value + "\"" + case yaml.MappingNode: + result += innerIndent + renderMappingNode(item, innerIndent) + "" default: result += innerIndent + fmt.Sprintf("???ArrayItem(%+v)", item) } - if i < len(array)-1 { + if i < len(node.Content)-1 { result += "," } result += "\n" @@ -106,229 +87,283 @@ func renderStringArray(array []string, indent string) (result string) { return result } -func Render(info yaml.MapSlice) string { - return renderMap(info, "") + "\n" +// Render renders a yaml.Node as JSON +func Render(node *yaml.Node) string { + if node.Kind == yaml.DocumentNode { + if len(node.Content) == 1 { + return Render(node.Content[0]) + } + } else if node.Kind == yaml.MappingNode { + return renderMappingNode(node, "") + "\n" + } else if node.Kind == yaml.SequenceNode { + return renderSequenceNode(node, "") + "\n" + } + return "" } -func (object *SchemaNumber) jsonValue() interface{} { +func (object *SchemaNumber) nodeValue() *yaml.Node { if object.Integer != nil { - return object.Integer + return nodeForInt64(*object.Integer) } else if object.Float != nil { - return object.Float + return nodeForFloat64(*object.Float) } else { return nil } } -func (object *SchemaOrBoolean) jsonValue() interface{} { +func (object *SchemaOrBoolean) nodeValue() *yaml.Node { if object.Schema != nil { - return object.Schema.jsonValue() + return object.Schema.nodeValue() } else if object.Boolean != nil { - return *object.Boolean + return nodeForBoolean(*object.Boolean) } else { return nil } } -func (object *StringOrStringArray) jsonValue() interface{} { +func nodeForStringArray(array []string) *yaml.Node { + content := make([]*yaml.Node, 0) + for _, item := range array { + content = append(content, nodeForString(item)) + } + return nodeForSequence(content) +} + +func nodeForSchemaArray(array []*Schema) *yaml.Node { + content := make([]*yaml.Node, 0) + for _, item := range array { + content = append(content, item.nodeValue()) + } + return nodeForSequence(content) +} + +func (object *StringOrStringArray) nodeValue() *yaml.Node { if object.String != nil { - return *object.String + return nodeForString(*object.String) } else if object.StringArray != nil { - array := make([]interface{}, 0) - for _, item := range *(object.StringArray) { - array = append(array, item) - } - return array + return nodeForStringArray(*(object.StringArray)) } else { return nil } } -func (object *SchemaOrStringArray) jsonValue() interface{} { +func (object *SchemaOrStringArray) nodeValue() *yaml.Node { if object.Schema != nil { - return object.Schema.jsonValue() + return object.Schema.nodeValue() } else if object.StringArray != nil { - array := make([]interface{}, 0) - for _, item := range *(object.StringArray) { - array = append(array, item) - } - return array + return nodeForStringArray(*(object.StringArray)) } else { return nil } } -func (object *SchemaOrSchemaArray) jsonValue() interface{} { +func (object *SchemaOrSchemaArray) nodeValue() *yaml.Node { if object.Schema != nil { - return object.Schema.jsonValue() + return object.Schema.nodeValue() } else if object.SchemaArray != nil { - array := make([]interface{}, 0) - for _, item := range *(object.SchemaArray) { - array = append(array, item.jsonValue()) - } - return array + return nodeForSchemaArray(*(object.SchemaArray)) } else { return nil } } -func (object *SchemaEnumValue) jsonValue() interface{} { +func (object *SchemaEnumValue) nodeValue() *yaml.Node { if object.String != nil { - return *object.String + return nodeForString(*object.String) } else if object.Bool != nil { - return *object.Bool + return nodeForBoolean(*object.Bool) } else { return nil } } -func namedSchemaArrayValue(array *[]*NamedSchema) interface{} { - m2 := yaml.MapSlice{} +func nodeForNamedSchemaArray(array *[]*NamedSchema) *yaml.Node { + content := make([]*yaml.Node, 0) for _, pair := range *(array) { - var item2 yaml.MapItem - item2.Key = pair.Name - item2.Value = pair.Value.jsonValue() - m2 = append(m2, item2) + content = appendPair(content, pair.Name, pair.Value.nodeValue()) } - return m2 + return nodeForMapping(content) } -func namedSchemaOrStringArrayValue(array *[]*NamedSchemaOrStringArray) interface{} { - m2 := yaml.MapSlice{} +func nodeForNamedSchemaOrStringArray(array *[]*NamedSchemaOrStringArray) *yaml.Node { + content := make([]*yaml.Node, 0) for _, pair := range *(array) { - var item2 yaml.MapItem - item2.Key = pair.Name - item2.Value = pair.Value.jsonValue() - m2 = append(m2, item2) + content = appendPair(content, pair.Name, pair.Value.nodeValue()) } - return m2 + return nodeForMapping(content) } -func schemaEnumArrayValue(array *[]SchemaEnumValue) []interface{} { - a := make([]interface{}, 0) +func nodeForSchemaEnumArray(array *[]SchemaEnumValue) *yaml.Node { + content := make([]*yaml.Node, 0) for _, item := range *array { - a = append(a, item.jsonValue()) + content = append(content, item.nodeValue()) } - return a + return nodeForSequence(content) } -func schemaArrayValue(array *[]*Schema) []interface{} { - a := make([]interface{}, 0) - for _, item := range *array { - a = append(a, item.jsonValue()) +func nodeForMapping(content []*yaml.Node) *yaml.Node { + return &yaml.Node{ + Kind: yaml.MappingNode, + Content: content, + } +} + +func nodeForSequence(content []*yaml.Node) *yaml.Node { + return &yaml.Node{ + Kind: yaml.SequenceNode, + Content: content, + } +} + +func nodeForString(value string) *yaml.Node { + return &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!string", + Value: value, + } +} + +func nodeForBoolean(value bool) *yaml.Node { + return &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!bool", + Value: fmt.Sprintf("%t", value), } - return a } -func (schema *Schema) jsonValue() yaml.MapSlice { - m := yaml.MapSlice{} +func nodeForInt64(value int64) *yaml.Node { + return &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!int", + Value: fmt.Sprintf("%d", value), + } +} + +func nodeForFloat64(value float64) *yaml.Node { + return &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!float", + Value: fmt.Sprintf("%f", value), + } +} + +func appendPair(nodes []*yaml.Node, name string, value *yaml.Node) []*yaml.Node { + nodes = append(nodes, nodeForString(name)) + nodes = append(nodes, value) + return nodes +} + +func (schema *Schema) nodeValue() *yaml.Node { + n := &yaml.Node{Kind: yaml.MappingNode} + content := make([]*yaml.Node, 0) if schema.Title != nil { - m = append(m, yaml.MapItem{Key: "title", Value: *schema.Title}) + content = appendPair(content, "title", nodeForString(*schema.Title)) } if schema.ID != nil { - m = append(m, yaml.MapItem{Key: "id", Value: *schema.ID}) + content = appendPair(content, "id", nodeForString(*schema.ID)) } if schema.Schema != nil { - m = append(m, yaml.MapItem{Key: "$schema", Value: *schema.Schema}) + content = appendPair(content, "$schema", nodeForString(*schema.Schema)) } if schema.Type != nil { - m = append(m, yaml.MapItem{Key: "type", Value: schema.Type.jsonValue()}) + content = appendPair(content, "type", schema.Type.nodeValue()) } if schema.Items != nil { - m = append(m, yaml.MapItem{Key: "items", Value: schema.Items.jsonValue()}) + content = appendPair(content, "items", schema.Items.nodeValue()) } if schema.Description != nil { - m = append(m, yaml.MapItem{Key: "description", Value: *schema.Description}) + content = appendPair(content, "description", nodeForString(*schema.Description)) } if schema.Required != nil { - m = append(m, yaml.MapItem{Key: "required", Value: *schema.Required}) + content = appendPair(content, "required", nodeForStringArray(*schema.Required)) } if schema.AdditionalProperties != nil { - m = append(m, yaml.MapItem{Key: "additionalProperties", Value: schema.AdditionalProperties.jsonValue()}) + content = appendPair(content, "additionalProperties", schema.AdditionalProperties.nodeValue()) } if schema.PatternProperties != nil { - m = append(m, yaml.MapItem{Key: "patternProperties", Value: namedSchemaArrayValue(schema.PatternProperties)}) + content = appendPair(content, "patternProperties", nodeForNamedSchemaArray(schema.PatternProperties)) } if schema.Properties != nil { - m = append(m, yaml.MapItem{Key: "properties", Value: namedSchemaArrayValue(schema.Properties)}) + content = appendPair(content, "properties", nodeForNamedSchemaArray(schema.Properties)) } if schema.Dependencies != nil { - m = append(m, yaml.MapItem{Key: "dependencies", Value: namedSchemaOrStringArrayValue(schema.Dependencies)}) + content = appendPair(content, "dependencies", nodeForNamedSchemaOrStringArray(schema.Dependencies)) } if schema.Ref != nil { - m = append(m, yaml.MapItem{Key: "$ref", Value: *schema.Ref}) + content = appendPair(content, "$ref", nodeForString(*schema.Ref)) } if schema.MultipleOf != nil { - m = append(m, yaml.MapItem{Key: "multipleOf", Value: schema.MultipleOf.jsonValue()}) + content = appendPair(content, "multipleOf", schema.MultipleOf.nodeValue()) } if schema.Maximum != nil { - m = append(m, yaml.MapItem{Key: "maximum", Value: schema.Maximum.jsonValue()}) + content = appendPair(content, "maximum", schema.Maximum.nodeValue()) } if schema.ExclusiveMaximum != nil { - m = append(m, yaml.MapItem{Key: "exclusiveMaximum", Value: schema.ExclusiveMaximum}) + content = appendPair(content, "exclusiveMaximum", nodeForBoolean(*schema.ExclusiveMaximum)) } if schema.Minimum != nil { - m = append(m, yaml.MapItem{Key: "minimum", Value: schema.Minimum.jsonValue()}) + content = appendPair(content, "minimum", schema.Minimum.nodeValue()) } if schema.ExclusiveMinimum != nil { - m = append(m, yaml.MapItem{Key: "exclusiveMinimum", Value: schema.ExclusiveMinimum}) + content = appendPair(content, "exclusiveMinimum", nodeForBoolean(*schema.ExclusiveMinimum)) } if schema.MaxLength != nil { - m = append(m, yaml.MapItem{Key: "maxLength", Value: *schema.MaxLength}) + content = appendPair(content, "maxLength", nodeForInt64(*schema.MaxLength)) } if schema.MinLength != nil { - m = append(m, yaml.MapItem{Key: "minLength", Value: *schema.MinLength}) + content = appendPair(content, "minLength", nodeForInt64(*schema.MinLength)) } if schema.Pattern != nil { - m = append(m, yaml.MapItem{Key: "pattern", Value: *schema.Pattern}) + content = appendPair(content, "pattern", nodeForString(*schema.Pattern)) } if schema.AdditionalItems != nil { - m = append(m, yaml.MapItem{Key: "additionalItems", Value: schema.AdditionalItems.jsonValue()}) + content = appendPair(content, "additionalItems", schema.AdditionalItems.nodeValue()) } if schema.MaxItems != nil { - m = append(m, yaml.MapItem{Key: "maxItems", Value: *schema.MaxItems}) + content = appendPair(content, "maxItems", nodeForInt64(*schema.MaxItems)) } if schema.MinItems != nil { - m = append(m, yaml.MapItem{Key: "minItems", Value: *schema.MinItems}) + content = appendPair(content, "minItems", nodeForInt64(*schema.MinItems)) } if schema.UniqueItems != nil { - m = append(m, yaml.MapItem{Key: "uniqueItems", Value: *schema.UniqueItems}) + content = appendPair(content, "uniqueItems", nodeForBoolean(*schema.UniqueItems)) } if schema.MaxProperties != nil { - m = append(m, yaml.MapItem{Key: "maxProperties", Value: *schema.MaxProperties}) + content = appendPair(content, "maxProperties", nodeForInt64(*schema.MaxProperties)) } if schema.MinProperties != nil { - m = append(m, yaml.MapItem{Key: "minProperties", Value: *schema.MinProperties}) + content = appendPair(content, "minProperties", nodeForInt64(*schema.MinProperties)) } if schema.Enumeration != nil { - m = append(m, yaml.MapItem{Key: "enum", Value: schemaEnumArrayValue(schema.Enumeration)}) + content = appendPair(content, "enum", nodeForSchemaEnumArray(schema.Enumeration)) } if schema.AllOf != nil { - m = append(m, yaml.MapItem{Key: "allOf", Value: schemaArrayValue(schema.AllOf)}) + content = appendPair(content, "allOf", nodeForSchemaArray(*schema.AllOf)) } if schema.AnyOf != nil { - m = append(m, yaml.MapItem{Key: "anyOf", Value: schemaArrayValue(schema.AnyOf)}) + content = appendPair(content, "anyOf", nodeForSchemaArray(*schema.AnyOf)) } if schema.OneOf != nil { - m = append(m, yaml.MapItem{Key: "oneOf", Value: schemaArrayValue(schema.OneOf)}) + content = appendPair(content, "oneOf", nodeForSchemaArray(*schema.OneOf)) } if schema.Not != nil { - m = append(m, yaml.MapItem{Key: "not", Value: schema.Not.jsonValue()}) + content = appendPair(content, "not", schema.Not.nodeValue()) } if schema.Definitions != nil { - m = append(m, yaml.MapItem{Key: "definitions", Value: namedSchemaArrayValue(schema.Definitions)}) + content = appendPair(content, "definitions", nodeForNamedSchemaArray(schema.Definitions)) } if schema.Default != nil { - m = append(m, yaml.MapItem{Key: "default", Value: *schema.Default}) + // m = append(m, yaml.MapItem{Key: "default", Value: *schema.Default}) } if schema.Format != nil { - m = append(m, yaml.MapItem{Key: "format", Value: *schema.Format}) + content = appendPair(content, "format", nodeForString(*schema.Format)) } - return m + n.Content = content + return n } // JSONString returns a json representation of a schema. func (schema *Schema) JSONString() string { - info := schema.jsonValue() - return Render(info) + node := schema.nodeValue() + return Render(node) } From e450c323a8da7124b92b0ca8bd7cd3bacc374f90 Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Thu, 9 Jul 2020 08:30:46 -0700 Subject: [PATCH 02/13] Read and write json schemas with yaml.v3 --- compiler/helpers.go | 3 +- go.mod | 2 + go.sum | 8 + jsonschema/models.go | 4 +- jsonschema/reader.go | 315 +++++++++++++++++++++------------------ jsonschema/writer.go | 2 +- metrics/vocabulary.pb.go | 2 +- tools/j2y2j/main.go | 13 +- 8 files changed, 190 insertions(+), 159 deletions(-) diff --git a/compiler/helpers.go b/compiler/helpers.go index 3616ec41..88779525 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -22,6 +22,7 @@ import ( "github.com/googleapis/gnostic/jsonschema" "gopkg.in/yaml.v2" + yamlv3 "gopkg.in/yaml.v3" ) // compiler helper functions, usually called from generated code @@ -200,7 +201,7 @@ func StringValue(item interface{}) (value string, ok bool) { // Description returns a human-readable represention of an item. func Description(item interface{}) string { - value, ok := item.(yaml.MapSlice) + value, ok := item.(*yamlv3.Node) if ok { return jsonschema.Render(value) } diff --git a/go.mod b/go.mod index 8a8f0aa5..1edf3fab 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,9 @@ require ( github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 github.com/golang/protobuf v1.4.2 github.com/kr/pretty v0.2.0 // indirect + github.com/stoewer/go-strcase v1.2.0 google.golang.org/protobuf v1.23.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 gopkg.in/yaml.v2 v2.2.2 + gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 ) diff --git a/go.sum b/go.sum index de4a47bf..452af758 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -15,6 +16,11 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= +github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -28,3 +34,5 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/jsonschema/models.go b/jsonschema/models.go index 67f1f914..65dffbff 100644 --- a/jsonschema/models.go +++ b/jsonschema/models.go @@ -16,6 +16,8 @@ // of JSON Schemas. package jsonschema +import "gopkg.in/yaml.v3" + // The Schema struct models a JSON Schema and, because schemas are // defined hierarchically, contains many references to itself. // All fields are pointers and are nil if the associated values @@ -66,7 +68,7 @@ type Schema struct { // 6. Metadata keywords Title *string Description *string - Default *interface{} + Default *yaml.Node // 7. Semantic validation with "format" Format *string diff --git a/jsonschema/reader.go b/jsonschema/reader.go index 9fabbe82..89015ca1 100644 --- a/jsonschema/reader.go +++ b/jsonschema/reader.go @@ -19,8 +19,9 @@ package jsonschema import ( "fmt" "io/ioutil" + "strconv" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) // This is a global map of all known Schemas. @@ -33,12 +34,12 @@ func NewBaseSchema() (schema *Schema, err error) { if err != nil { return nil, err } - var info yaml.MapSlice - err = yaml.Unmarshal(b, &info) + var node yaml.Node + err = yaml.Unmarshal(b, &node) if err != nil { return nil, err } - return NewSchemaFromObject(info), nil + return NewSchemaFromObject(&node), nil } // NewSchemaFromFile reads a schema from a file. @@ -48,27 +49,27 @@ func NewSchemaFromFile(filename string) (schema *Schema, err error) { if err != nil { return nil, err } - var info yaml.MapSlice - err = yaml.Unmarshal(file, &info) + var node yaml.Node + err = yaml.Unmarshal(file, &node) if err != nil { return nil, err } - return NewSchemaFromObject(info), nil + return NewSchemaFromObject(&node), nil } // NewSchemaFromObject constructs a schema from a parsed JSON object. // Due to the complexity of the schema representation, this is a // custom reader and not the standard Go JSON reader (encoding/json). -func NewSchemaFromObject(jsonData interface{}) *Schema { - switch t := jsonData.(type) { - default: - fmt.Printf("schemaValue: unexpected type %T\n", t) - return nil - case yaml.MapSlice: +func NewSchemaFromObject(jsonData *yaml.Node) *Schema { + switch jsonData.Kind { + case yaml.DocumentNode: + return NewSchemaFromObject(jsonData.Content[0]) + case yaml.MappingNode: schema := &Schema{} - for _, mapItem := range t { - k := mapItem.Key.(string) - v := mapItem.Value + + for i := 0; i < len(jsonData.Content); i += 2 { + k := jsonData.Content[i].Value + v := jsonData.Content[i+1] switch k { case "$schema": @@ -142,7 +143,7 @@ func NewSchemaFromObject(jsonData interface{}) *Schema { schema.Description = schema.stringValue(v) case "default": - schema.Default = &v + schema.Default = v case "format": schema.Format = schema.stringValue(v) @@ -161,7 +162,12 @@ func NewSchemaFromObject(jsonData interface{}) *Schema { schemas[*(schema.ID)] = schema } return schema + + default: + fmt.Printf("schemaValue: unexpected node %+v\n", jsonData) + return nil } + return nil } @@ -172,254 +178,265 @@ func NewSchemaFromObject(jsonData interface{}) *Schema { // // Gets the string value of an interface{} value if possible. -func (schema *Schema) stringValue(v interface{}) *string { - switch v := v.(type) { +func (schema *Schema) stringValue(v *yaml.Node) *string { + switch v.Kind { + case yaml.ScalarNode: + return &v.Value default: - fmt.Printf("stringValue: unexpected type %T\n", v) - case string: - return &v + fmt.Printf("stringValue: unexpected node %+v\n", v) } return nil } // Gets the numeric value of an interface{} value if possible. -func (schema *Schema) numberValue(v interface{}) *SchemaNumber { +func (schema *Schema) numberValue(v *yaml.Node) *SchemaNumber { number := &SchemaNumber{} - switch v := v.(type) { + switch v.Kind { + case yaml.ScalarNode: + switch v.Tag { + case "!!float": + v2, _ := strconv.ParseFloat(v.Value, 64) + number.Float = &v2 + return number + case "!!int": + v2, _ := strconv.ParseInt(v.Value, 10, 64) + number.Integer = &v2 + return number + default: + fmt.Printf("stringValue: unexpected node %+v\n", v) + } default: - fmt.Printf("numberValue: unexpected type %T\n", v) - case float64: - v2 := float64(v) - number.Float = &v2 - return number - case float32: - v2 := float64(v) - number.Float = &v2 - return number - case int: - v2 := int64(v) - number.Integer = &v2 + fmt.Printf("stringValue: unexpected node %+v\n", v) } return nil } // Gets the integer value of an interface{} value if possible. -func (schema *Schema) intValue(v interface{}) *int64 { - switch v := v.(type) { +func (schema *Schema) intValue(v *yaml.Node) *int64 { + switch v.Kind { + case yaml.ScalarNode: + switch v.Tag { + case "!!float": + v2, _ := strconv.ParseFloat(v.Value, 64) + v3 := int64(v2) + return &v3 + case "!!int": + v2, _ := strconv.ParseInt(v.Value, 10, 64) + return &v2 + default: + fmt.Printf("intValue: unexpected node %+v\n", v) + } default: - fmt.Printf("intValue: unexpected type %T\n", v) - case float64: - v2 := int64(v) - return &v2 - case int64: - return &v - case int: - v2 := int64(v) - return &v2 + fmt.Printf("intValue: unexpected node %+v\n", v) } return nil } // Gets the bool value of an interface{} value if possible. -func (schema *Schema) boolValue(v interface{}) *bool { - switch v := v.(type) { +func (schema *Schema) boolValue(v *yaml.Node) *bool { + switch v.Kind { + case yaml.ScalarNode: + switch v.Tag { + case "!!bool": + v2, _ := strconv.ParseBool(v.Value) + return &v2 + default: + fmt.Printf("boolValue: unexpected node %+v\n", v) + } default: - fmt.Printf("boolValue: unexpected type %T\n", v) - case bool: - return &v + fmt.Printf("boolValue: unexpected node %+v\n", v) } return nil } // Gets a map of Schemas from an interface{} value if possible. -func (schema *Schema) mapOfSchemasValue(v interface{}) *[]*NamedSchema { - switch v := v.(type) { - default: - fmt.Printf("mapOfSchemasValue: unexpected type %T\n", v) - case yaml.MapSlice: +func (schema *Schema) mapOfSchemasValue(v *yaml.Node) *[]*NamedSchema { + switch v.Kind { + case yaml.MappingNode: m := make([]*NamedSchema, 0) - for _, mapItem := range v { - k2 := mapItem.Key.(string) - v2 := mapItem.Value + for i := 0; i < len(v.Content); i += 2 { + k2 := v.Content[i].Value + v2 := v.Content[i+1] pair := &NamedSchema{Name: k2, Value: NewSchemaFromObject(v2)} m = append(m, pair) } return &m + default: + fmt.Printf("mapOfSchemasValue: unexpected node %+v\n", v) } return nil } // Gets an array of Schemas from an interface{} value if possible. -func (schema *Schema) arrayOfSchemasValue(v interface{}) *[]*Schema { - switch v := v.(type) { - default: - fmt.Printf("arrayOfSchemasValue: unexpected type %T\n", v) - case []interface{}: +func (schema *Schema) arrayOfSchemasValue(v *yaml.Node) *[]*Schema { + switch v.Kind { + case yaml.SequenceNode: m := make([]*Schema, 0) - for _, v2 := range v { - switch v2 := v2.(type) { - default: - fmt.Printf("arrayOfSchemasValue: unexpected type %T\n", v2) - case yaml.MapSlice: + for _, v2 := range v.Content { + switch v2.Kind { + case yaml.MappingNode: s := NewSchemaFromObject(v2) m = append(m, s) + default: + fmt.Printf("arrayOfSchemasValue: unexpected node %+v\n", v2) } } return &m - case yaml.MapSlice: + case yaml.MappingNode: m := make([]*Schema, 0) s := NewSchemaFromObject(v) m = append(m, s) return &m + default: + fmt.Printf("arrayOfSchemasValue: unexpected node %+v\n", v) } return nil } // Gets a Schema or an array of Schemas from an interface{} value if possible. -func (schema *Schema) schemaOrSchemaArrayValue(v interface{}) *SchemaOrSchemaArray { - switch v := v.(type) { - default: - fmt.Printf("schemaOrSchemaArrayValue: unexpected type %T\n", v) - case []interface{}: +func (schema *Schema) schemaOrSchemaArrayValue(v *yaml.Node) *SchemaOrSchemaArray { + switch v.Kind { + case yaml.SequenceNode: m := make([]*Schema, 0) - for _, v2 := range v { - switch v2 := v2.(type) { - default: - fmt.Printf("schemaOrSchemaArrayValue: unexpected type %T\n", v2) - case map[string]interface{}: + for _, v2 := range v.Content { + switch v2.Kind { + case yaml.MappingNode: s := NewSchemaFromObject(v2) m = append(m, s) + default: + fmt.Printf("schemaOrSchemaArrayValue: unexpected node %+v\n", v2) } } return &SchemaOrSchemaArray{SchemaArray: &m} - case yaml.MapSlice: + case yaml.MappingNode: s := NewSchemaFromObject(v) return &SchemaOrSchemaArray{Schema: s} + default: + fmt.Printf("schemaOrSchemaArrayValue: unexpected node %+v\n", v) } return nil } // Gets an array of strings from an interface{} value if possible. -func (schema *Schema) arrayOfStringsValue(v interface{}) *[]string { - switch v := v.(type) { - default: - fmt.Printf("arrayOfStringsValue: unexpected type %T\n", v) - case []string: - return &v - case string: - a := []string{v} +func (schema *Schema) arrayOfStringsValue(v *yaml.Node) *[]string { + switch v.Kind { + case yaml.ScalarNode: + a := []string{v.Value} return &a - case []interface{}: + case yaml.SequenceNode: a := make([]string, 0) - for _, v2 := range v { - switch v2 := v2.(type) { + for _, v2 := range v.Content { + switch v2.Kind { + case yaml.ScalarNode: + a = append(a, v2.Value) default: - fmt.Printf("arrayOfStringsValue: unexpected type %T\n", v2) - case string: - a = append(a, v2) + fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v2) } } return &a + default: + fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v) } return nil } // Gets a string or an array of strings from an interface{} value if possible. -func (schema *Schema) stringOrStringArrayValue(v interface{}) *StringOrStringArray { - switch v := v.(type) { - default: - fmt.Printf("arrayOfStringsValue: unexpected type %T\n", v) - case []string: - s := &StringOrStringArray{} - s.StringArray = &v - return s - case string: +func (schema *Schema) stringOrStringArrayValue(v *yaml.Node) *StringOrStringArray { + switch v.Kind { + case yaml.ScalarNode: s := &StringOrStringArray{} - s.String = &v + s.String = &v.Value return s - case []interface{}: + case yaml.SequenceNode: a := make([]string, 0) - for _, v2 := range v { - switch v2 := v2.(type) { + for _, v2 := range v.Content { + switch v2.Kind { + case yaml.ScalarNode: + a = append(a, v2.Value) default: - fmt.Printf("arrayOfStringsValue: unexpected type %T\n", v2) - case string: - a = append(a, v2) + fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v2) } } s := &StringOrStringArray{} s.StringArray = &a return s + default: + fmt.Printf("arrayOfStringsValue: unexpected node %+v\n", v) } return nil } // Gets an array of enum values from an interface{} value if possible. -func (schema *Schema) arrayOfEnumValuesValue(v interface{}) *[]SchemaEnumValue { +func (schema *Schema) arrayOfEnumValuesValue(v *yaml.Node) *[]SchemaEnumValue { a := make([]SchemaEnumValue, 0) - switch v := v.(type) { - default: - fmt.Printf("arrayOfEnumValuesValue: unexpected type %T\n", v) - case []interface{}: - for _, v2 := range v { - switch v2 := v2.(type) { + switch v.Kind { + case yaml.SequenceNode: + for _, v2 := range v.Content { + switch v2.Kind { + case yaml.ScalarNode: + switch v2.Tag { + case "!!str": + a = append(a, SchemaEnumValue{String: &v2.Value}) + case "!!bool": + v3, _ := strconv.ParseBool(v2.Value) + a = append(a, SchemaEnumValue{Bool: &v3}) + default: + fmt.Printf("arrayOfEnumValuesValue: unexpected type %s\n", v2.Tag) + } default: - fmt.Printf("arrayOfEnumValuesValue: unexpected type %T\n", v2) - case string: - a = append(a, SchemaEnumValue{String: &v2}) - case bool: - a = append(a, SchemaEnumValue{Bool: &v2}) + fmt.Printf("arrayOfEnumValuesValue: unexpected node %+v\n", v2) } } + default: + fmt.Printf("arrayOfEnumValuesValue: unexpected node %+v\n", v) } return &a } // Gets a map of schemas or string arrays from an interface{} value if possible. -func (schema *Schema) mapOfSchemasOrStringArraysValue(v interface{}) *[]*NamedSchemaOrStringArray { +func (schema *Schema) mapOfSchemasOrStringArraysValue(v *yaml.Node) *[]*NamedSchemaOrStringArray { m := make([]*NamedSchemaOrStringArray, 0) - switch v := v.(type) { - default: - fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected type %T %+v\n", v, v) - case yaml.MapSlice: - for _, mapItem := range v { - k2 := mapItem.Key.(string) - v2 := mapItem.Value - switch v2 := v2.(type) { - default: - fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected type %T %+v\n", v2, v2) - case []interface{}: + switch v.Kind { + case yaml.MappingNode: + for i := 0; i < len(v.Content); i += 2 { + k2 := v.Content[i].Value + v2 := v.Content[i+1] + switch v2.Kind { + case yaml.SequenceNode: a := make([]string, 0) - for _, v3 := range v2 { - switch v3 := v3.(type) { + for _, v3 := range v2.Content { + switch v3.Kind { + case yaml.ScalarNode: + a = append(a, v3.Value) default: - fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected type %T %+v\n", v3, v3) - case string: - a = append(a, v3) + fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v3) } } s := &SchemaOrStringArray{} s.StringArray = &a pair := &NamedSchemaOrStringArray{Name: k2, Value: s} m = append(m, pair) + default: + fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v2) } } + default: + fmt.Printf("mapOfSchemasOrStringArraysValue: unexpected node %+v\n", v) } return &m } // Gets a schema or a boolean value from an interface{} value if possible. -func (schema *Schema) schemaOrBooleanValue(v interface{}) *SchemaOrBoolean { +func (schema *Schema) schemaOrBooleanValue(v *yaml.Node) *SchemaOrBoolean { schemaOrBoolean := &SchemaOrBoolean{} - switch v := v.(type) { - case bool: - schemaOrBoolean.Boolean = &v - case yaml.MapSlice: + switch v.Kind { + case yaml.ScalarNode: + v2, _ := strconv.ParseBool(v.Value) + schemaOrBoolean.Boolean = &v2 + case yaml.MappingNode: schemaOrBoolean.Schema = NewSchemaFromObject(v) default: - fmt.Printf("schemaOrBooleanValue: unexpected type %T\n", v) - case []map[string]interface{}: - + fmt.Printf("schemaOrBooleanValue: unexpected node %+v\n", v) } return schemaOrBoolean } diff --git a/jsonschema/writer.go b/jsonschema/writer.go index 3bdfe0b1..0f9d4510 100644 --- a/jsonschema/writer.go +++ b/jsonschema/writer.go @@ -218,7 +218,7 @@ func nodeForSequence(content []*yaml.Node) *yaml.Node { func nodeForString(value string) *yaml.Node { return &yaml.Node{ Kind: yaml.ScalarNode, - Tag: "!!string", + Tag: "!!str", Value: value, } } diff --git a/metrics/vocabulary.pb.go b/metrics/vocabulary.pb.go index ffb2ece8..6ea247a7 100644 --- a/metrics/vocabulary.pb.go +++ b/metrics/vocabulary.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.3 +// protoc v3.12.0 // source: metrics/vocabulary.proto package gnostic_metrics_v1 diff --git a/tools/j2y2j/main.go b/tools/j2y2j/main.go index d2fb0429..15d73442 100644 --- a/tools/j2y2j/main.go +++ b/tools/j2y2j/main.go @@ -17,11 +17,12 @@ package main import ( "fmt" - "github.com/googleapis/gnostic/jsonschema" - "gopkg.in/yaml.v2" "io/ioutil" "os" "path" + + "github.com/googleapis/gnostic/jsonschema" + "gopkg.in/yaml.v3" ) func usage() { @@ -41,15 +42,15 @@ func main() { if err != nil { panic(err) } - var info yaml.MapSlice - err = yaml.Unmarshal(file, &info) + var node yaml.Node + err = yaml.Unmarshal(file, &node) switch os.Args[2] { case "--json": - result := jsonschema.Render(info) + result := jsonschema.Render(&node) fmt.Printf("%s", result) case "--yaml": - result, err := yaml.Marshal(info) + result, err := yaml.Marshal(&node) if err != nil { panic(err) } From 4d8977f1b76caa73116dc099b12c2faabc12f043 Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Thu, 9 Jul 2020 17:20:34 -0700 Subject: [PATCH 03/13] rewrite helpers to yaml.v3 (project fails to compile) --- compiler/helpers.go | 89 ++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/compiler/helpers.go b/compiler/helpers.go index 88779525..b5d54ae5 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -21,15 +21,14 @@ import ( "strconv" "github.com/googleapis/gnostic/jsonschema" - "gopkg.in/yaml.v2" - yamlv3 "gopkg.in/yaml.v3" + "gopkg.in/yaml.v3" ) // 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) +// UnpackMap gets a *yaml.Node if possible. +func UnpackMap(in interface{}) (*yaml.Node, bool) { + m, ok := in.(*yaml.Node) if ok { return m, true } @@ -37,38 +36,47 @@ func UnpackMap(in interface{}) (yaml.MapSlice, bool) { a, ok := in.([]interface{}) if ok && len(a) == 0 { // if so, return an empty map - return yaml.MapSlice{}, true + return &yaml.Node{ + Kind: yaml.MappingNode, + Content: make([]*yaml.Node, 0), + }, true } return nil, false } -// SortedKeysForMap returns the sorted keys of a yaml.MapSlice. -func SortedKeysForMap(m yaml.MapSlice) []string { +// SortedKeysForMap returns the sorted keys of a yamlv2.MapSlice. +func SortedKeysForMap(m *yaml.Node) []string { keys := make([]string, 0) - for _, item := range m { - keys = append(keys, item.Key.(string)) + if m.Kind == yaml.MappingNode { + for i := 0; i < len(m.Content); i += 2 { + keys = append(keys, m.Content[i].Value) + } } sort.Strings(keys) 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) - if ok && key == itemKey { - return true +// MapHasKey returns true if a yamlv2.MapSlice contains a specified key. +func MapHasKey(m *yaml.Node, key string) bool { + if m.Kind == yaml.MappingNode { + for i := 0; i < len(m.Content); i += 2 { + itemKey := m.Content[i].Value + if key == itemKey { + return true + } } } 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) - if ok && key == itemKey { - return item.Value +func MapValueForKey(m *yaml.Node, key string) *yaml.Node { + if m.Kind == yaml.MappingNode { + for i := 0; i < len(m.Content); i += 2 { + itemKey := m.Content[i].Value + if key == itemKey { + return m.Content[i+1] + } } } return nil @@ -87,7 +95,7 @@ func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string { } // MissingKeysInMap identifies which keys from a list of required keys are not in a map. -func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string { +func MissingKeysInMap(m *yaml.Node, requiredKeys []string) []string { missingKeys := make([]string, 0) for _, k := range requiredKeys { if !MapHasKey(m, k) { @@ -98,31 +106,28 @@ func MissingKeysInMap(m yaml.MapSlice, requiredKeys []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 { +func InvalidKeysInMap(m *yaml.Node, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string { invalidKeys := make([]string, 0) - for _, item := range m { - itemKey, ok := item.Key.(string) - if ok { - key := itemKey - found := false - // does the key match an allowed key? - for _, allowedKey := range allowedKeys { - if key == allowedKey { + for i := 0; i < len(m.Content); i += 2 { + key := m.Content[i].Value + found := false + // does the key match an allowed key? + for _, allowedKey := range allowedKeys { + if key == allowedKey { + found = true + break + } + } + if !found { + // does the key match an allowed pattern? + for _, allowedPattern := range allowedPatterns { + if allowedPattern.MatchString(key) { found = true break } } if !found { - // does the key match an allowed pattern? - for _, allowedPattern := range allowedPatterns { - if allowedPattern.MatchString(key) { - found = true - break - } - } - if !found { - invalidKeys = append(invalidKeys, key) - } + invalidKeys = append(invalidKeys, key) } } } @@ -201,7 +206,7 @@ func StringValue(item interface{}) (value string, ok bool) { // Description returns a human-readable represention of an item. func Description(item interface{}) string { - value, ok := item.(*yamlv3.Node) + value, ok := item.(*yaml.Node) if ok { return jsonschema.Render(value) } From 361fd805c6e3813d1744dc1ade1dd3ff2906640a Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Fri, 10 Jul 2020 20:52:38 -0700 Subject: [PATCH 04/13] major rework, compiles and passes some tests --- compiler/helpers.go | 179 +- compiler/reader.go | 38 +- discovery/discovery.go | 697 ++++--- discovery/discovery.pb.go | 2 +- discovery/discovery.proto | 2 +- generate-gnostic/generate-compiler.go | 127 +- generate-gnostic/generate-extension.go | 2 +- generate-gnostic/main.go | 4 +- lib/gnostic.go | 38 +- openapiv2/OpenAPIv2.go | 2343 ++++++++++++------------ openapiv2/OpenAPIv2.pb.go | 2 +- openapiv2/OpenAPIv2.proto | 2 +- openapiv3/OpenAPIv3.go | 1715 +++++++++-------- openapiv3/OpenAPIv3.pb.go | 32 +- openapiv3/OpenAPIv3.proto | 6 +- 15 files changed, 2848 insertions(+), 2341 deletions(-) diff --git a/compiler/helpers.go b/compiler/helpers.go index b5d54ae5..f18a35b1 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -28,19 +28,27 @@ import ( // UnpackMap gets a *yaml.Node if possible. func UnpackMap(in interface{}) (*yaml.Node, bool) { + if in == nil { + return nil, false + } m, ok := in.(*yaml.Node) if ok { + if m == nil { + return nil, false + } 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.Node{ - Kind: yaml.MappingNode, - Content: make([]*yaml.Node, 0), - }, true - } + /* + // do we have an empty array? + a, ok := in.([]interface{}) + if ok && len(a) == 0 { + // if so, return an empty map + return &yaml.Node{ + Kind: yaml.MappingNode, + Content: make([]*yaml.Node, 0), + }, true + } + */ return nil, false } @@ -58,6 +66,9 @@ func SortedKeysForMap(m *yaml.Node) []string { // MapHasKey returns true if a yamlv2.MapSlice contains a specified key. func MapHasKey(m *yaml.Node, key string) bool { + if m == nil { + return false + } if m.Kind == yaml.MappingNode { for i := 0; i < len(m.Content); i += 2 { itemKey := m.Content[i].Value @@ -71,6 +82,9 @@ func MapHasKey(m *yaml.Node, key string) bool { // MapValueForKey gets the value of a map value for a specified key. func MapValueForKey(m *yaml.Node, key string) *yaml.Node { + if m == nil { + return nil + } if m.Kind == yaml.MappingNode { for i := 0; i < len(m.Content); i += 2 { itemKey := m.Content[i].Value @@ -94,6 +108,85 @@ func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string { return stringArray } +// SequenceNodeForNode returns a node if it is a SequenceNode. +func SequenceNodeForNode(node *yaml.Node) (*yaml.Node, bool) { + if node.Kind != yaml.SequenceNode { + return nil, false + } + return node, true +} + +// BoolForScalarNode returns the bool value of a node. +func BoolForScalarNode(node *yaml.Node) (bool, bool) { + if node.Kind != yaml.ScalarNode { + return false, false + } + if node.Tag != "!!bool" { + return false, false + } + v, err := strconv.ParseBool(node.Value) + if err != nil { + return false, false + } + return v, true +} + +// IntForScalarNode returns the integer value of a node. +func IntForScalarNode(node *yaml.Node) (int64, bool) { + if node.Kind != yaml.ScalarNode { + return 0, false + } + if node.Tag != "!!int" { + return 0, false + } + v, err := strconv.ParseInt(node.Value, 10, 64) + if err != nil { + return 0, false + } + return v, true +} + +// FloatForScalarNode returns the float value of a node. +func FloatForScalarNode(node *yaml.Node) (float64, bool) { + if node.Kind != yaml.ScalarNode { + return 0.0, false + } + if (node.Tag != "!!int") && (node.Tag != "!!float") { + return 0.0, false + } + v, err := strconv.ParseFloat(node.Value, 64) + if err != nil { + return 0.0, false + } + return v, true +} + +// StringForScalarNode returns the string value of a node. +func StringForScalarNode(node *yaml.Node) (string, bool) { + if node == nil { + return "", false + } + if node.Kind != yaml.ScalarNode { + return "", false + } + if node.Tag != "!!str" { + return "", false + } + return node.Value, true +} + +// StringArrayForSequenceNode converts a sequence node to an array of strings, if possible. +func StringArrayForSequenceNode(node *yaml.Node) []string { + stringArray := make([]string, 0) + for _, item := range node.Content { + v, ok := StringForScalarNode(item) + if ok { + stringArray = append(stringArray, v) + } + } + return stringArray +} + // MissingKeysInMap identifies which keys from a list of required keys are not in a map. func MissingKeysInMap(m *yaml.Node, requiredKeys []string) []string { missingKeys := make([]string, 0) @@ -108,6 +201,9 @@ func MissingKeysInMap(m *yaml.Node, requiredKeys []string) []string { // InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns. func InvalidKeysInMap(m *yaml.Node, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string { invalidKeys := make([]string, 0) + if m == nil || m.Kind != yaml.MappingNode { + return invalidKeys + } for i := 0; i < len(m.Content); i += 2 { key := m.Content[i].Value found := false @@ -134,6 +230,71 @@ func InvalidKeysInMap(m *yaml.Node, allowedKeys []string, allowedPatterns []*reg return invalidKeys } +// NewMappingNode creates a new Mapping node. +func NewMappingNode() *yaml.Node { + return &yaml.Node{ + Kind: yaml.MappingNode, + Content: make([]*yaml.Node, 0), + } +} + +// NewSequenceNode creates a new Sequence node. +func NewSequenceNode() *yaml.Node { + node := &yaml.Node{ + Kind: yaml.SequenceNode, + Content: make([]*yaml.Node, 0), + } + return node +} + +// NewScalarNodeForString creates a new node to hold a string. +func NewScalarNodeForString(s string) *yaml.Node { + return &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!str", + Value: s, + } +} + +// NewSequenceNodeForStringArray creates a new node to hold an array of strings. +func NewSequenceNodeForStringArray(strings []string) *yaml.Node { + node := &yaml.Node{ + Kind: yaml.SequenceNode, + Content: make([]*yaml.Node, 0), + } + for _, s := range strings { + node.Content = append(node.Content, NewScalarNodeForString(s)) + } + return node +} + +// NewScalarNodeForBool creates a new node to hold a bool. +func NewScalarNodeForBool(b bool) *yaml.Node { + return &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!bool", + Value: fmt.Sprintf("%t", b), + } +} + +// NewScalarNodeForFloat creates a new node to hold a float. +func NewScalarNodeForFloat(f float64) *yaml.Node { + return &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!float", + Value: fmt.Sprintf("%g", f), + } +} + +// NewScalarNodeForInt creates a new node to hold an integer. +func NewScalarNodeForInt(i int64) *yaml.Node { + return &yaml.Node{ + Kind: yaml.ScalarNode, + Tag: "!!int", + Value: fmt.Sprintf("%d", i), + } +} + // DescribeMap describes a map (for debugging purposes). func DescribeMap(in interface{}, indent string) string { description := "" diff --git a/compiler/reader.go b/compiler/reader.go index 30d5dd92..6375a146 100644 --- a/compiler/reader.go +++ b/compiler/reader.go @@ -24,13 +24,13 @@ import ( "strings" "sync" - yaml "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v3" ) var verboseReader = false var fileCache map[string][]byte -var infoCache map[string]interface{} +var infoCache map[string]*yaml.Node var fileCacheEnable = true var infoCacheEnable = true @@ -54,7 +54,7 @@ func initializeFileCache() { func initializeInfoCache() { if infoCache == nil { - infoCache = make(map[string]interface{}, 0) + infoCache = make(map[string]*yaml.Node, 0) } } @@ -109,7 +109,7 @@ func RemoveFromInfoCache(filename string) { } // GetInfoCache returns the info cache map. -func GetInfoCache() map[string]interface{} { +func GetInfoCache() map[string]*yaml.Node { infoCacheMutex.Lock() defer infoCacheMutex.Unlock() if infoCache == nil { @@ -129,7 +129,7 @@ func ClearFileCache() { func ClearInfoCache() { infoCacheMutex.Lock() defer infoCacheMutex.Unlock() - infoCache = make(map[string]interface{}) + infoCache = make(map[string]*yaml.Node) } // ClearCaches clears all caches. @@ -201,14 +201,14 @@ func readBytesForFile(filename string) ([]byte, error) { return bytes, nil } -// ReadInfoFromBytes unmarshals a file as a yaml.MapSlice. -func ReadInfoFromBytes(filename string, bytes []byte) (interface{}, error) { +// ReadInfoFromBytes unmarshals a file as a *yaml.Node. +func ReadInfoFromBytes(filename string, bytes []byte) (*yaml.Node, error) { infoCacheMutex.Lock() defer infoCacheMutex.Unlock() return readInfoFromBytes(filename, bytes) } -func readInfoFromBytes(filename string, bytes []byte) (interface{}, error) { +func readInfoFromBytes(filename string, bytes []byte) (*yaml.Node, error) { initializeInfoCache() if infoCacheEnable { cachedInfo, ok := infoCache[filename] @@ -222,15 +222,15 @@ func readInfoFromBytes(filename string, bytes []byte) (interface{}, error) { log.Printf("Reading info for file %s", filename) } } - var info yaml.MapSlice + var info yaml.Node err := yaml.Unmarshal(bytes, &info) if err != nil { return nil, err } if infoCacheEnable && len(filename) > 0 { - infoCache[filename] = info + infoCache[filename] = &info } - return info, nil + return &info, nil } // ReadInfoForRef reads a file and return the fragment needed to resolve a $ref. @@ -269,19 +269,25 @@ func ReadInfoForRef(basefile string, ref string) (interface{}, error) { return nil, err } info, err := readInfoFromBytes(filename, bytes) + if info != nil && info.Kind == yaml.DocumentNode { + info = info.Content[0] + } if err != nil { log.Printf("File error: %v\n", err) } else { + if info == nil { + return nil, NewError(nil, fmt.Sprintf("could not resolve %s", ref)) + } if len(parts) > 1 { path := strings.Split(parts[1], "/") for i, key := range path { if i > 0 { - m, ok := info.(yaml.MapSlice) - if ok { + m := info + if true { found := false - for _, section := range m { - if section.Key == key { - info = section.Value + for i := 0; i < len(m.Content); i += 2 { + if m.Content[i].Value == key { + info = m.Content[i+1] found = true } } diff --git a/discovery/discovery.go b/discovery/discovery.go index d67456c6..5ea7da80 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package discovery_v1 import ( "fmt" "github.com/googleapis/gnostic/compiler" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" "regexp" "strings" ) @@ -48,9 +48,9 @@ func NewAnnotations(in interface{}, context *compiler.Context) (*Annotations, er // repeated string required = 1; v1 := compiler.MapValueForKey(m, "required") if v1 != nil { - v, ok := v1.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v1) if ok { - x.Required = compiler.ConvertInterfaceArrayToStringArray(v) + x.Required = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -123,7 +123,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string kind = 1; v1 := compiler.MapValueForKey(m, "kind") if v1 != nil { - x.Kind, ok = v1.(string) + x.Kind, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for kind: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -132,7 +132,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string discovery_version = 2; v2 := compiler.MapValueForKey(m, "discoveryVersion") if v2 != nil { - x.DiscoveryVersion, ok = v2.(string) + x.DiscoveryVersion, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for discoveryVersion: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -141,7 +141,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string id = 3; v3 := compiler.MapValueForKey(m, "id") if v3 != nil { - x.Id, ok = v3.(string) + x.Id, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for id: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -150,7 +150,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string name = 4; v4 := compiler.MapValueForKey(m, "name") if v4 != nil { - x.Name, ok = v4.(string) + x.Name, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -159,7 +159,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string version = 5; v5 := compiler.MapValueForKey(m, "version") if v5 != nil { - x.Version, ok = v5.(string) + x.Version, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -168,7 +168,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string revision = 6; v6 := compiler.MapValueForKey(m, "revision") if v6 != nil { - x.Revision, ok = v6.(string) + x.Revision, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for revision: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -177,7 +177,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string title = 7; v7 := compiler.MapValueForKey(m, "title") if v7 != nil { - x.Title, ok = v7.(string) + x.Title, ok = compiler.StringForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -186,7 +186,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string description = 8; v8 := compiler.MapValueForKey(m, "description") if v8 != nil { - x.Description, ok = v8.(string) + x.Description, ok = compiler.StringForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -204,7 +204,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string documentation_link = 10; v10 := compiler.MapValueForKey(m, "documentationLink") if v10 != nil { - x.DocumentationLink, ok = v10.(string) + x.DocumentationLink, ok = compiler.StringForScalarNode(v10) if !ok { message := fmt.Sprintf("has unexpected value for documentationLink: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) @@ -213,9 +213,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // repeated string labels = 11; v11 := compiler.MapValueForKey(m, "labels") if v11 != nil { - v, ok := v11.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v11) if ok { - x.Labels = compiler.ConvertInterfaceArrayToStringArray(v) + x.Labels = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for labels: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) @@ -224,7 +224,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string protocol = 12; v12 := compiler.MapValueForKey(m, "protocol") if v12 != nil { - x.Protocol, ok = v12.(string) + x.Protocol, ok = compiler.StringForScalarNode(v12) if !ok { message := fmt.Sprintf("has unexpected value for protocol: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -233,7 +233,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string base_url = 13; v13 := compiler.MapValueForKey(m, "baseUrl") if v13 != nil { - x.BaseUrl, ok = v13.(string) + x.BaseUrl, ok = compiler.StringForScalarNode(v13) if !ok { message := fmt.Sprintf("has unexpected value for baseUrl: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) @@ -242,7 +242,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string base_path = 14; v14 := compiler.MapValueForKey(m, "basePath") if v14 != nil { - x.BasePath, ok = v14.(string) + x.BasePath, ok = compiler.StringForScalarNode(v14) if !ok { message := fmt.Sprintf("has unexpected value for basePath: %+v (%T)", v14, v14) errors = append(errors, compiler.NewError(context, message)) @@ -251,7 +251,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string root_url = 15; v15 := compiler.MapValueForKey(m, "rootUrl") if v15 != nil { - x.RootUrl, ok = v15.(string) + x.RootUrl, ok = compiler.StringForScalarNode(v15) if !ok { message := fmt.Sprintf("has unexpected value for rootUrl: %+v (%T)", v15, v15) errors = append(errors, compiler.NewError(context, message)) @@ -260,7 +260,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string service_path = 16; v16 := compiler.MapValueForKey(m, "servicePath") if v16 != nil { - x.ServicePath, ok = v16.(string) + x.ServicePath, ok = compiler.StringForScalarNode(v16) if !ok { message := fmt.Sprintf("has unexpected value for servicePath: %+v (%T)", v16, v16) errors = append(errors, compiler.NewError(context, message)) @@ -269,7 +269,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string batch_path = 17; v17 := compiler.MapValueForKey(m, "batchPath") if v17 != nil { - x.BatchPath, ok = v17.(string) + x.BatchPath, ok = compiler.StringForScalarNode(v17) if !ok { message := fmt.Sprintf("has unexpected value for batchPath: %+v (%T)", v17, v17) errors = append(errors, compiler.NewError(context, message)) @@ -296,9 +296,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // repeated string features = 20; v20 := compiler.MapValueForKey(m, "features") if v20 != nil { - v, ok := v20.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v20) if ok { - x.Features = compiler.ConvertInterfaceArrayToStringArray(v) + x.Features = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for features: %+v (%T)", v20, v20) errors = append(errors, compiler.NewError(context, message)) @@ -334,7 +334,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string etag = 24; v24 := compiler.MapValueForKey(m, "etag") if v24 != nil { - x.Etag, ok = v24.(string) + x.Etag, ok = compiler.StringForScalarNode(v24) if !ok { message := fmt.Sprintf("has unexpected value for etag: %+v (%T)", v24, v24) errors = append(errors, compiler.NewError(context, message)) @@ -343,7 +343,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string owner_domain = 25; v25 := compiler.MapValueForKey(m, "ownerDomain") if v25 != nil { - x.OwnerDomain, ok = v25.(string) + x.OwnerDomain, ok = compiler.StringForScalarNode(v25) if !ok { message := fmt.Sprintf("has unexpected value for ownerDomain: %+v (%T)", v25, v25) errors = append(errors, compiler.NewError(context, message)) @@ -352,7 +352,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string owner_name = 26; v26 := compiler.MapValueForKey(m, "ownerName") if v26 != nil { - x.OwnerName, ok = v26.(string) + x.OwnerName, ok = compiler.StringForScalarNode(v26) if !ok { message := fmt.Sprintf("has unexpected value for ownerName: %+v (%T)", v26, v26) errors = append(errors, compiler.NewError(context, message)) @@ -361,7 +361,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // bool version_module = 27; v27 := compiler.MapValueForKey(m, "version_module") if v27 != nil { - x.VersionModule, ok = v27.(bool) + x.VersionModule, ok = compiler.BoolForScalarNode(v27) if !ok { message := fmt.Sprintf("has unexpected value for version_module: %+v (%T)", v27, v27) errors = append(errors, compiler.NewError(context, message)) @@ -370,7 +370,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string canonical_name = 28; v28 := compiler.MapValueForKey(m, "canonicalName") if v28 != nil { - x.CanonicalName, ok = v28.(string) + x.CanonicalName, ok = compiler.StringForScalarNode(v28) if !ok { message := fmt.Sprintf("has unexpected value for canonicalName: %+v (%T)", v28, v28) errors = append(errors, compiler.NewError(context, message)) @@ -379,7 +379,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // bool fully_encode_reserved_expansion = 29; v29 := compiler.MapValueForKey(m, "fullyEncodeReservedExpansion") if v29 != nil { - x.FullyEncodeReservedExpansion, ok = v29.(bool) + x.FullyEncodeReservedExpansion, ok = compiler.BoolForScalarNode(v29) if !ok { message := fmt.Sprintf("has unexpected value for fullyEncodeReservedExpansion: %+v (%T)", v29, v29) errors = append(errors, compiler.NewError(context, message)) @@ -388,7 +388,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string package_path = 30; v30 := compiler.MapValueForKey(m, "packagePath") if v30 != nil { - x.PackagePath, ok = v30.(string) + x.PackagePath, ok = compiler.StringForScalarNode(v30) if !ok { message := fmt.Sprintf("has unexpected value for packagePath: %+v (%T)", v30, v30) errors = append(errors, compiler.NewError(context, message)) @@ -397,7 +397,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string mtls_root_url = 31; v31 := compiler.MapValueForKey(m, "mtlsRootUrl") if v31 != nil { - x.MtlsRootUrl, ok = v31.(string) + x.MtlsRootUrl, ok = compiler.StringForScalarNode(v31) if !ok { message := fmt.Sprintf("has unexpected value for mtlsRootUrl: %+v (%T)", v31, v31) errors = append(errors, compiler.NewError(context, message)) @@ -432,7 +432,7 @@ func NewIcons(in interface{}, context *compiler.Context) (*Icons, error) { // string x16 = 1; v1 := compiler.MapValueForKey(m, "x16") if v1 != nil { - x.X16, ok = v1.(string) + x.X16, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for x16: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -441,7 +441,7 @@ func NewIcons(in interface{}, context *compiler.Context) (*Icons, error) { // string x32 = 2; v2 := compiler.MapValueForKey(m, "x32") if v2 != nil { - x.X32, ok = v2.(string) + x.X32, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for x32: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -470,9 +470,9 @@ func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, er // repeated string accept = 1; v1 := compiler.MapValueForKey(m, "accept") if v1 != nil { - v, ok := v1.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v1) if ok { - x.Accept = compiler.ConvertInterfaceArrayToStringArray(v) + x.Accept = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for accept: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -481,7 +481,7 @@ func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, er // string max_size = 2; v2 := compiler.MapValueForKey(m, "maxSize") if v2 != nil { - x.MaxSize, ok = v2.(string) + x.MaxSize, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for maxSize: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -499,7 +499,7 @@ func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, er // bool supports_subscription = 4; v4 := compiler.MapValueForKey(m, "supportsSubscription") if v4 != nil { - x.SupportsSubscription, ok = v4.(bool) + x.SupportsSubscription, ok = compiler.BoolForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for supportsSubscription: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -528,7 +528,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // string id = 1; v1 := compiler.MapValueForKey(m, "id") if v1 != nil { - x.Id, ok = v1.(string) + x.Id, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for id: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -537,7 +537,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // string path = 2; v2 := compiler.MapValueForKey(m, "path") if v2 != nil { - x.Path, ok = v2.(string) + x.Path, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for path: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -546,7 +546,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // string http_method = 3; v3 := compiler.MapValueForKey(m, "httpMethod") if v3 != nil { - x.HttpMethod, ok = v3.(string) + x.HttpMethod, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for httpMethod: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -555,7 +555,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // string description = 4; v4 := compiler.MapValueForKey(m, "description") if v4 != nil { - x.Description, ok = v4.(string) + x.Description, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -573,9 +573,9 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // repeated string parameter_order = 6; v6 := compiler.MapValueForKey(m, "parameterOrder") if v6 != nil { - v, ok := v6.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v6) if ok { - x.ParameterOrder = compiler.ConvertInterfaceArrayToStringArray(v) + x.ParameterOrder = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for parameterOrder: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -602,9 +602,9 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // repeated string scopes = 9; v9 := compiler.MapValueForKey(m, "scopes") if v9 != nil { - v, ok := v9.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v9) if ok { - x.Scopes = compiler.ConvertInterfaceArrayToStringArray(v) + x.Scopes = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for scopes: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -613,7 +613,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // bool supports_media_download = 10; v10 := compiler.MapValueForKey(m, "supportsMediaDownload") if v10 != nil { - x.SupportsMediaDownload, ok = v10.(bool) + x.SupportsMediaDownload, ok = compiler.BoolForScalarNode(v10) if !ok { message := fmt.Sprintf("has unexpected value for supportsMediaDownload: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) @@ -622,7 +622,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // bool supports_media_upload = 11; v11 := compiler.MapValueForKey(m, "supportsMediaUpload") if v11 != nil { - x.SupportsMediaUpload, ok = v11.(bool) + x.SupportsMediaUpload, ok = compiler.BoolForScalarNode(v11) if !ok { message := fmt.Sprintf("has unexpected value for supportsMediaUpload: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) @@ -631,7 +631,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // bool use_media_download_service = 12; v12 := compiler.MapValueForKey(m, "useMediaDownloadService") if v12 != nil { - x.UseMediaDownloadService, ok = v12.(bool) + x.UseMediaDownloadService, ok = compiler.BoolForScalarNode(v12) if !ok { message := fmt.Sprintf("has unexpected value for useMediaDownloadService: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -649,7 +649,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // bool supports_subscription = 14; v14 := compiler.MapValueForKey(m, "supportsSubscription") if v14 != nil { - x.SupportsSubscription, ok = v14.(bool) + x.SupportsSubscription, ok = compiler.BoolForScalarNode(v14) if !ok { message := fmt.Sprintf("has unexpected value for supportsSubscription: %+v (%T)", v14, v14) errors = append(errors, compiler.NewError(context, message)) @@ -658,7 +658,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // string flat_path = 15; v15 := compiler.MapValueForKey(m, "flatPath") if v15 != nil { - x.FlatPath, ok = v15.(string) + x.FlatPath, ok = compiler.StringForScalarNode(v15) if !ok { message := fmt.Sprintf("has unexpected value for flatPath: %+v (%T)", v15, v15) errors = append(errors, compiler.NewError(context, message)) @@ -667,7 +667,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { // bool etag_required = 16; v16 := compiler.MapValueForKey(m, "etagRequired") if v16 != nil { - x.EtagRequired, ok = v16.(bool) + x.EtagRequired, ok = compiler.BoolForScalarNode(v16) if !ok { message := fmt.Sprintf("has unexpected value for etagRequired: %+v (%T)", v16, v16) errors = append(errors, compiler.NewError(context, message)) @@ -689,10 +689,10 @@ func NewMethods(in interface{}, context *compiler.Context) (*Methods, error) { // repeated NamedMethod additional_properties = 1; // MAP: Method x.AdditionalProperties = make([]*NamedMethod, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedMethod{} pair.Name = k var err error @@ -726,7 +726,7 @@ func NewNamedMethod(in interface{}, context *compiler.Context) (*NamedMethod, er // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -764,7 +764,7 @@ func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParamet // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -802,7 +802,7 @@ func NewNamedResource(in interface{}, context *compiler.Context) (*NamedResource // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -840,7 +840,7 @@ func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, er // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -878,7 +878,7 @@ func NewNamedScope(in interface{}, context *compiler.Context) (*NamedScope, erro // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -945,7 +945,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string id = 1; v1 := compiler.MapValueForKey(m, "id") if v1 != nil { - x.Id, ok = v1.(string) + x.Id, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for id: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -954,7 +954,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string type = 2; v2 := compiler.MapValueForKey(m, "type") if v2 != nil { - x.Type, ok = v2.(string) + x.Type, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -963,7 +963,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string _ref = 3; v3 := compiler.MapValueForKey(m, "$ref") if v3 != nil { - x.XRef, ok = v3.(string) + x.XRef, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -972,7 +972,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string description = 4; v4 := compiler.MapValueForKey(m, "description") if v4 != nil { - x.Description, ok = v4.(string) + x.Description, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -981,7 +981,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string default = 5; v5 := compiler.MapValueForKey(m, "default") if v5 != nil { - x.Default, ok = v5.(string) + x.Default, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for default: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -990,7 +990,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // bool required = 6; v6 := compiler.MapValueForKey(m, "required") if v6 != nil { - x.Required, ok = v6.(bool) + x.Required, ok = compiler.BoolForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -999,7 +999,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string format = 7; v7 := compiler.MapValueForKey(m, "format") if v7 != nil { - x.Format, ok = v7.(string) + x.Format, ok = compiler.StringForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -1008,7 +1008,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string pattern = 8; v8 := compiler.MapValueForKey(m, "pattern") if v8 != nil { - x.Pattern, ok = v8.(string) + x.Pattern, ok = compiler.StringForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -1017,7 +1017,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string minimum = 9; v9 := compiler.MapValueForKey(m, "minimum") if v9 != nil { - x.Minimum, ok = v9.(string) + x.Minimum, ok = compiler.StringForScalarNode(v9) if !ok { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -1026,7 +1026,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string maximum = 10; v10 := compiler.MapValueForKey(m, "maximum") if v10 != nil { - x.Maximum, ok = v10.(string) + x.Maximum, ok = compiler.StringForScalarNode(v10) if !ok { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) @@ -1035,9 +1035,9 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // repeated string enum = 11; v11 := compiler.MapValueForKey(m, "enum") if v11 != nil { - v, ok := v11.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v11) if ok { - x.Enum = compiler.ConvertInterfaceArrayToStringArray(v) + x.Enum = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for enum: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) @@ -1046,9 +1046,9 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // repeated string enum_descriptions = 12; v12 := compiler.MapValueForKey(m, "enumDescriptions") if v12 != nil { - v, ok := v12.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v12) if ok { - x.EnumDescriptions = compiler.ConvertInterfaceArrayToStringArray(v) + x.EnumDescriptions = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for enumDescriptions: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -1057,7 +1057,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // bool repeated = 13; v13 := compiler.MapValueForKey(m, "repeated") if v13 != nil { - x.Repeated, ok = v13.(bool) + x.Repeated, ok = compiler.BoolForScalarNode(v13) if !ok { message := fmt.Sprintf("has unexpected value for repeated: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) @@ -1066,7 +1066,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string location = 14; v14 := compiler.MapValueForKey(m, "location") if v14 != nil { - x.Location, ok = v14.(string) + x.Location, ok = compiler.StringForScalarNode(v14) if !ok { message := fmt.Sprintf("has unexpected value for location: %+v (%T)", v14, v14) errors = append(errors, compiler.NewError(context, message)) @@ -1124,10 +1124,10 @@ func NewParameters(in interface{}, context *compiler.Context) (*Parameters, erro // repeated NamedParameter additional_properties = 1; // MAP: Parameter x.AdditionalProperties = make([]*NamedParameter, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedParameter{} pair.Name = k var err error @@ -1199,7 +1199,7 @@ func NewRequest(in interface{}, context *compiler.Context) (*Request, error) { // string _ref = 1; v1 := compiler.MapValueForKey(m, "$ref") if v1 != nil { - x.XRef, ok = v1.(string) + x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1208,7 +1208,7 @@ func NewRequest(in interface{}, context *compiler.Context) (*Request, error) { // string parameter_name = 2; v2 := compiler.MapValueForKey(m, "parameterName") if v2 != nil { - x.ParameterName, ok = v2.(string) + x.ParameterName, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for parameterName: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1268,10 +1268,10 @@ func NewResources(in interface{}, context *compiler.Context) (*Resources, error) // repeated NamedResource additional_properties = 1; // MAP: Resource x.AdditionalProperties = make([]*NamedResource, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedResource{} pair.Name = k var err error @@ -1305,7 +1305,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { // string _ref = 1; v1 := compiler.MapValueForKey(m, "$ref") if v1 != nil { - x.XRef, ok = v1.(string) + x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1334,7 +1334,7 @@ func NewResumable(in interface{}, context *compiler.Context) (*Resumable, error) // bool multipart = 1; v1 := compiler.MapValueForKey(m, "multipart") if v1 != nil { - x.Multipart, ok = v1.(bool) + x.Multipart, ok = compiler.BoolForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for multipart: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1343,7 +1343,7 @@ func NewResumable(in interface{}, context *compiler.Context) (*Resumable, error) // string path = 2; v2 := compiler.MapValueForKey(m, "path") if v2 != nil { - x.Path, ok = v2.(string) + x.Path, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for path: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1372,7 +1372,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string id = 1; v1 := compiler.MapValueForKey(m, "id") if v1 != nil { - x.Id, ok = v1.(string) + x.Id, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for id: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1381,7 +1381,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string type = 2; v2 := compiler.MapValueForKey(m, "type") if v2 != nil { - x.Type, ok = v2.(string) + x.Type, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1390,7 +1390,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -1399,7 +1399,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string default = 4; v4 := compiler.MapValueForKey(m, "default") if v4 != nil { - x.Default, ok = v4.(string) + x.Default, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for default: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -1408,7 +1408,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool required = 5; v5 := compiler.MapValueForKey(m, "required") if v5 != nil { - x.Required, ok = v5.(bool) + x.Required, ok = compiler.BoolForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -1417,7 +1417,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string format = 6; v6 := compiler.MapValueForKey(m, "format") if v6 != nil { - x.Format, ok = v6.(string) + x.Format, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -1426,7 +1426,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string pattern = 7; v7 := compiler.MapValueForKey(m, "pattern") if v7 != nil { - x.Pattern, ok = v7.(string) + x.Pattern, ok = compiler.StringForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -1435,7 +1435,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string minimum = 8; v8 := compiler.MapValueForKey(m, "minimum") if v8 != nil { - x.Minimum, ok = v8.(string) + x.Minimum, ok = compiler.StringForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -1444,7 +1444,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string maximum = 9; v9 := compiler.MapValueForKey(m, "maximum") if v9 != nil { - x.Maximum, ok = v9.(string) + x.Maximum, ok = compiler.StringForScalarNode(v9) if !ok { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -1453,9 +1453,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // repeated string enum = 10; v10 := compiler.MapValueForKey(m, "enum") if v10 != nil { - v, ok := v10.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v10) if ok { - x.Enum = compiler.ConvertInterfaceArrayToStringArray(v) + x.Enum = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for enum: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) @@ -1464,9 +1464,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // repeated string enum_descriptions = 11; v11 := compiler.MapValueForKey(m, "enumDescriptions") if v11 != nil { - v, ok := v11.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v11) if ok { - x.EnumDescriptions = compiler.ConvertInterfaceArrayToStringArray(v) + x.EnumDescriptions = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for enumDescriptions: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) @@ -1475,7 +1475,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool repeated = 12; v12 := compiler.MapValueForKey(m, "repeated") if v12 != nil { - x.Repeated, ok = v12.(bool) + x.Repeated, ok = compiler.BoolForScalarNode(v12) if !ok { message := fmt.Sprintf("has unexpected value for repeated: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -1484,7 +1484,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string location = 13; v13 := compiler.MapValueForKey(m, "location") if v13 != nil { - x.Location, ok = v13.(string) + x.Location, ok = compiler.StringForScalarNode(v13) if !ok { message := fmt.Sprintf("has unexpected value for location: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) @@ -1520,7 +1520,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string _ref = 17; v17 := compiler.MapValueForKey(m, "$ref") if v17 != nil { - x.XRef, ok = v17.(string) + x.XRef, ok = compiler.StringForScalarNode(v17) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v17, v17) errors = append(errors, compiler.NewError(context, message)) @@ -1538,7 +1538,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool read_only = 19; v19 := compiler.MapValueForKey(m, "readOnly") if v19 != nil { - x.ReadOnly, ok = v19.(bool) + x.ReadOnly, ok = compiler.BoolForScalarNode(v19) if !ok { message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v19, v19) errors = append(errors, compiler.NewError(context, message)) @@ -1560,10 +1560,10 @@ func NewSchemas(in interface{}, context *compiler.Context) (*Schemas, error) { // repeated NamedSchema additional_properties = 1; // MAP: Schema x.AdditionalProperties = make([]*NamedSchema, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedSchema{} pair.Name = k var err error @@ -1597,7 +1597,7 @@ func NewScope(in interface{}, context *compiler.Context) (*Scope, error) { // string description = 1; v1 := compiler.MapValueForKey(m, "description") if v1 != nil { - x.Description, ok = v1.(string) + x.Description, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1619,10 +1619,10 @@ func NewScopes(in interface{}, context *compiler.Context) (*Scopes, error) { // repeated NamedScope additional_properties = 1; // MAP: Scope x.AdditionalProperties = make([]*NamedScope, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedScope{} pair.Name = k var err error @@ -1656,7 +1656,7 @@ func NewSimple(in interface{}, context *compiler.Context) (*Simple, error) { // bool multipart = 1; v1 := compiler.MapValueForKey(m, "multipart") if v1 != nil { - x.Multipart, ok = v1.(bool) + x.Multipart, ok = compiler.BoolForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for multipart: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1665,7 +1665,7 @@ func NewSimple(in interface{}, context *compiler.Context) (*Simple, error) { // string path = 2; v2 := compiler.MapValueForKey(m, "path") if v2 != nil { - x.Path, ok = v2.(string) + x.Path, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for path: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2130,262 +2130,308 @@ func (m *StringArray) ResolveReferences(root string) (interface{}, error) { } // ToRawInfo returns a description of Annotations suitable for JSON or YAML export. -func (m *Annotations) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Annotations) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if len(m.Required) != 0 { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Required)) } return info } // ToRawInfo returns a description of Any suitable for JSON or YAML export. -func (m *Any) ToRawInfo() interface{} { +func (m *Any) ToRawInfo() *yaml.Node { var err error - var info1 []yaml.MapSlice - err = yaml.Unmarshal([]byte(m.Yaml), &info1) + var node yaml.Node + err = yaml.Unmarshal([]byte(m.Yaml), &node) 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 &node } return nil } // ToRawInfo returns a description of Auth suitable for JSON or YAML export. -func (m *Auth) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Auth) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Oauth2 != nil { - info = append(info, yaml.MapItem{Key: "oauth2", Value: m.Oauth2.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("oauth2")) + info.Content = append(info.Content, m.Oauth2.ToRawInfo()) } // &{Name:oauth2 Type:Oauth2 StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} return info } // ToRawInfo returns a description of Document suitable for JSON or YAML export. -func (m *Document) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Document) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "kind", Value: m.Kind}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("kind")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Kind)) // always include this required field. - info = append(info, yaml.MapItem{Key: "discoveryVersion", Value: m.DiscoveryVersion}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("discoveryVersion")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.DiscoveryVersion)) if m.Id != "" { - info = append(info, yaml.MapItem{Key: "id", Value: m.Id}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("id")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Id)) } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Version != "" { - info = append(info, yaml.MapItem{Key: "version", Value: m.Version}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("version")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Version)) } if m.Revision != "" { - info = append(info, yaml.MapItem{Key: "revision", Value: m.Revision}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("revision")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Revision)) } if m.Title != "" { - info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Icons != nil { - info = append(info, yaml.MapItem{Key: "icons", Value: m.Icons.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("icons")) + info.Content = append(info.Content, m.Icons.ToRawInfo()) } // &{Name:icons Type:Icons StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.DocumentationLink != "" { - info = append(info, yaml.MapItem{Key: "documentationLink", Value: m.DocumentationLink}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("documentationLink")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.DocumentationLink)) } if len(m.Labels) != 0 { - info = append(info, yaml.MapItem{Key: "labels", Value: m.Labels}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("labels")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Labels)) } if m.Protocol != "" { - info = append(info, yaml.MapItem{Key: "protocol", Value: m.Protocol}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("protocol")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Protocol)) } if m.BaseUrl != "" { - info = append(info, yaml.MapItem{Key: "baseUrl", Value: m.BaseUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("baseUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BaseUrl)) } if m.BasePath != "" { - info = append(info, yaml.MapItem{Key: "basePath", Value: m.BasePath}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("basePath")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BasePath)) } if m.RootUrl != "" { - info = append(info, yaml.MapItem{Key: "rootUrl", Value: m.RootUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("rootUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.RootUrl)) } if m.ServicePath != "" { - info = append(info, yaml.MapItem{Key: "servicePath", Value: m.ServicePath}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("servicePath")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.ServicePath)) } if m.BatchPath != "" { - info = append(info, yaml.MapItem{Key: "batchPath", Value: m.BatchPath}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("batchPath")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BatchPath)) } if m.Parameters != nil { - info = append(info, yaml.MapItem{Key: "parameters", Value: m.Parameters.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, m.Parameters.ToRawInfo()) } // &{Name:parameters Type:Parameters StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Auth != nil { - info = append(info, yaml.MapItem{Key: "auth", Value: m.Auth.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("auth")) + info.Content = append(info.Content, m.Auth.ToRawInfo()) } // &{Name:auth Type:Auth StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.Features) != 0 { - info = append(info, yaml.MapItem{Key: "features", Value: m.Features}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("features")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Features)) } if m.Schemas != nil { - info = append(info, yaml.MapItem{Key: "schemas", Value: m.Schemas.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schemas")) + info.Content = append(info.Content, m.Schemas.ToRawInfo()) } // &{Name:schemas Type:Schemas StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Methods != nil { - info = append(info, yaml.MapItem{Key: "methods", Value: m.Methods.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("methods")) + info.Content = append(info.Content, m.Methods.ToRawInfo()) } // &{Name:methods Type:Methods StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Resources != nil { - info = append(info, yaml.MapItem{Key: "resources", Value: m.Resources.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("resources")) + info.Content = append(info.Content, m.Resources.ToRawInfo()) } // &{Name:resources Type:Resources StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Etag != "" { - info = append(info, yaml.MapItem{Key: "etag", Value: m.Etag}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("etag")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Etag)) } if m.OwnerDomain != "" { - info = append(info, yaml.MapItem{Key: "ownerDomain", Value: m.OwnerDomain}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("ownerDomain")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OwnerDomain)) } if m.OwnerName != "" { - info = append(info, yaml.MapItem{Key: "ownerName", Value: m.OwnerName}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("ownerName")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OwnerName)) } if m.VersionModule != false { - info = append(info, yaml.MapItem{Key: "version_module", Value: m.VersionModule}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("version_module")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.VersionModule)) } if m.CanonicalName != "" { - info = append(info, yaml.MapItem{Key: "canonicalName", Value: m.CanonicalName}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("canonicalName")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.CanonicalName)) } if m.FullyEncodeReservedExpansion != false { - info = append(info, yaml.MapItem{Key: "fullyEncodeReservedExpansion", Value: m.FullyEncodeReservedExpansion}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("fullyEncodeReservedExpansion")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.FullyEncodeReservedExpansion)) } if m.PackagePath != "" { - info = append(info, yaml.MapItem{Key: "packagePath", Value: m.PackagePath}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("packagePath")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.PackagePath)) } if m.MtlsRootUrl != "" { - info = append(info, yaml.MapItem{Key: "mtlsRootUrl", Value: m.MtlsRootUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("mtlsRootUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.MtlsRootUrl)) } return info } // ToRawInfo returns a description of Icons suitable for JSON or YAML export. -func (m *Icons) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Icons) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "x16", Value: m.X16}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("x16")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.X16)) // always include this required field. - info = append(info, yaml.MapItem{Key: "x32", Value: m.X32}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("x32")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.X32)) return info } // ToRawInfo returns a description of MediaUpload suitable for JSON or YAML export. -func (m *MediaUpload) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *MediaUpload) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if len(m.Accept) != 0 { - info = append(info, yaml.MapItem{Key: "accept", Value: m.Accept}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("accept")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Accept)) } if m.MaxSize != "" { - info = append(info, yaml.MapItem{Key: "maxSize", Value: m.MaxSize}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxSize")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.MaxSize)) } if m.Protocols != nil { - info = append(info, yaml.MapItem{Key: "protocols", Value: m.Protocols.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("protocols")) + info.Content = append(info.Content, m.Protocols.ToRawInfo()) } // &{Name:protocols Type:Protocols StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SupportsSubscription != false { - info = append(info, yaml.MapItem{Key: "supportsSubscription", Value: m.SupportsSubscription}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("supportsSubscription")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.SupportsSubscription)) } return info } // ToRawInfo returns a description of Method suitable for JSON or YAML export. -func (m *Method) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Method) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Id != "" { - info = append(info, yaml.MapItem{Key: "id", Value: m.Id}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("id")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Id)) } if m.Path != "" { - info = append(info, yaml.MapItem{Key: "path", Value: m.Path}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("path")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Path)) } if m.HttpMethod != "" { - info = append(info, yaml.MapItem{Key: "httpMethod", Value: m.HttpMethod}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("httpMethod")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.HttpMethod)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Parameters != nil { - info = append(info, yaml.MapItem{Key: "parameters", Value: m.Parameters.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, m.Parameters.ToRawInfo()) } // &{Name:parameters Type:Parameters StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.ParameterOrder) != 0 { - info = append(info, yaml.MapItem{Key: "parameterOrder", Value: m.ParameterOrder}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameterOrder")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.ParameterOrder)) } if m.Request != nil { - info = append(info, yaml.MapItem{Key: "request", Value: m.Request.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("request")) + info.Content = append(info.Content, m.Request.ToRawInfo()) } // &{Name:request Type:Request StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Response != nil { - info = append(info, yaml.MapItem{Key: "response", Value: m.Response.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("response")) + info.Content = append(info.Content, m.Response.ToRawInfo()) } // &{Name:response Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.Scopes) != 0 { - info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Scopes)) } if m.SupportsMediaDownload != false { - info = append(info, yaml.MapItem{Key: "supportsMediaDownload", Value: m.SupportsMediaDownload}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("supportsMediaDownload")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.SupportsMediaDownload)) } if m.SupportsMediaUpload != false { - info = append(info, yaml.MapItem{Key: "supportsMediaUpload", Value: m.SupportsMediaUpload}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("supportsMediaUpload")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.SupportsMediaUpload)) } if m.UseMediaDownloadService != false { - info = append(info, yaml.MapItem{Key: "useMediaDownloadService", Value: m.UseMediaDownloadService}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("useMediaDownloadService")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UseMediaDownloadService)) } if m.MediaUpload != nil { - info = append(info, yaml.MapItem{Key: "mediaUpload", Value: m.MediaUpload.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("mediaUpload")) + info.Content = append(info.Content, m.MediaUpload.ToRawInfo()) } // &{Name:mediaUpload Type:MediaUpload StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SupportsSubscription != false { - info = append(info, yaml.MapItem{Key: "supportsSubscription", Value: m.SupportsSubscription}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("supportsSubscription")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.SupportsSubscription)) } if m.FlatPath != "" { - info = append(info, yaml.MapItem{Key: "flatPath", Value: m.FlatPath}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("flatPath")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.FlatPath)) } if m.EtagRequired != false { - info = append(info, yaml.MapItem{Key: "etagRequired", Value: m.EtagRequired}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("etagRequired")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.EtagRequired)) } return info } // ToRawInfo returns a description of Methods suitable for JSON or YAML export. -func (m *Methods) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Methods) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedMethod StringEnumValues:[] MapType:Method Repeated:true Pattern: Implicit:true Description:} @@ -2393,159 +2439,184 @@ func (m *Methods) ToRawInfo() interface{} { } // ToRawInfo returns a description of NamedMethod suitable for JSON or YAML export. -func (m *NamedMethod) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedMethod) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:Method 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{} +func (m *NamedParameter) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedResource suitable for JSON or YAML export. -func (m *NamedResource) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedResource) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:Resource 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{} +func (m *NamedSchema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedScope suitable for JSON or YAML export. -func (m *NamedScope) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedScope) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:Scope StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of Oauth2 suitable for JSON or YAML export. -func (m *Oauth2) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Oauth2) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Scopes != nil { - info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) + info.Content = append(info.Content, m.Scopes.ToRawInfo()) } // &{Name:scopes Type:Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} return info } // ToRawInfo returns a description of Parameter suitable for JSON or YAML export. -func (m *Parameter) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Parameter) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Id != "" { - info = append(info, yaml.MapItem{Key: "id", Value: m.Id}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("id")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Id)) } if m.Type != "" { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) } if m.XRef != "" { - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Default != "" { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Default)) } if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.Minimum != "" { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Minimum)) } if m.Maximum != "" { - info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Maximum)) } if len(m.Enum) != 0 { - info = append(info, yaml.MapItem{Key: "enum", Value: m.Enum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Enum)) } if len(m.EnumDescriptions) != 0 { - info = append(info, yaml.MapItem{Key: "enumDescriptions", Value: m.EnumDescriptions}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enumDescriptions")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.EnumDescriptions)) } if m.Repeated != false { - info = append(info, yaml.MapItem{Key: "repeated", Value: m.Repeated}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("repeated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Repeated)) } if m.Location != "" { - info = append(info, yaml.MapItem{Key: "location", Value: m.Location}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("location")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Location)) } if m.Properties != nil { - info = append(info, yaml.MapItem{Key: "properties", Value: m.Properties.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("properties")) + info.Content = append(info.Content, m.Properties.ToRawInfo()) } // &{Name:properties Type:Schemas StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.AdditionalProperties != nil { - info = append(info, yaml.MapItem{Key: "additionalProperties", Value: m.AdditionalProperties.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("additionalProperties")) + info.Content = append(info.Content, m.AdditionalProperties.ToRawInfo()) } // &{Name:additionalProperties Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Items != nil { - info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, m.Items.ToRawInfo()) } // &{Name:items Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Annotations != nil { - info = append(info, yaml.MapItem{Key: "annotations", Value: m.Annotations.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("annotations")) + info.Content = append(info.Content, m.Annotations.ToRawInfo()) } // &{Name:annotations Type:Annotations StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} return info } // ToRawInfo returns a description of Parameters suitable for JSON or YAML export. -func (m *Parameters) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Parameters) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedParameter StringEnumValues:[] MapType:Parameter Repeated:true Pattern: Implicit:true Description:} @@ -2553,63 +2624,70 @@ func (m *Parameters) ToRawInfo() interface{} { } // ToRawInfo returns a description of Protocols suitable for JSON or YAML export. -func (m *Protocols) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Protocols) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Simple != nil { - info = append(info, yaml.MapItem{Key: "simple", Value: m.Simple.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("simple")) + info.Content = append(info.Content, m.Simple.ToRawInfo()) } // &{Name:simple Type:Simple StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Resumable != nil { - info = append(info, yaml.MapItem{Key: "resumable", Value: m.Resumable.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("resumable")) + info.Content = append(info.Content, m.Resumable.ToRawInfo()) } // &{Name:resumable Type:Resumable StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} return info } // ToRawInfo returns a description of Request suitable for JSON or YAML export. -func (m *Request) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Request) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.XRef != "" { - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) } if m.ParameterName != "" { - info = append(info, yaml.MapItem{Key: "parameterName", Value: m.ParameterName}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameterName")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.ParameterName)) } return info } // ToRawInfo returns a description of Resource suitable for JSON or YAML export. -func (m *Resource) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Resource) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Methods != nil { - info = append(info, yaml.MapItem{Key: "methods", Value: m.Methods.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("methods")) + info.Content = append(info.Content, m.Methods.ToRawInfo()) } // &{Name:methods Type:Methods StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Resources != nil { - info = append(info, yaml.MapItem{Key: "resources", Value: m.Resources.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("resources")) + info.Content = append(info.Content, m.Resources.ToRawInfo()) } // &{Name:resources Type:Resources StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} return info } // ToRawInfo returns a description of Resources suitable for JSON or YAML export. -func (m *Resources) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Resources) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedResource StringEnumValues:[] MapType:Resource Repeated:true Pattern: Implicit:true Description:} @@ -2617,111 +2695,134 @@ func (m *Resources) ToRawInfo() interface{} { } // ToRawInfo returns a description of Response suitable for JSON or YAML export. -func (m *Response) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Response) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.XRef != "" { - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) } return info } // ToRawInfo returns a description of Resumable suitable for JSON or YAML export. -func (m *Resumable) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Resumable) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Multipart != false { - info = append(info, yaml.MapItem{Key: "multipart", Value: m.Multipart}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipart")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Multipart)) } if m.Path != "" { - info = append(info, yaml.MapItem{Key: "path", Value: m.Path}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("path")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Path)) } return info } // ToRawInfo returns a description of Schema suitable for JSON or YAML export. -func (m *Schema) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Schema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Id != "" { - info = append(info, yaml.MapItem{Key: "id", Value: m.Id}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("id")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Id)) } if m.Type != "" { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Default != "" { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Default)) } if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.Minimum != "" { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Minimum)) } if m.Maximum != "" { - info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Maximum)) } if len(m.Enum) != 0 { - info = append(info, yaml.MapItem{Key: "enum", Value: m.Enum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Enum)) } if len(m.EnumDescriptions) != 0 { - info = append(info, yaml.MapItem{Key: "enumDescriptions", Value: m.EnumDescriptions}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enumDescriptions")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.EnumDescriptions)) } if m.Repeated != false { - info = append(info, yaml.MapItem{Key: "repeated", Value: m.Repeated}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("repeated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Repeated)) } if m.Location != "" { - info = append(info, yaml.MapItem{Key: "location", Value: m.Location}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("location")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Location)) } if m.Properties != nil { - info = append(info, yaml.MapItem{Key: "properties", Value: m.Properties.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("properties")) + info.Content = append(info.Content, m.Properties.ToRawInfo()) } // &{Name:properties Type:Schemas StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.AdditionalProperties != nil { - info = append(info, yaml.MapItem{Key: "additionalProperties", Value: m.AdditionalProperties.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("additionalProperties")) + info.Content = append(info.Content, m.AdditionalProperties.ToRawInfo()) } // &{Name:additionalProperties Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Items != nil { - info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, m.Items.ToRawInfo()) } // &{Name:items Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.XRef != "" { - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) } if m.Annotations != nil { - info = append(info, yaml.MapItem{Key: "annotations", Value: m.Annotations.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("annotations")) + info.Content = append(info.Content, m.Annotations.ToRawInfo()) } // &{Name:annotations Type:Annotations StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.ReadOnly != false { - info = append(info, yaml.MapItem{Key: "readOnly", Value: m.ReadOnly}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("readOnly")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ReadOnly)) } return info } // ToRawInfo returns a description of Schemas suitable for JSON or YAML export. -func (m *Schemas) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Schemas) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:} @@ -2729,26 +2830,28 @@ func (m *Schemas) ToRawInfo() interface{} { } // ToRawInfo returns a description of Scope suitable for JSON or YAML export. -func (m *Scope) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Scope) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } return info } // ToRawInfo returns a description of Scopes suitable for JSON or YAML export. -func (m *Scopes) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Scopes) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedScope StringEnumValues:[] MapType:Scope Repeated:true Pattern: Implicit:true Description:} @@ -2756,23 +2859,23 @@ func (m *Scopes) ToRawInfo() interface{} { } // ToRawInfo returns a description of Simple suitable for JSON or YAML export. -func (m *Simple) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Simple) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Multipart != false { - info = append(info, yaml.MapItem{Key: "multipart", Value: m.Multipart}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipart")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Multipart)) } if m.Path != "" { - info = append(info, yaml.MapItem{Key: "path", Value: m.Path}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("path")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Path)) } return info } // ToRawInfo returns a description of StringArray suitable for JSON or YAML export. -func (m *StringArray) ToRawInfo() interface{} { - return m.Value +func (m *StringArray) ToRawInfo() *yaml.Node { + return compiler.NewSequenceNodeForStringArray(m.Value) } - -var () diff --git a/discovery/discovery.pb.go b/discovery/discovery.pb.go index c44d30c2..f76d235a 100644 --- a/discovery/discovery.pb.go +++ b/discovery/discovery.pb.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/discovery/discovery.proto b/discovery/discovery.proto index 5839b7f3..a095d873 100644 --- a/discovery/discovery.proto +++ b/discovery/discovery.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/generate-gnostic/generate-compiler.go b/generate-gnostic/generate-compiler.go index ec14e316..d3a85ab3 100644 --- a/generate-gnostic/generate-compiler.go +++ b/generate-gnostic/generate-compiler.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -142,14 +142,16 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st if typeModel.IsStringArray { code.Print("x := &TypeItem{}") - code.Print("switch in := in.(type) {") - code.Print("case string:") + code.Print("v1, _ := in.(*yaml.Node)") + code.Print("switch v1.Kind {") + code.Print("case yaml.ScalarNode:") code.Print(" x.Value = make([]string, 0)") - code.Print(" x.Value = append(x.Value, in)") - code.Print("case []interface{}:") + code.Print(" x.Value = append(x.Value, v1.Value)") + code.Print("case yaml.SequenceNode:") code.Print(" x.Value = make([]string, 0)") - code.Print(" for _, v := range in {") - code.Print(" value, ok := v.(string)") + code.Print(" for _, v := range v1.Content {") + code.Print(" value := v.Value") + code.Print(" ok := v.Kind == yaml.ScalarNode") code.Print(" if ok {") code.Print(" x.Value = append(x.Value, value)") code.Print(" } else {") @@ -411,9 +413,9 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print("if (v%d != nil) {", fieldNumber) code.Print(" // repeated %s", typeModel.Name) code.Print(" x.%s = make([]*%s, 0)", fieldName, typeModel.Name) - code.Print(" a, ok := v%d.([]interface{})", fieldNumber) + code.Print(" a, ok := compiler.SequenceNodeForNode(v%d)", fieldNumber) code.Print(" if ok {") - code.Print(" for _, item := range a {") + code.Print(" for _, item := range a.Content {") code.Print(" y, err := New%s(item, compiler.NewContext(\"%s\", context))", typeModel.Name, propertyName) code.Print(" if err != nil {") code.Print(" errors = append(errors, err)") @@ -457,9 +459,9 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st if propertyModel.Repeated { code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" v, ok := v%d.([]interface{})", fieldNumber) + code.Print(" v, ok := compiler.SequenceNodeForNode(v%d)", fieldNumber) code.Print(" if ok {") - code.Print(" x.%s = compiler.ConvertInterfaceArrayToStringArray(v)", fieldName) + code.Print(" x.%s = compiler.StringArrayForSequenceNode(v)", fieldName) code.Print(" } else {") code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") @@ -487,7 +489,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } else { code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" x.%s, ok = v%d.(string)", fieldName, fieldNumber) + code.Print(" x.%s, ok = compiler.StringForScalarNode(v%d)", fieldName, fieldNumber) code.Print(" if !ok {") code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") @@ -516,22 +518,10 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } else if propertyType == "float" { code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" switch v%d := v%d.(type) {", fieldNumber, fieldNumber) - code.Print(" case float64:") - code.Print(" x.%s = v%d", fieldName, fieldNumber) - code.Print(" case float32:") - code.Print(" x.%s = float64(v%d)", fieldName, fieldNumber) - code.Print(" case uint64:") - code.Print(" x.%s = float64(v%d)", fieldName, fieldNumber) - code.Print(" case uint32:") - code.Print(" x.%s = float64(v%d)", fieldName, fieldNumber) - code.Print(" case int64:") - code.Print(" x.%s = float64(v%d)", fieldName, fieldNumber) - code.Print(" case int32:") - code.Print(" x.%s = float64(v%d)", fieldName, fieldNumber) - code.Print(" case int:") - code.Print(" x.%s = float64(v%d)", fieldName, fieldNumber) - code.Print(" default:") + code.Print(" v, ok := compiler.FloatForScalarNode(v%d)", fieldNumber) + code.Print(" if ok {") + code.Print(" x.%s = v", fieldName) + code.Print(" } else {") code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print(" }") @@ -539,7 +529,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } else if propertyType == "int64" { code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" t, ok := v%d.(int)", fieldNumber) + code.Print(" t, ok := compiler.IntForScalarNode(v%d)", fieldNumber) code.Print(" if ok {") code.Print(" x.%s = int64(t)", fieldName) code.Print(" } else {") @@ -558,7 +548,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } else { code.Print("v%d := compiler.MapValueForKey(m, \"%s\")", fieldNumber, propertyName) code.Print("if (v%d != nil) {", fieldNumber) - code.Print(" x.%s, ok = v%d.(bool)", fieldName, fieldNumber) + code.Print(" x.%s, ok = compiler.BoolForScalarNode(v%d)", fieldName, fieldNumber) code.Print(" if !ok {") code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") @@ -574,10 +564,10 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } else { code.Print("x.%s = make([]*Named%s, 0)", fieldName, mapTypeName) } - code.Print("for _, item := range m {") - code.Print("k, ok := compiler.StringValue(item.Key)") + code.Print("for i := 0; i < len(m.Content); i += 2 {") + code.Print("k, ok := compiler.StringForScalarNode(m.Content[i])") code.Print("if ok {") - code.Print("v := item.Value") + code.Print("v := m.Content[i+1]") if pattern := propertyModel.Pattern; pattern != "" { if inline, ok := regexPatterns.SpecialCaseExpression(pattern, "k"); ok { code.Print("if %s {", inline) @@ -590,7 +580,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print("pair.Name = k") if mapTypeName == "string" { - code.Print("pair.Value = v.(string)") + code.Print("pair.Value, _ = compiler.StringForScalarNode(v)") } else if mapTypeName == "Any" { code.Print("result := &Any{}") code.Print("handled, resultFromExt, err := compiler.HandleExtension(context, v, k)") @@ -763,22 +753,16 @@ func (domain *Domain) generateResolveReferencesMethodsForType(code *printer.Code // ToRawInfo() methods func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeName string) { code.Print("// ToRawInfo returns a description of %s suitable for JSON or YAML export.", typeName) - code.Print("func (m *%s) ToRawInfo() interface{} {", typeName) + code.Print("func (m *%s) ToRawInfo() *yaml.Node {", typeName) typeModel := domain.TypeModels[typeName] if typeName == "Any" { code.Print("var err error") - code.Print("var info1 []yaml.MapSlice") - code.Print("err = yaml.Unmarshal([]byte(m.Yaml), &info1)") - code.Print("if err == nil {return info1}") - code.Print("var info2 yaml.MapSlice") - code.Print("err = yaml.Unmarshal([]byte(m.Yaml), &info2)") - code.Print("if err == nil {return info2}") - code.Print("var info3 interface{}") - code.Print("err = yaml.Unmarshal([]byte(m.Yaml), &info3)") - code.Print("if err == nil {return info3}") + code.Print("var node yaml.Node") + code.Print("err = yaml.Unmarshal([]byte(m.Yaml), &node)") + code.Print("if err == nil {return &node}") code.Print("return nil") } else if typeName == "StringArray" { - code.Print("return m.Value") + code.Print("return compiler.NewSequenceNodeForStringArray(m.Value)") } else if typeModel.OneOfWrapper { code.Print("// ONE OF WRAPPER") code.Print("// %s", typeModel.Name) @@ -786,15 +770,15 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam code.Print("// %+v", *item) if item.Type == "float" { code.Print("if v%d, ok := m.GetOneof().(*%s_Number); ok {", i, typeName) - code.Print("return v%d.Number", i) + code.Print("return compiler.NewScalarNodeForFloat(v%d.Number)", i) code.Print("}") } else if item.Type == "bool" { code.Print("if v%d, ok := m.GetOneof().(*%s_Boolean); ok {", i, typeName) - code.Print("return v%d.Boolean", i) + code.Print("return compiler.NewScalarNodeForBool(v%d.Boolean)", i) code.Print("}") } else if item.Type == "string" { code.Print("if v%d, ok := m.GetOneof().(*%s_String_); ok {", i, typeName) - code.Print("return v%d.String_", i) + code.Print("return compiler.NewScalarNodeForString(v%d.String_)", i) code.Print("}") } else { code.Print("v%d := m.Get%s()", i, item.Type) @@ -805,7 +789,7 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam } code.Print("return nil") } else { - code.Print("info := yaml.MapSlice{}") + code.Print("info := compiler.NewMappingNode()") code.Print("if m == nil {return info}") for _, propertyModel := range typeModel.Properties { isRequired := typeModel.IsRequired(propertyModel.Name) @@ -815,11 +799,13 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam if !propertyModel.Repeated { code.PrintIf(isRequired, "// always include this required field.") code.PrintIf(!isRequired, "if m.%s != \"\" {", propertyModel.FieldName()) - code.Print("info = append(info, yaml.MapItem{Key:\"%s\", Value:m.%s})", propertyName, propertyModel.FieldName()) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(m.%s))", propertyModel.FieldName()) code.PrintIf(!isRequired, "}") } else { code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) - code.Print("info = append(info, yaml.MapItem{Key:\"%s\", Value:m.%s})", propertyName, propertyModel.FieldName()) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) + code.Print("info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.%s))", propertyModel.FieldName()) code.Print("}") } case "bool": @@ -827,7 +813,8 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam if !propertyModel.Repeated { code.PrintIf(isRequired, "// always include this required field.") code.PrintIf(!isRequired, "if m.%s != false {", propertyModel.FieldName()) - code.Print("info = append(info, yaml.MapItem{Key:\"%s\", Value:m.%s})", propertyName, propertyModel.FieldName()) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.%s))", propertyModel.FieldName()) code.PrintIf(!isRequired, "}") } else { code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) @@ -839,7 +826,8 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam if !propertyModel.Repeated { code.PrintIf(isRequired, "// always include this required field.") code.PrintIf(!isRequired, "if m.%s != 0 {", propertyModel.FieldName()) - code.Print("info = append(info, yaml.MapItem{Key:\"%s\", Value:m.%s})", propertyName, propertyModel.FieldName()) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.%s))", propertyModel.FieldName()) code.PrintIf(!isRequired, "}") } else { code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) @@ -851,7 +839,8 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam if !propertyModel.Repeated { code.PrintIf(isRequired, "// always include this required field.") code.PrintIf(!isRequired, "if m.%s != 0.0 {", propertyModel.FieldName()) - code.Print("info = append(info, yaml.MapItem{Key:\"%s\", Value:m.%s})", propertyName, propertyModel.FieldName()) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.%s))", propertyModel.FieldName()) code.PrintIf(!isRequired, "}") } else { code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) @@ -867,23 +856,26 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam code.PrintIf(!isRequired, "if m.%s != nil {", propertyModel.FieldName()) if propertyModel.Type == "TypeItem" { code.Print("if len(m.Type.Value) == 1 {") - code.Print("info = append(info, yaml.MapItem{Key:\"type\", Value:m.Type.Value[0]})") + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"type\"))") + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type.Value[0]))") code.Print("} else {") - code.Print("info = append(info, yaml.MapItem{Key:\"type\", Value:m.Type.Value})") + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"type\"))") + code.Print("info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Type.Value))") code.Print("}") } else if propertyModel.Type == "ItemsItem" { - code.Print("items := make([]interface{}, 0)") + code.Print("items := compiler.NewSequenceNode()") if domain.Version == "v2" { code.Print("for _, item := range m.Items.Schema {") } else { code.Print("for _, item := range m.Items.SchemaOrReference {") } - code.Print(" items = append(items, item.ToRawInfo())") + code.Print(" items.Content = append(items.Content, item.ToRawInfo())") code.Print("}") - code.Print("info = append(info, yaml.MapItem{Key:\"items\", Value:items[0]})") + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"items\"))") + code.Print("info.Content = append(info.Content, items)") } else { - code.Print("info = append(info, yaml.MapItem{Key:\"%s\", Value:m.%s.ToRawInfo()})", - propertyName, propertyModel.FieldName()) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) + code.Print("info.Content = append(info.Content, m.%s.ToRawInfo())", propertyModel.FieldName()) } code.PrintIf(!isRequired, "}") code.Print("// %+v", propertyModel) @@ -892,17 +884,19 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam } else if propertyModel.MapType != "" { code.Print("if m.%s != nil {", propertyModel.FieldName()) code.Print("for _, item := range m.%s {", propertyModel.FieldName()) - code.Print("info = append(info, yaml.MapItem{Key:item.Name, Value:item.Value.ToRawInfo()})") + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name))") + code.Print("info.Content = append(info.Content, item.Value.ToRawInfo())") code.Print("}") code.Print("}") code.Print("// %+v", propertyModel) } else { code.Print("if len(m.%s) != 0 {", propertyModel.FieldName()) - code.Print("items := make([]interface{}, 0)") + code.Print("items := compiler.NewSequenceNode()") code.Print("for _, item := range m.%s {", propertyModel.FieldName()) - code.Print("items = append(items, item.ToRawInfo())") + code.Print("items.Content = append(items.Content, item.ToRawInfo())") code.Print("}") - code.Print("info = append(info, yaml.MapItem{Key:\"%s\", Value:items})", propertyName) + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"%s\"))", propertyName) + code.Print("info.Content = append(info.Content, items)") code.Print("}") code.Print("// %+v", propertyModel) } @@ -915,6 +909,9 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam func (domain *Domain) generateConstantVariables(code *printer.Code, regexPatterns *patternNames) { names := regexPatterns.Names() + if len(names) == 0 { + return + } var sortedNames []string for name, _ := range names { sortedNames = append(sortedNames, name) diff --git a/generate-gnostic/generate-extension.go b/generate-gnostic/generate-extension.go index d3c6adff..3ede5b55 100644 --- a/generate-gnostic/generate-extension.go +++ b/generate-gnostic/generate-extension.go @@ -268,7 +268,7 @@ func GenerateExtension(schemaFile string, outDir string) error { "regexp", "strings", "github.com/googleapis/gnostic/compiler", - "gopkg.in/yaml.v2", + "gopkg.in/yaml.v3", }) goFilename := path.Join(protoOutDirectory, outFileBaseName+".go") err = ioutil.WriteFile(goFilename, []byte(compiler), 0644) diff --git a/generate-gnostic/main.go b/generate-gnostic/main.go index c8799235..7a13be40 100644 --- a/generate-gnostic/main.go +++ b/generate-gnostic/main.go @@ -33,7 +33,7 @@ import ( // License is the software license applied to generated code. const License = "" + - "// Copyright 2017 Google Inc. All Rights Reserved.\n" + + "// Copyright 2020 Google LLC. All Rights Reserved.\n" + "//\n" + "// Licensed under the Apache License, Version 2.0 (the \"License\");\n" + "// you may not use this file except in compliance with the License.\n" + @@ -190,7 +190,7 @@ func generateOpenAPIModel(version string) error { packageImports := []string{ "fmt", - "gopkg.in/yaml.v2", + "gopkg.in/yaml.v3", "strings", "regexp", "github.com/googleapis/gnostic/compiler", diff --git a/lib/gnostic.go b/lib/gnostic.go index 66fbfd61..3dca0169 100644 --- a/lib/gnostic.go +++ b/lib/gnostic.go @@ -36,7 +36,7 @@ import ( openapi_v3 "github.com/googleapis/gnostic/openapiv3" plugins "github.com/googleapis/gnostic/plugins" surface "github.com/googleapis/gnostic/surface" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) // UsageError is a response to invalid command-line inputs @@ -71,18 +71,26 @@ func getOpenAPIVersionFromInfo(info interface{}) int { if !ok { return SourceFormatUnknown } - swagger, ok := compiler.MapValueForKey(m, "swagger").(string) + + if m.Kind == yaml.DocumentNode { + return getOpenAPIVersionFromInfo(m.Content[0]) + } + + swagger, ok := compiler.StringForScalarNode(compiler.MapValueForKey(m, "swagger")) if ok && strings.HasPrefix(swagger, "2.0") { return SourceFormatOpenAPI2 } - openapi, ok := compiler.MapValueForKey(m, "openapi").(string) + + openapi, ok := compiler.StringForScalarNode(compiler.MapValueForKey(m, "openapi")) if ok && strings.HasPrefix(openapi, "3.0") { return SourceFormatOpenAPI3 } - kind, ok := compiler.MapValueForKey(m, "kind").(string) + + kind, ok := compiler.StringForScalarNode(compiler.MapValueForKey(m, "kind")) if ok && kind == "discovery#restDescription" { return SourceFormatDiscovery } + return SourceFormatUnknown } @@ -434,13 +442,13 @@ func (g *Gnostic) readOpenAPIText(bytes []byte) (message proto.Message, err erro } // Compile to the proto model. if g.sourceFormat == SourceFormatOpenAPI2 { - document, err := openapi_v2.NewDocument(info, compiler.NewContextWithExtensions("$root", nil, &g.extensionHandlers)) + document, err := openapi_v2.NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, &g.extensionHandlers)) if err != nil { return nil, err } message = document } else if g.sourceFormat == SourceFormatOpenAPI3 { - document, err := openapi_v3.NewDocument(info, compiler.NewContextWithExtensions("$root", nil, &g.extensionHandlers)) + document, err := openapi_v3.NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, &g.extensionHandlers)) if err != nil { return nil, err } @@ -501,27 +509,17 @@ func (g *Gnostic) writeTextOutput(message proto.Message) { // Write JSON/YAML OpenAPI representations. func (g *Gnostic) writeJSONYAMLOutput(message proto.Message) { // Convert the OpenAPI document into an exportable MapSlice. - var rawInfo yaml.MapSlice - var ok bool + var rawInfo *yaml.Node var err error if g.sourceFormat == SourceFormatOpenAPI2 { document := message.(*openapi_v2.Document) - rawInfo, ok = document.ToRawInfo().(yaml.MapSlice) - if !ok { - rawInfo = nil - } + rawInfo = document.ToRawInfo() } else if g.sourceFormat == SourceFormatOpenAPI3 { document := message.(*openapi_v3.Document) - rawInfo, ok = document.ToRawInfo().(yaml.MapSlice) - if !ok { - rawInfo = nil - } + rawInfo = document.ToRawInfo() } else if g.sourceFormat == SourceFormatDiscovery { document := message.(*discovery_v1.Document) - rawInfo, ok = document.ToRawInfo().(yaml.MapSlice) - if !ok { - rawInfo = nil - } + rawInfo = document.ToRawInfo() } // Optionally write description in yaml format. if g.yamlOutputPath != "" { diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index 69fb8440..0e93c8c7 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,10 +18,11 @@ package openapi_v2 import ( "fmt" - "github.com/googleapis/gnostic/compiler" - "gopkg.in/yaml.v2" "regexp" "strings" + + "github.com/googleapis/gnostic/compiler" + "gopkg.in/yaml.v3" ) // Version returns the package name (and OpenAPI version). @@ -95,7 +96,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -110,7 +111,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri // string name = 2; v2 := compiler.MapValueForKey(m, "name") if v2 != nil { - x.Name, ok = v2.(string) + x.Name, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -119,7 +120,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri // string in = 3; v3 := compiler.MapValueForKey(m, "in") if v3 != nil { - x.In, ok = v3.(string) + x.In, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -134,7 +135,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri // string description = 4; v4 := compiler.MapValueForKey(m, "description") if v4 != nil { - x.Description, ok = v4.(string) + x.Description, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -143,10 +144,10 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri // repeated NamedAny vendor_extension = 5; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -200,7 +201,7 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -215,7 +216,7 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( // string description = 2; v2 := compiler.MapValueForKey(m, "description") if v2 != nil { - x.Description, ok = v2.(string) + x.Description, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -224,10 +225,10 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( // repeated NamedAny vendor_extension = 3; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -281,7 +282,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter // string description = 1; v1 := compiler.MapValueForKey(m, "description") if v1 != nil { - x.Description, ok = v1.(string) + x.Description, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -290,7 +291,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter // string name = 2; v2 := compiler.MapValueForKey(m, "name") if v2 != nil { - x.Name, ok = v2.(string) + x.Name, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -299,7 +300,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter // string in = 3; v3 := compiler.MapValueForKey(m, "in") if v3 != nil { - x.In, ok = v3.(string) + x.In, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -314,7 +315,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter // bool required = 4; v4 := compiler.MapValueForKey(m, "required") if v4 != nil { - x.Required, ok = v4.(bool) + x.Required, ok = compiler.BoolForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -332,10 +333,10 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter // repeated NamedAny vendor_extension = 6; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -383,7 +384,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -392,7 +393,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // string url = 2; v2 := compiler.MapValueForKey(m, "url") if v2 != nil { - x.Url, ok = v2.(string) + x.Url, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -401,7 +402,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // string email = 3; v3 := compiler.MapValueForKey(m, "email") if v3 != nil { - x.Email, ok = v3.(string) + x.Email, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for email: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -410,10 +411,10 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // repeated NamedAny vendor_extension = 4; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -454,10 +455,10 @@ func NewDefault(in interface{}, context *compiler.Context) (*Default, error) { // repeated NamedAny additional_properties = 1; // MAP: Any x.AdditionalProperties = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedAny{} pair.Name = k result := &Any{} @@ -496,10 +497,10 @@ func NewDefinitions(in interface{}, context *compiler.Context) (*Definitions, er // repeated NamedSchema additional_properties = 1; // MAP: Schema x.AdditionalProperties = make([]*NamedSchema, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedSchema{} pair.Name = k var err error @@ -539,7 +540,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string swagger = 1; v1 := compiler.MapValueForKey(m, "swagger") if v1 != nil { - x.Swagger, ok = v1.(string) + x.Swagger, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for swagger: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -563,7 +564,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string host = 3; v3 := compiler.MapValueForKey(m, "host") if v3 != nil { - x.Host, ok = v3.(string) + x.Host, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for host: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -572,7 +573,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string base_path = 4; v4 := compiler.MapValueForKey(m, "basePath") if v4 != nil { - x.BasePath, ok = v4.(string) + x.BasePath, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for basePath: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -581,9 +582,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // repeated string schemes = 5; v5 := compiler.MapValueForKey(m, "schemes") if v5 != nil { - v, ok := v5.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v5) if ok { - x.Schemes = compiler.ConvertInterfaceArrayToStringArray(v) + x.Schemes = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for schemes: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -598,9 +599,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // repeated string consumes = 6; v6 := compiler.MapValueForKey(m, "consumes") if v6 != nil { - v, ok := v6.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v6) if ok { - x.Consumes = compiler.ConvertInterfaceArrayToStringArray(v) + x.Consumes = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for consumes: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -609,9 +610,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // repeated string produces = 7; v7 := compiler.MapValueForKey(m, "produces") if v7 != nil { - v, ok := v7.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v7) if ok { - x.Produces = compiler.ConvertInterfaceArrayToStringArray(v) + x.Produces = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for produces: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -658,9 +659,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v12 != nil { // repeated SecurityRequirement x.Security = make([]*SecurityRequirement, 0) - a, ok := v12.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v12) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) if err != nil { errors = append(errors, err) @@ -683,9 +684,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v14 != nil { // repeated Tag x.Tags = make([]*Tag, 0) - a, ok := v14.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v14) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewTag(item, compiler.NewContext("tags", context)) if err != nil { errors = append(errors, err) @@ -706,10 +707,10 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // repeated NamedAny vendor_extension = 16; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -750,10 +751,10 @@ func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) { // repeated NamedAny additional_properties = 1; // MAP: Any x.AdditionalProperties = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedAny{} pair.Name = k result := &Any{} @@ -805,7 +806,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, // string description = 1; v1 := compiler.MapValueForKey(m, "description") if v1 != nil { - x.Description, ok = v1.(string) + x.Description, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -814,7 +815,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, // string url = 2; v2 := compiler.MapValueForKey(m, "url") if v2 != nil { - x.Url, ok = v2.(string) + x.Url, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -823,10 +824,10 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, // repeated NamedAny vendor_extension = 3; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -880,7 +881,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro // string format = 1; v1 := compiler.MapValueForKey(m, "format") if v1 != nil { - x.Format, ok = v1.(string) + x.Format, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -889,7 +890,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro // string title = 2; v2 := compiler.MapValueForKey(m, "title") if v2 != nil { - x.Title, ok = v2.(string) + x.Title, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -898,7 +899,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -916,9 +917,9 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro // repeated string required = 5; v5 := compiler.MapValueForKey(m, "required") if v5 != nil { - v, ok := v5.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v5) if ok { - x.Required = compiler.ConvertInterfaceArrayToStringArray(v) + x.Required = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -927,7 +928,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro // string type = 6; v6 := compiler.MapValueForKey(m, "type") if v6 != nil { - x.Type, ok = v6.(string) + x.Type, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -942,7 +943,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro // bool read_only = 7; v7 := compiler.MapValueForKey(m, "readOnly") if v7 != nil { - x.ReadOnly, ok = v7.(bool) + x.ReadOnly, ok = compiler.BoolForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -969,10 +970,10 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro // repeated NamedAny vendor_extension = 10; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1020,7 +1021,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // bool required = 1; v1 := compiler.MapValueForKey(m, "required") if v1 != nil { - x.Required, ok = v1.(bool) + x.Required, ok = compiler.BoolForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1029,7 +1030,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // string in = 2; v2 := compiler.MapValueForKey(m, "in") if v2 != nil { - x.In, ok = v2.(string) + x.In, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1044,7 +1045,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -1053,7 +1054,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // string name = 4; v4 := compiler.MapValueForKey(m, "name") if v4 != nil { - x.Name, ok = v4.(string) + x.Name, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -1062,7 +1063,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // bool allow_empty_value = 5; v5 := compiler.MapValueForKey(m, "allowEmptyValue") if v5 != nil { - x.AllowEmptyValue, ok = v5.(bool) + x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -1071,7 +1072,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // string type = 6; v6 := compiler.MapValueForKey(m, "type") if v6 != nil { - x.Type, ok = v6.(string) + x.Type, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -1086,7 +1087,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // string format = 7; v7 := compiler.MapValueForKey(m, "format") if v7 != nil { - x.Format, ok = v7.(string) + x.Format, ok = compiler.StringForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -1104,7 +1105,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // string collection_format = 9; v9 := compiler.MapValueForKey(m, "collectionFormat") if v9 != nil { - x.CollectionFormat, ok = v9.(string) + x.CollectionFormat, ok = compiler.StringForScalarNode(v9) if !ok { message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -1128,22 +1129,10 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // float maximum = 11; v11 := compiler.MapValueForKey(m, "maximum") if v11 != nil { - switch v11 := v11.(type) { - case float64: - x.Maximum = v11 - case float32: - x.Maximum = float64(v11) - case uint64: - x.Maximum = float64(v11) - case uint32: - x.Maximum = float64(v11) - case int64: - x.Maximum = float64(v11) - case int32: - x.Maximum = float64(v11) - case int: - x.Maximum = float64(v11) - default: + v, ok := compiler.FloatForScalarNode(v11) + if ok { + x.Maximum = v + } else { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) } @@ -1151,7 +1140,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // bool exclusive_maximum = 12; v12 := compiler.MapValueForKey(m, "exclusiveMaximum") if v12 != nil { - x.ExclusiveMaximum, ok = v12.(bool) + x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v12) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -1160,22 +1149,10 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // float minimum = 13; v13 := compiler.MapValueForKey(m, "minimum") if v13 != nil { - switch v13 := v13.(type) { - case float64: - x.Minimum = v13 - case float32: - x.Minimum = float64(v13) - case uint64: - x.Minimum = float64(v13) - case uint32: - x.Minimum = float64(v13) - case int64: - x.Minimum = float64(v13) - case int32: - x.Minimum = float64(v13) - case int: - x.Minimum = float64(v13) - default: + v, ok := compiler.FloatForScalarNode(v13) + if ok { + x.Minimum = v + } else { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) } @@ -1183,7 +1160,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // bool exclusive_minimum = 14; v14 := compiler.MapValueForKey(m, "exclusiveMinimum") if v14 != nil { - x.ExclusiveMinimum, ok = v14.(bool) + x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v14) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14) errors = append(errors, compiler.NewError(context, message)) @@ -1192,7 +1169,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // int64 max_length = 15; v15 := compiler.MapValueForKey(m, "maxLength") if v15 != nil { - t, ok := v15.(int) + t, ok := compiler.IntForScalarNode(v15) if ok { x.MaxLength = int64(t) } else { @@ -1203,7 +1180,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // int64 min_length = 16; v16 := compiler.MapValueForKey(m, "minLength") if v16 != nil { - t, ok := v16.(int) + t, ok := compiler.IntForScalarNode(v16) if ok { x.MinLength = int64(t) } else { @@ -1214,7 +1191,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // string pattern = 17; v17 := compiler.MapValueForKey(m, "pattern") if v17 != nil { - x.Pattern, ok = v17.(string) + x.Pattern, ok = compiler.StringForScalarNode(v17) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17) errors = append(errors, compiler.NewError(context, message)) @@ -1223,7 +1200,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // int64 max_items = 18; v18 := compiler.MapValueForKey(m, "maxItems") if v18 != nil { - t, ok := v18.(int) + t, ok := compiler.IntForScalarNode(v18) if ok { x.MaxItems = int64(t) } else { @@ -1234,7 +1211,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // int64 min_items = 19; v19 := compiler.MapValueForKey(m, "minItems") if v19 != nil { - t, ok := v19.(int) + t, ok := compiler.IntForScalarNode(v19) if ok { x.MinItems = int64(t) } else { @@ -1245,7 +1222,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // bool unique_items = 20; v20 := compiler.MapValueForKey(m, "uniqueItems") if v20 != nil { - x.UniqueItems, ok = v20.(bool) + x.UniqueItems, ok = compiler.BoolForScalarNode(v20) if !ok { message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20) errors = append(errors, compiler.NewError(context, message)) @@ -1256,9 +1233,9 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v21 != nil { // repeated Any x.Enum = make([]*Any, 0) - a, ok := v21.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v21) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewAny(item, compiler.NewContext("enum", context)) if err != nil { errors = append(errors, err) @@ -1270,22 +1247,10 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // float multiple_of = 22; v22 := compiler.MapValueForKey(m, "multipleOf") if v22 != nil { - switch v22 := v22.(type) { - case float64: - x.MultipleOf = v22 - case float32: - x.MultipleOf = float64(v22) - case uint64: - x.MultipleOf = float64(v22) - case uint32: - x.MultipleOf = float64(v22) - case int64: - x.MultipleOf = float64(v22) - case int32: - x.MultipleOf = float64(v22) - case int: - x.MultipleOf = float64(v22) - default: + v, ok := compiler.FloatForScalarNode(v22) + if ok { + x.MultipleOf = v + } else { message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v22, v22) errors = append(errors, compiler.NewError(context, message)) } @@ -1293,10 +1258,10 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* // repeated NamedAny vendor_extension = 23; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1350,7 +1315,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1365,7 +1330,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // string format = 2; v2 := compiler.MapValueForKey(m, "format") if v2 != nil { - x.Format, ok = v2.(string) + x.Format, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1383,7 +1348,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // string collection_format = 4; v4 := compiler.MapValueForKey(m, "collectionFormat") if v4 != nil { - x.CollectionFormat, ok = v4.(string) + x.CollectionFormat, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -1407,22 +1372,10 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // float maximum = 6; v6 := compiler.MapValueForKey(m, "maximum") if v6 != nil { - switch v6 := v6.(type) { - case float64: - x.Maximum = v6 - case float32: - x.Maximum = float64(v6) - case uint64: - x.Maximum = float64(v6) - case uint32: - x.Maximum = float64(v6) - case int64: - x.Maximum = float64(v6) - case int32: - x.Maximum = float64(v6) - case int: - x.Maximum = float64(v6) - default: + v, ok := compiler.FloatForScalarNode(v6) + if ok { + x.Maximum = v + } else { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) } @@ -1430,7 +1383,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // bool exclusive_maximum = 7; v7 := compiler.MapValueForKey(m, "exclusiveMaximum") if v7 != nil { - x.ExclusiveMaximum, ok = v7.(bool) + x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -1439,22 +1392,10 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // float minimum = 8; v8 := compiler.MapValueForKey(m, "minimum") if v8 != nil { - switch v8 := v8.(type) { - case float64: - x.Minimum = v8 - case float32: - x.Minimum = float64(v8) - case uint64: - x.Minimum = float64(v8) - case uint32: - x.Minimum = float64(v8) - case int64: - x.Minimum = float64(v8) - case int32: - x.Minimum = float64(v8) - case int: - x.Minimum = float64(v8) - default: + v, ok := compiler.FloatForScalarNode(v8) + if ok { + x.Minimum = v + } else { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) } @@ -1462,7 +1403,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // bool exclusive_minimum = 9; v9 := compiler.MapValueForKey(m, "exclusiveMinimum") if v9 != nil { - x.ExclusiveMinimum, ok = v9.(bool) + x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v9) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -1471,7 +1412,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // int64 max_length = 10; v10 := compiler.MapValueForKey(m, "maxLength") if v10 != nil { - t, ok := v10.(int) + t, ok := compiler.IntForScalarNode(v10) if ok { x.MaxLength = int64(t) } else { @@ -1482,7 +1423,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // int64 min_length = 11; v11 := compiler.MapValueForKey(m, "minLength") if v11 != nil { - t, ok := v11.(int) + t, ok := compiler.IntForScalarNode(v11) if ok { x.MinLength = int64(t) } else { @@ -1493,7 +1434,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // string pattern = 12; v12 := compiler.MapValueForKey(m, "pattern") if v12 != nil { - x.Pattern, ok = v12.(string) + x.Pattern, ok = compiler.StringForScalarNode(v12) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -1502,7 +1443,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // int64 max_items = 13; v13 := compiler.MapValueForKey(m, "maxItems") if v13 != nil { - t, ok := v13.(int) + t, ok := compiler.IntForScalarNode(v13) if ok { x.MaxItems = int64(t) } else { @@ -1513,7 +1454,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // int64 min_items = 14; v14 := compiler.MapValueForKey(m, "minItems") if v14 != nil { - t, ok := v14.(int) + t, ok := compiler.IntForScalarNode(v14) if ok { x.MinItems = int64(t) } else { @@ -1524,7 +1465,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // bool unique_items = 15; v15 := compiler.MapValueForKey(m, "uniqueItems") if v15 != nil { - x.UniqueItems, ok = v15.(bool) + x.UniqueItems, ok = compiler.BoolForScalarNode(v15) if !ok { message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v15, v15) errors = append(errors, compiler.NewError(context, message)) @@ -1535,9 +1476,9 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v16 != nil { // repeated Any x.Enum = make([]*Any, 0) - a, ok := v16.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v16) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewAny(item, compiler.NewContext("enum", context)) if err != nil { errors = append(errors, err) @@ -1549,22 +1490,10 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // float multiple_of = 17; v17 := compiler.MapValueForKey(m, "multipleOf") if v17 != nil { - switch v17 := v17.(type) { - case float64: - x.MultipleOf = v17 - case float32: - x.MultipleOf = float64(v17) - case uint64: - x.MultipleOf = float64(v17) - case uint32: - x.MultipleOf = float64(v17) - case int64: - x.MultipleOf = float64(v17) - case int32: - x.MultipleOf = float64(v17) - case int: - x.MultipleOf = float64(v17) - default: + v, ok := compiler.FloatForScalarNode(v17) + if ok { + x.MultipleOf = v + } else { message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v17, v17) errors = append(errors, compiler.NewError(context, message)) } @@ -1572,7 +1501,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // string description = 18; v18 := compiler.MapValueForKey(m, "description") if v18 != nil { - x.Description, ok = v18.(string) + x.Description, ok = compiler.StringForScalarNode(v18) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v18, v18) errors = append(errors, compiler.NewError(context, message)) @@ -1581,10 +1510,10 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // repeated NamedAny vendor_extension = 19; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1632,7 +1561,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // bool required = 1; v1 := compiler.MapValueForKey(m, "required") if v1 != nil { - x.Required, ok = v1.(bool) + x.Required, ok = compiler.BoolForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1641,7 +1570,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // string in = 2; v2 := compiler.MapValueForKey(m, "in") if v2 != nil { - x.In, ok = v2.(string) + x.In, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1656,7 +1585,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -1665,7 +1594,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // string name = 4; v4 := compiler.MapValueForKey(m, "name") if v4 != nil { - x.Name, ok = v4.(string) + x.Name, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -1674,7 +1603,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // string type = 5; v5 := compiler.MapValueForKey(m, "type") if v5 != nil { - x.Type, ok = v5.(string) + x.Type, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -1689,7 +1618,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // string format = 6; v6 := compiler.MapValueForKey(m, "format") if v6 != nil { - x.Format, ok = v6.(string) + x.Format, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -1707,7 +1636,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // string collection_format = 8; v8 := compiler.MapValueForKey(m, "collectionFormat") if v8 != nil { - x.CollectionFormat, ok = v8.(string) + x.CollectionFormat, ok = compiler.StringForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -1731,22 +1660,10 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // float maximum = 10; v10 := compiler.MapValueForKey(m, "maximum") if v10 != nil { - switch v10 := v10.(type) { - case float64: - x.Maximum = v10 - case float32: - x.Maximum = float64(v10) - case uint64: - x.Maximum = float64(v10) - case uint32: - x.Maximum = float64(v10) - case int64: - x.Maximum = float64(v10) - case int32: - x.Maximum = float64(v10) - case int: - x.Maximum = float64(v10) - default: + v, ok := compiler.FloatForScalarNode(v10) + if ok { + x.Maximum = v + } else { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) } @@ -1754,7 +1671,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // bool exclusive_maximum = 11; v11 := compiler.MapValueForKey(m, "exclusiveMaximum") if v11 != nil { - x.ExclusiveMaximum, ok = v11.(bool) + x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v11) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) @@ -1763,22 +1680,10 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // float minimum = 12; v12 := compiler.MapValueForKey(m, "minimum") if v12 != nil { - switch v12 := v12.(type) { - case float64: - x.Minimum = v12 - case float32: - x.Minimum = float64(v12) - case uint64: - x.Minimum = float64(v12) - case uint32: - x.Minimum = float64(v12) - case int64: - x.Minimum = float64(v12) - case int32: - x.Minimum = float64(v12) - case int: - x.Minimum = float64(v12) - default: + v, ok := compiler.FloatForScalarNode(v12) + if ok { + x.Minimum = v + } else { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) } @@ -1786,7 +1691,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // bool exclusive_minimum = 13; v13 := compiler.MapValueForKey(m, "exclusiveMinimum") if v13 != nil { - x.ExclusiveMinimum, ok = v13.(bool) + x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v13) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) @@ -1795,7 +1700,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // int64 max_length = 14; v14 := compiler.MapValueForKey(m, "maxLength") if v14 != nil { - t, ok := v14.(int) + t, ok := compiler.IntForScalarNode(v14) if ok { x.MaxLength = int64(t) } else { @@ -1806,7 +1711,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // int64 min_length = 15; v15 := compiler.MapValueForKey(m, "minLength") if v15 != nil { - t, ok := v15.(int) + t, ok := compiler.IntForScalarNode(v15) if ok { x.MinLength = int64(t) } else { @@ -1817,7 +1722,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // string pattern = 16; v16 := compiler.MapValueForKey(m, "pattern") if v16 != nil { - x.Pattern, ok = v16.(string) + x.Pattern, ok = compiler.StringForScalarNode(v16) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16) errors = append(errors, compiler.NewError(context, message)) @@ -1826,7 +1731,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // int64 max_items = 17; v17 := compiler.MapValueForKey(m, "maxItems") if v17 != nil { - t, ok := v17.(int) + t, ok := compiler.IntForScalarNode(v17) if ok { x.MaxItems = int64(t) } else { @@ -1837,7 +1742,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // int64 min_items = 18; v18 := compiler.MapValueForKey(m, "minItems") if v18 != nil { - t, ok := v18.(int) + t, ok := compiler.IntForScalarNode(v18) if ok { x.MinItems = int64(t) } else { @@ -1848,7 +1753,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // bool unique_items = 19; v19 := compiler.MapValueForKey(m, "uniqueItems") if v19 != nil { - x.UniqueItems, ok = v19.(bool) + x.UniqueItems, ok = compiler.BoolForScalarNode(v19) if !ok { message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19) errors = append(errors, compiler.NewError(context, message)) @@ -1859,9 +1764,9 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v20 != nil { // repeated Any x.Enum = make([]*Any, 0) - a, ok := v20.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v20) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewAny(item, compiler.NewContext("enum", context)) if err != nil { errors = append(errors, err) @@ -1873,22 +1778,10 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // float multiple_of = 21; v21 := compiler.MapValueForKey(m, "multipleOf") if v21 != nil { - switch v21 := v21.(type) { - case float64: - x.MultipleOf = v21 - case float32: - x.MultipleOf = float64(v21) - case uint64: - x.MultipleOf = float64(v21) - case uint32: - x.MultipleOf = float64(v21) - case int64: - x.MultipleOf = float64(v21) - case int32: - x.MultipleOf = float64(v21) - case int: - x.MultipleOf = float64(v21) - default: + v, ok := compiler.FloatForScalarNode(v21) + if ok { + x.MultipleOf = v + } else { message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v21, v21) errors = append(errors, compiler.NewError(context, message)) } @@ -1896,10 +1789,10 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He // repeated NamedAny vendor_extension = 22; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1940,10 +1833,10 @@ func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) { // repeated NamedHeader additional_properties = 1; // MAP: Header x.AdditionalProperties = make([]*NamedHeader, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedHeader{} pair.Name = k var err error @@ -1983,7 +1876,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string title = 1; v1 := compiler.MapValueForKey(m, "title") if v1 != nil { - x.Title, ok = v1.(string) + x.Title, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1992,7 +1885,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string version = 2; v2 := compiler.MapValueForKey(m, "version") if v2 != nil { - x.Version, ok = v2.(string) + x.Version, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2001,7 +1894,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -2010,7 +1903,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string terms_of_service = 4; v4 := compiler.MapValueForKey(m, "termsOfService") if v4 != nil { - x.TermsOfService, ok = v4.(string) + x.TermsOfService, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for termsOfService: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -2037,10 +1930,10 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // repeated NamedAny vendor_extension = 7; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -2106,7 +1999,7 @@ func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference // string _ref = 1; v1 := compiler.MapValueForKey(m, "$ref") if v1 != nil { - x.XRef, ok = v1.(string) + x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2115,7 +2008,7 @@ func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference // string description = 2; v2 := compiler.MapValueForKey(m, "description") if v2 != nil { - x.Description, ok = v2.(string) + x.Description, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2150,7 +2043,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2159,7 +2052,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { // string url = 2; v2 := compiler.MapValueForKey(m, "url") if v2 != nil { - x.Url, ok = v2.(string) + x.Url, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2168,10 +2061,10 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { // repeated NamedAny vendor_extension = 3; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -2219,7 +2112,7 @@ func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2257,7 +2150,7 @@ func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, er // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2295,7 +2188,7 @@ func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParamet // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2333,7 +2226,7 @@ func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2371,7 +2264,7 @@ func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2409,7 +2302,7 @@ func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedRes // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2447,7 +2340,7 @@ func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, er // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2485,7 +2378,7 @@ func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2523,7 +2416,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2532,7 +2425,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er // string value = 2; v2 := compiler.MapValueForKey(m, "value") if v2 != nil { - x.Value, ok = v2.(string) + x.Value, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for value: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2561,7 +2454,7 @@ func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStrin // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2673,7 +2566,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2688,7 +2581,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa // string flow = 2; v2 := compiler.MapValueForKey(m, "flow") if v2 != nil { - x.Flow, ok = v2.(string) + x.Flow, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2712,7 +2605,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa // string authorization_url = 4; v4 := compiler.MapValueForKey(m, "authorizationUrl") if v4 != nil { - x.AuthorizationUrl, ok = v4.(string) + x.AuthorizationUrl, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -2721,7 +2614,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa // string token_url = 5; v5 := compiler.MapValueForKey(m, "tokenUrl") if v5 != nil { - x.TokenUrl, ok = v5.(string) + x.TokenUrl, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -2730,7 +2623,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa // string description = 6; v6 := compiler.MapValueForKey(m, "description") if v6 != nil { - x.Description, ok = v6.(string) + x.Description, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -2739,10 +2632,10 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa // repeated NamedAny vendor_extension = 7; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -2796,7 +2689,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2811,7 +2704,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O // string flow = 2; v2 := compiler.MapValueForKey(m, "flow") if v2 != nil { - x.Flow, ok = v2.(string) + x.Flow, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2835,7 +2728,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O // string token_url = 4; v4 := compiler.MapValueForKey(m, "tokenUrl") if v4 != nil { - x.TokenUrl, ok = v4.(string) + x.TokenUrl, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -2844,7 +2737,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O // string description = 5; v5 := compiler.MapValueForKey(m, "description") if v5 != nil { - x.Description, ok = v5.(string) + x.Description, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -2853,10 +2746,10 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O // repeated NamedAny vendor_extension = 6; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -2910,7 +2803,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2925,7 +2818,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut // string flow = 2; v2 := compiler.MapValueForKey(m, "flow") if v2 != nil { - x.Flow, ok = v2.(string) + x.Flow, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2949,7 +2842,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut // string authorization_url = 4; v4 := compiler.MapValueForKey(m, "authorizationUrl") if v4 != nil { - x.AuthorizationUrl, ok = v4.(string) + x.AuthorizationUrl, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -2958,7 +2851,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut // string description = 5; v5 := compiler.MapValueForKey(m, "description") if v5 != nil { - x.Description, ok = v5.(string) + x.Description, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -2967,10 +2860,10 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut // repeated NamedAny vendor_extension = 6; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3024,7 +2917,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3039,7 +2932,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut // string flow = 2; v2 := compiler.MapValueForKey(m, "flow") if v2 != nil { - x.Flow, ok = v2.(string) + x.Flow, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -3063,7 +2956,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut // string token_url = 4; v4 := compiler.MapValueForKey(m, "tokenUrl") if v4 != nil { - x.TokenUrl, ok = v4.(string) + x.TokenUrl, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -3072,7 +2965,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut // string description = 5; v5 := compiler.MapValueForKey(m, "description") if v5 != nil { - x.Description, ok = v5.(string) + x.Description, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -3081,10 +2974,10 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut // repeated NamedAny vendor_extension = 6; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3125,13 +3018,13 @@ func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, // repeated NamedString additional_properties = 1; // MAP: string x.AdditionalProperties = make([]*NamedString, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedString{} pair.Name = k - pair.Value = v.(string) + pair.Value, _ = compiler.StringForScalarNode(v) x.AdditionalProperties = append(x.AdditionalProperties, pair) } } @@ -3164,9 +3057,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // repeated string tags = 1; v1 := compiler.MapValueForKey(m, "tags") if v1 != nil { - v, ok := v1.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v1) if ok { - x.Tags = compiler.ConvertInterfaceArrayToStringArray(v) + x.Tags = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for tags: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3175,7 +3068,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // string summary = 2; v2 := compiler.MapValueForKey(m, "summary") if v2 != nil { - x.Summary, ok = v2.(string) + x.Summary, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -3184,7 +3077,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -3202,7 +3095,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // string operation_id = 5; v5 := compiler.MapValueForKey(m, "operationId") if v5 != nil { - x.OperationId, ok = v5.(string) + x.OperationId, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -3211,9 +3104,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // repeated string produces = 6; v6 := compiler.MapValueForKey(m, "produces") if v6 != nil { - v, ok := v6.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v6) if ok { - x.Produces = compiler.ConvertInterfaceArrayToStringArray(v) + x.Produces = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for produces: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -3222,9 +3115,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // repeated string consumes = 7; v7 := compiler.MapValueForKey(m, "consumes") if v7 != nil { - v, ok := v7.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v7) if ok { - x.Consumes = compiler.ConvertInterfaceArrayToStringArray(v) + x.Consumes = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for consumes: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -3235,9 +3128,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v8 != nil { // repeated ParametersItem x.Parameters = make([]*ParametersItem, 0) - a, ok := v8.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v8) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewParametersItem(item, compiler.NewContext("parameters", context)) if err != nil { errors = append(errors, err) @@ -3258,9 +3151,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // repeated string schemes = 10; v10 := compiler.MapValueForKey(m, "schemes") if v10 != nil { - v, ok := v10.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v10) if ok { - x.Schemes = compiler.ConvertInterfaceArrayToStringArray(v) + x.Schemes = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for schemes: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) @@ -3275,7 +3168,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // bool deprecated = 11; v11 := compiler.MapValueForKey(m, "deprecated") if v11 != nil { - x.Deprecated, ok = v11.(bool) + x.Deprecated, ok = compiler.BoolForScalarNode(v11) if !ok { message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) @@ -3286,9 +3179,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v12 != nil { // repeated SecurityRequirement x.Security = make([]*SecurityRequirement, 0) - a, ok := v12.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v12) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) if err != nil { errors = append(errors, err) @@ -3300,10 +3193,10 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // repeated NamedAny vendor_extension = 13; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3384,10 +3277,10 @@ func NewParameterDefinitions(in interface{}, context *compiler.Context) (*Parame // repeated NamedParameter additional_properties = 1; // MAP: Parameter x.AdditionalProperties = make([]*NamedParameter, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedParameter{} pair.Name = k var err error @@ -3461,7 +3354,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { // string _ref = 1; v1 := compiler.MapValueForKey(m, "$ref") if v1 != nil { - x.XRef, ok = v1.(string) + x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3535,9 +3428,9 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if v9 != nil { // repeated ParametersItem x.Parameters = make([]*ParametersItem, 0) - a, ok := v9.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v9) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewParametersItem(item, compiler.NewContext("parameters", context)) if err != nil { errors = append(errors, err) @@ -3549,10 +3442,10 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { // repeated NamedAny vendor_extension = 10; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3606,7 +3499,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // bool required = 1; v1 := compiler.MapValueForKey(m, "required") if v1 != nil { - x.Required, ok = v1.(bool) + x.Required, ok = compiler.BoolForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3615,7 +3508,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // string in = 2; v2 := compiler.MapValueForKey(m, "in") if v2 != nil { - x.In, ok = v2.(string) + x.In, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -3630,7 +3523,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -3639,7 +3532,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // string name = 4; v4 := compiler.MapValueForKey(m, "name") if v4 != nil { - x.Name, ok = v4.(string) + x.Name, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -3648,7 +3541,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // string type = 5; v5 := compiler.MapValueForKey(m, "type") if v5 != nil { - x.Type, ok = v5.(string) + x.Type, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -3663,7 +3556,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // string format = 6; v6 := compiler.MapValueForKey(m, "format") if v6 != nil { - x.Format, ok = v6.(string) + x.Format, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -3681,7 +3574,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // string collection_format = 8; v8 := compiler.MapValueForKey(m, "collectionFormat") if v8 != nil { - x.CollectionFormat, ok = v8.(string) + x.CollectionFormat, ok = compiler.StringForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -3705,22 +3598,10 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // float maximum = 10; v10 := compiler.MapValueForKey(m, "maximum") if v10 != nil { - switch v10 := v10.(type) { - case float64: - x.Maximum = v10 - case float32: - x.Maximum = float64(v10) - case uint64: - x.Maximum = float64(v10) - case uint32: - x.Maximum = float64(v10) - case int64: - x.Maximum = float64(v10) - case int32: - x.Maximum = float64(v10) - case int: - x.Maximum = float64(v10) - default: + v, ok := compiler.FloatForScalarNode(v10) + if ok { + x.Maximum = v + } else { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) } @@ -3728,7 +3609,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // bool exclusive_maximum = 11; v11 := compiler.MapValueForKey(m, "exclusiveMaximum") if v11 != nil { - x.ExclusiveMaximum, ok = v11.(bool) + x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v11) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) @@ -3737,22 +3618,10 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // float minimum = 12; v12 := compiler.MapValueForKey(m, "minimum") if v12 != nil { - switch v12 := v12.(type) { - case float64: - x.Minimum = v12 - case float32: - x.Minimum = float64(v12) - case uint64: - x.Minimum = float64(v12) - case uint32: - x.Minimum = float64(v12) - case int64: - x.Minimum = float64(v12) - case int32: - x.Minimum = float64(v12) - case int: - x.Minimum = float64(v12) - default: + v, ok := compiler.FloatForScalarNode(v12) + if ok { + x.Minimum = v + } else { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) } @@ -3760,7 +3629,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // bool exclusive_minimum = 13; v13 := compiler.MapValueForKey(m, "exclusiveMinimum") if v13 != nil { - x.ExclusiveMinimum, ok = v13.(bool) + x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v13) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) @@ -3769,7 +3638,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // int64 max_length = 14; v14 := compiler.MapValueForKey(m, "maxLength") if v14 != nil { - t, ok := v14.(int) + t, ok := compiler.IntForScalarNode(v14) if ok { x.MaxLength = int64(t) } else { @@ -3780,7 +3649,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // int64 min_length = 15; v15 := compiler.MapValueForKey(m, "minLength") if v15 != nil { - t, ok := v15.(int) + t, ok := compiler.IntForScalarNode(v15) if ok { x.MinLength = int64(t) } else { @@ -3791,7 +3660,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // string pattern = 16; v16 := compiler.MapValueForKey(m, "pattern") if v16 != nil { - x.Pattern, ok = v16.(string) + x.Pattern, ok = compiler.StringForScalarNode(v16) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16) errors = append(errors, compiler.NewError(context, message)) @@ -3800,7 +3669,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // int64 max_items = 17; v17 := compiler.MapValueForKey(m, "maxItems") if v17 != nil { - t, ok := v17.(int) + t, ok := compiler.IntForScalarNode(v17) if ok { x.MaxItems = int64(t) } else { @@ -3811,7 +3680,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // int64 min_items = 18; v18 := compiler.MapValueForKey(m, "minItems") if v18 != nil { - t, ok := v18.(int) + t, ok := compiler.IntForScalarNode(v18) if ok { x.MinItems = int64(t) } else { @@ -3822,7 +3691,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // bool unique_items = 19; v19 := compiler.MapValueForKey(m, "uniqueItems") if v19 != nil { - x.UniqueItems, ok = v19.(bool) + x.UniqueItems, ok = compiler.BoolForScalarNode(v19) if !ok { message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19) errors = append(errors, compiler.NewError(context, message)) @@ -3833,9 +3702,9 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v20 != nil { // repeated Any x.Enum = make([]*Any, 0) - a, ok := v20.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v20) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewAny(item, compiler.NewContext("enum", context)) if err != nil { errors = append(errors, err) @@ -3847,22 +3716,10 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // float multiple_of = 21; v21 := compiler.MapValueForKey(m, "multipleOf") if v21 != nil { - switch v21 := v21.(type) { - case float64: - x.MultipleOf = v21 - case float32: - x.MultipleOf = float64(v21) - case uint64: - x.MultipleOf = float64(v21) - case uint32: - x.MultipleOf = float64(v21) - case int64: - x.MultipleOf = float64(v21) - case int32: - x.MultipleOf = float64(v21) - case int: - x.MultipleOf = float64(v21) - default: + v, ok := compiler.FloatForScalarNode(v21) + if ok { + x.MultipleOf = v + } else { message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v21, v21) errors = append(errors, compiler.NewError(context, message)) } @@ -3870,10 +3727,10 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path // repeated NamedAny vendor_extension = 22; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3921,10 +3778,10 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { // repeated NamedAny vendor_extension = 1; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3952,10 +3809,10 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { // repeated NamedPathItem path = 2; // MAP: PathItem ^/ x.Path = make([]*NamedPathItem, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "/") { pair := &NamedPathItem{} pair.Name = k @@ -3991,7 +3848,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4006,7 +3863,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // string format = 2; v2 := compiler.MapValueForKey(m, "format") if v2 != nil { - x.Format, ok = v2.(string) + x.Format, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -4024,7 +3881,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // string collection_format = 4; v4 := compiler.MapValueForKey(m, "collectionFormat") if v4 != nil { - x.CollectionFormat, ok = v4.(string) + x.CollectionFormat, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -4048,22 +3905,10 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // float maximum = 6; v6 := compiler.MapValueForKey(m, "maximum") if v6 != nil { - switch v6 := v6.(type) { - case float64: - x.Maximum = v6 - case float32: - x.Maximum = float64(v6) - case uint64: - x.Maximum = float64(v6) - case uint32: - x.Maximum = float64(v6) - case int64: - x.Maximum = float64(v6) - case int32: - x.Maximum = float64(v6) - case int: - x.Maximum = float64(v6) - default: + v, ok := compiler.FloatForScalarNode(v6) + if ok { + x.Maximum = v + } else { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) } @@ -4071,7 +3916,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // bool exclusive_maximum = 7; v7 := compiler.MapValueForKey(m, "exclusiveMaximum") if v7 != nil { - x.ExclusiveMaximum, ok = v7.(bool) + x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -4080,22 +3925,10 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // float minimum = 8; v8 := compiler.MapValueForKey(m, "minimum") if v8 != nil { - switch v8 := v8.(type) { - case float64: - x.Minimum = v8 - case float32: - x.Minimum = float64(v8) - case uint64: - x.Minimum = float64(v8) - case uint32: - x.Minimum = float64(v8) - case int64: - x.Minimum = float64(v8) - case int32: - x.Minimum = float64(v8) - case int: - x.Minimum = float64(v8) - default: + v, ok := compiler.FloatForScalarNode(v8) + if ok { + x.Minimum = v + } else { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) } @@ -4103,7 +3936,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // bool exclusive_minimum = 9; v9 := compiler.MapValueForKey(m, "exclusiveMinimum") if v9 != nil { - x.ExclusiveMinimum, ok = v9.(bool) + x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v9) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -4112,7 +3945,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // int64 max_length = 10; v10 := compiler.MapValueForKey(m, "maxLength") if v10 != nil { - t, ok := v10.(int) + t, ok := compiler.IntForScalarNode(v10) if ok { x.MaxLength = int64(t) } else { @@ -4123,7 +3956,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // int64 min_length = 11; v11 := compiler.MapValueForKey(m, "minLength") if v11 != nil { - t, ok := v11.(int) + t, ok := compiler.IntForScalarNode(v11) if ok { x.MinLength = int64(t) } else { @@ -4134,7 +3967,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // string pattern = 12; v12 := compiler.MapValueForKey(m, "pattern") if v12 != nil { - x.Pattern, ok = v12.(string) + x.Pattern, ok = compiler.StringForScalarNode(v12) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -4143,7 +3976,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // int64 max_items = 13; v13 := compiler.MapValueForKey(m, "maxItems") if v13 != nil { - t, ok := v13.(int) + t, ok := compiler.IntForScalarNode(v13) if ok { x.MaxItems = int64(t) } else { @@ -4154,7 +3987,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // int64 min_items = 14; v14 := compiler.MapValueForKey(m, "minItems") if v14 != nil { - t, ok := v14.(int) + t, ok := compiler.IntForScalarNode(v14) if ok { x.MinItems = int64(t) } else { @@ -4165,7 +3998,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // bool unique_items = 15; v15 := compiler.MapValueForKey(m, "uniqueItems") if v15 != nil { - x.UniqueItems, ok = v15.(bool) + x.UniqueItems, ok = compiler.BoolForScalarNode(v15) if !ok { message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v15, v15) errors = append(errors, compiler.NewError(context, message)) @@ -4176,9 +4009,9 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if v16 != nil { // repeated Any x.Enum = make([]*Any, 0) - a, ok := v16.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v16) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewAny(item, compiler.NewContext("enum", context)) if err != nil { errors = append(errors, err) @@ -4190,22 +4023,10 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // float multiple_of = 17; v17 := compiler.MapValueForKey(m, "multipleOf") if v17 != nil { - switch v17 := v17.(type) { - case float64: - x.MultipleOf = v17 - case float32: - x.MultipleOf = float64(v17) - case uint64: - x.MultipleOf = float64(v17) - case uint32: - x.MultipleOf = float64(v17) - case int64: - x.MultipleOf = float64(v17) - case int32: - x.MultipleOf = float64(v17) - case int: - x.MultipleOf = float64(v17) - default: + v, ok := compiler.FloatForScalarNode(v17) + if ok { + x.MultipleOf = v + } else { message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v17, v17) errors = append(errors, compiler.NewError(context, message)) } @@ -4213,10 +4034,10 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI // repeated NamedAny vendor_extension = 18; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4257,10 +4078,10 @@ func NewProperties(in interface{}, context *compiler.Context) (*Properties, erro // repeated NamedSchema additional_properties = 1; // MAP: Schema x.AdditionalProperties = make([]*NamedSchema, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedSchema{} pair.Name = k var err error @@ -4294,7 +4115,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // bool required = 1; v1 := compiler.MapValueForKey(m, "required") if v1 != nil { - x.Required, ok = v1.(bool) + x.Required, ok = compiler.BoolForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4303,7 +4124,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // string in = 2; v2 := compiler.MapValueForKey(m, "in") if v2 != nil { - x.In, ok = v2.(string) + x.In, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -4318,7 +4139,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -4327,7 +4148,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // string name = 4; v4 := compiler.MapValueForKey(m, "name") if v4 != nil { - x.Name, ok = v4.(string) + x.Name, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -4336,7 +4157,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // bool allow_empty_value = 5; v5 := compiler.MapValueForKey(m, "allowEmptyValue") if v5 != nil { - x.AllowEmptyValue, ok = v5.(bool) + x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -4345,7 +4166,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // string type = 6; v6 := compiler.MapValueForKey(m, "type") if v6 != nil { - x.Type, ok = v6.(string) + x.Type, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -4360,7 +4181,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // string format = 7; v7 := compiler.MapValueForKey(m, "format") if v7 != nil { - x.Format, ok = v7.(string) + x.Format, ok = compiler.StringForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -4378,7 +4199,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // string collection_format = 9; v9 := compiler.MapValueForKey(m, "collectionFormat") if v9 != nil { - x.CollectionFormat, ok = v9.(string) + x.CollectionFormat, ok = compiler.StringForScalarNode(v9) if !ok { message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -4402,22 +4223,10 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // float maximum = 11; v11 := compiler.MapValueForKey(m, "maximum") if v11 != nil { - switch v11 := v11.(type) { - case float64: - x.Maximum = v11 - case float32: - x.Maximum = float64(v11) - case uint64: - x.Maximum = float64(v11) - case uint32: - x.Maximum = float64(v11) - case int64: - x.Maximum = float64(v11) - case int32: - x.Maximum = float64(v11) - case int: - x.Maximum = float64(v11) - default: + v, ok := compiler.FloatForScalarNode(v11) + if ok { + x.Maximum = v + } else { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) } @@ -4425,7 +4234,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // bool exclusive_maximum = 12; v12 := compiler.MapValueForKey(m, "exclusiveMaximum") if v12 != nil { - x.ExclusiveMaximum, ok = v12.(bool) + x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v12) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -4434,22 +4243,10 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // float minimum = 13; v13 := compiler.MapValueForKey(m, "minimum") if v13 != nil { - switch v13 := v13.(type) { - case float64: - x.Minimum = v13 - case float32: - x.Minimum = float64(v13) - case uint64: - x.Minimum = float64(v13) - case uint32: - x.Minimum = float64(v13) - case int64: - x.Minimum = float64(v13) - case int32: - x.Minimum = float64(v13) - case int: - x.Minimum = float64(v13) - default: + v, ok := compiler.FloatForScalarNode(v13) + if ok { + x.Minimum = v + } else { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) } @@ -4457,7 +4254,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // bool exclusive_minimum = 14; v14 := compiler.MapValueForKey(m, "exclusiveMinimum") if v14 != nil { - x.ExclusiveMinimum, ok = v14.(bool) + x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v14) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14) errors = append(errors, compiler.NewError(context, message)) @@ -4466,7 +4263,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // int64 max_length = 15; v15 := compiler.MapValueForKey(m, "maxLength") if v15 != nil { - t, ok := v15.(int) + t, ok := compiler.IntForScalarNode(v15) if ok { x.MaxLength = int64(t) } else { @@ -4477,7 +4274,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // int64 min_length = 16; v16 := compiler.MapValueForKey(m, "minLength") if v16 != nil { - t, ok := v16.(int) + t, ok := compiler.IntForScalarNode(v16) if ok { x.MinLength = int64(t) } else { @@ -4488,7 +4285,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // string pattern = 17; v17 := compiler.MapValueForKey(m, "pattern") if v17 != nil { - x.Pattern, ok = v17.(string) + x.Pattern, ok = compiler.StringForScalarNode(v17) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17) errors = append(errors, compiler.NewError(context, message)) @@ -4497,7 +4294,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // int64 max_items = 18; v18 := compiler.MapValueForKey(m, "maxItems") if v18 != nil { - t, ok := v18.(int) + t, ok := compiler.IntForScalarNode(v18) if ok { x.MaxItems = int64(t) } else { @@ -4508,7 +4305,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // int64 min_items = 19; v19 := compiler.MapValueForKey(m, "minItems") if v19 != nil { - t, ok := v19.(int) + t, ok := compiler.IntForScalarNode(v19) if ok { x.MinItems = int64(t) } else { @@ -4519,7 +4316,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // bool unique_items = 20; v20 := compiler.MapValueForKey(m, "uniqueItems") if v20 != nil { - x.UniqueItems, ok = v20.(bool) + x.UniqueItems, ok = compiler.BoolForScalarNode(v20) if !ok { message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20) errors = append(errors, compiler.NewError(context, message)) @@ -4530,9 +4327,9 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v21 != nil { // repeated Any x.Enum = make([]*Any, 0) - a, ok := v21.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v21) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewAny(item, compiler.NewContext("enum", context)) if err != nil { errors = append(errors, err) @@ -4544,22 +4341,10 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // float multiple_of = 22; v22 := compiler.MapValueForKey(m, "multipleOf") if v22 != nil { - switch v22 := v22.(type) { - case float64: - x.MultipleOf = v22 - case float32: - x.MultipleOf = float64(v22) - case uint64: - x.MultipleOf = float64(v22) - case uint32: - x.MultipleOf = float64(v22) - case int64: - x.MultipleOf = float64(v22) - case int32: - x.MultipleOf = float64(v22) - case int: - x.MultipleOf = float64(v22) - default: + v, ok := compiler.FloatForScalarNode(v22) + if ok { + x.MultipleOf = v + } else { message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v22, v22) errors = append(errors, compiler.NewError(context, message)) } @@ -4567,10 +4352,10 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que // repeated NamedAny vendor_extension = 23; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4624,7 +4409,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { // string description = 1; v1 := compiler.MapValueForKey(m, "description") if v1 != nil { - x.Description, ok = v1.(string) + x.Description, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4660,10 +4445,10 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { // repeated NamedAny vendor_extension = 5; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4704,10 +4489,10 @@ func NewResponseDefinitions(in interface{}, context *compiler.Context) (*Respons // repeated NamedResponse additional_properties = 1; // MAP: Response x.AdditionalProperties = make([]*NamedResponse, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedResponse{} pair.Name = k var err error @@ -4781,10 +4566,10 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) // repeated NamedResponseValue response_code = 1; // MAP: ResponseValue ^([0-9]{3})$|^(default)$ x.ResponseCode = make([]*NamedResponseValue, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if pattern2.MatchString(k) { pair := &NamedResponseValue{} pair.Name = k @@ -4800,10 +4585,10 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) // repeated NamedAny vendor_extension = 2; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4851,7 +4636,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string _ref = 1; v1 := compiler.MapValueForKey(m, "$ref") if v1 != nil { - x.XRef, ok = v1.(string) + x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4860,7 +4645,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string format = 2; v2 := compiler.MapValueForKey(m, "format") if v2 != nil { - x.Format, ok = v2.(string) + x.Format, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -4869,7 +4654,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string title = 3; v3 := compiler.MapValueForKey(m, "title") if v3 != nil { - x.Title, ok = v3.(string) + x.Title, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -4878,7 +4663,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string description = 4; v4 := compiler.MapValueForKey(m, "description") if v4 != nil { - x.Description, ok = v4.(string) + x.Description, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -4896,22 +4681,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // float multiple_of = 6; v6 := compiler.MapValueForKey(m, "multipleOf") if v6 != nil { - switch v6 := v6.(type) { - case float64: - x.MultipleOf = v6 - case float32: - x.MultipleOf = float64(v6) - case uint64: - x.MultipleOf = float64(v6) - case uint32: - x.MultipleOf = float64(v6) - case int64: - x.MultipleOf = float64(v6) - case int32: - x.MultipleOf = float64(v6) - case int: - x.MultipleOf = float64(v6) - default: + v, ok := compiler.FloatForScalarNode(v6) + if ok { + x.MultipleOf = v + } else { message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) } @@ -4919,22 +4692,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // float maximum = 7; v7 := compiler.MapValueForKey(m, "maximum") if v7 != nil { - switch v7 := v7.(type) { - case float64: - x.Maximum = v7 - case float32: - x.Maximum = float64(v7) - case uint64: - x.Maximum = float64(v7) - case uint32: - x.Maximum = float64(v7) - case int64: - x.Maximum = float64(v7) - case int32: - x.Maximum = float64(v7) - case int: - x.Maximum = float64(v7) - default: + v, ok := compiler.FloatForScalarNode(v7) + if ok { + x.Maximum = v + } else { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) } @@ -4942,7 +4703,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool exclusive_maximum = 8; v8 := compiler.MapValueForKey(m, "exclusiveMaximum") if v8 != nil { - x.ExclusiveMaximum, ok = v8.(bool) + x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -4951,22 +4712,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // float minimum = 9; v9 := compiler.MapValueForKey(m, "minimum") if v9 != nil { - switch v9 := v9.(type) { - case float64: - x.Minimum = v9 - case float32: - x.Minimum = float64(v9) - case uint64: - x.Minimum = float64(v9) - case uint32: - x.Minimum = float64(v9) - case int64: - x.Minimum = float64(v9) - case int32: - x.Minimum = float64(v9) - case int: - x.Minimum = float64(v9) - default: + v, ok := compiler.FloatForScalarNode(v9) + if ok { + x.Minimum = v + } else { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) } @@ -4974,7 +4723,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool exclusive_minimum = 10; v10 := compiler.MapValueForKey(m, "exclusiveMinimum") if v10 != nil { - x.ExclusiveMinimum, ok = v10.(bool) + x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v10) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) @@ -4983,7 +4732,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 max_length = 11; v11 := compiler.MapValueForKey(m, "maxLength") if v11 != nil { - t, ok := v11.(int) + t, ok := compiler.IntForScalarNode(v11) if ok { x.MaxLength = int64(t) } else { @@ -4994,7 +4743,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 min_length = 12; v12 := compiler.MapValueForKey(m, "minLength") if v12 != nil { - t, ok := v12.(int) + t, ok := compiler.IntForScalarNode(v12) if ok { x.MinLength = int64(t) } else { @@ -5005,7 +4754,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string pattern = 13; v13 := compiler.MapValueForKey(m, "pattern") if v13 != nil { - x.Pattern, ok = v13.(string) + x.Pattern, ok = compiler.StringForScalarNode(v13) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) @@ -5014,7 +4763,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 max_items = 14; v14 := compiler.MapValueForKey(m, "maxItems") if v14 != nil { - t, ok := v14.(int) + t, ok := compiler.IntForScalarNode(v14) if ok { x.MaxItems = int64(t) } else { @@ -5025,7 +4774,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 min_items = 15; v15 := compiler.MapValueForKey(m, "minItems") if v15 != nil { - t, ok := v15.(int) + t, ok := compiler.IntForScalarNode(v15) if ok { x.MinItems = int64(t) } else { @@ -5036,7 +4785,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool unique_items = 16; v16 := compiler.MapValueForKey(m, "uniqueItems") if v16 != nil { - x.UniqueItems, ok = v16.(bool) + x.UniqueItems, ok = compiler.BoolForScalarNode(v16) if !ok { message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v16, v16) errors = append(errors, compiler.NewError(context, message)) @@ -5045,7 +4794,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 max_properties = 17; v17 := compiler.MapValueForKey(m, "maxProperties") if v17 != nil { - t, ok := v17.(int) + t, ok := compiler.IntForScalarNode(v17) if ok { x.MaxProperties = int64(t) } else { @@ -5056,7 +4805,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 min_properties = 18; v18 := compiler.MapValueForKey(m, "minProperties") if v18 != nil { - t, ok := v18.(int) + t, ok := compiler.IntForScalarNode(v18) if ok { x.MinProperties = int64(t) } else { @@ -5067,9 +4816,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // repeated string required = 19; v19 := compiler.MapValueForKey(m, "required") if v19 != nil { - v, ok := v19.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v19) if ok { - x.Required = compiler.ConvertInterfaceArrayToStringArray(v) + x.Required = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v19, v19) errors = append(errors, compiler.NewError(context, message)) @@ -5080,9 +4829,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v20 != nil { // repeated Any x.Enum = make([]*Any, 0) - a, ok := v20.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v20) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewAny(item, compiler.NewContext("enum", context)) if err != nil { errors = append(errors, err) @@ -5123,9 +4872,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v24 != nil { // repeated Schema x.AllOf = make([]*Schema, 0) - a, ok := v24.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v24) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewSchema(item, compiler.NewContext("allOf", context)) if err != nil { errors = append(errors, err) @@ -5146,7 +4895,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string discriminator = 26; v26 := compiler.MapValueForKey(m, "discriminator") if v26 != nil { - x.Discriminator, ok = v26.(string) + x.Discriminator, ok = compiler.StringForScalarNode(v26) if !ok { message := fmt.Sprintf("has unexpected value for discriminator: %+v (%T)", v26, v26) errors = append(errors, compiler.NewError(context, message)) @@ -5155,7 +4904,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool read_only = 27; v27 := compiler.MapValueForKey(m, "readOnly") if v27 != nil { - x.ReadOnly, ok = v27.(bool) + x.ReadOnly, ok = compiler.BoolForScalarNode(v27) if !ok { message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v27, v27) errors = append(errors, compiler.NewError(context, message)) @@ -5191,10 +4940,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // repeated NamedAny vendor_extension = 31; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -5275,10 +5024,10 @@ func NewSecurityDefinitions(in interface{}, context *compiler.Context) (*Securit // repeated NamedSecurityDefinitionsItem additional_properties = 1; // MAP: SecurityDefinitionsItem x.AdditionalProperties = make([]*NamedSecurityDefinitionsItem, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedSecurityDefinitionsItem{} pair.Name = k var err error @@ -5401,10 +5150,10 @@ func NewSecurityRequirement(in interface{}, context *compiler.Context) (*Securit // repeated NamedStringArray additional_properties = 1; // MAP: StringArray x.AdditionalProperties = make([]*NamedStringArray, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedStringArray{} pair.Name = k var err error @@ -5461,7 +5210,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -5470,7 +5219,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { // string description = 2; v2 := compiler.MapValueForKey(m, "description") if v2 != nil { - x.Description, ok = v2.(string) + x.Description, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -5488,10 +5237,10 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { // repeated NamedAny vendor_extension = 4; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -5524,14 +5273,16 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { func NewTypeItem(in interface{}, context *compiler.Context) (*TypeItem, error) { errors := make([]error, 0) x := &TypeItem{} - switch in := in.(type) { - case string: + v1, _ := in.(*yaml.Node) + switch v1.Kind { + case yaml.ScalarNode: x.Value = make([]string, 0) - x.Value = append(x.Value, in) - case []interface{}: + x.Value = append(x.Value, v1.Value) + case yaml.SequenceNode: x.Value = make([]string, 0) - for _, v := range in { - value, ok := v.(string) + for _, v := range v1.Content { + value := v.Value + ok := v.Kind == yaml.ScalarNode if ok { x.Value = append(x.Value, value) } else { @@ -5558,10 +5309,10 @@ func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExten // repeated NamedAny additional_properties = 1; // MAP: Any x.AdditionalProperties = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedAny{} pair.Name = k result := &Any{} @@ -5607,7 +5358,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -5616,7 +5367,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // string namespace = 2; v2 := compiler.MapValueForKey(m, "namespace") if v2 != nil { - x.Namespace, ok = v2.(string) + x.Namespace, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for namespace: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -5625,7 +5376,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // string prefix = 3; v3 := compiler.MapValueForKey(m, "prefix") if v3 != nil { - x.Prefix, ok = v3.(string) + x.Prefix, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for prefix: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -5634,7 +5385,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // bool attribute = 4; v4 := compiler.MapValueForKey(m, "attribute") if v4 != nil { - x.Attribute, ok = v4.(bool) + x.Attribute, ok = compiler.BoolForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for attribute: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -5643,7 +5394,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // bool wrapped = 5; v5 := compiler.MapValueForKey(m, "wrapped") if v5 != nil { - x.Wrapped, ok = v5.(bool) + x.Wrapped, ok = compiler.BoolForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for wrapped: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -5652,10 +5403,10 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // repeated NamedAny vendor_extension = 6; // MAP: Any ^x- x.VendorExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -7060,7 +6811,7 @@ func (m *Xml) ResolveReferences(root string) (interface{}, error) { } // ToRawInfo returns a description of AdditionalPropertiesItem suitable for JSON or YAML export. -func (m *AdditionalPropertiesItem) ToRawInfo() interface{} { +func (m *AdditionalPropertiesItem) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // AdditionalPropertiesItem // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -7070,50 +6821,45 @@ func (m *AdditionalPropertiesItem) ToRawInfo() interface{} { } // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if v1, ok := m.GetOneof().(*AdditionalPropertiesItem_Boolean); ok { - return v1.Boolean + return compiler.NewScalarNodeForBool(v1.Boolean) } return nil } // ToRawInfo returns a description of Any suitable for JSON or YAML export. -func (m *Any) ToRawInfo() interface{} { +func (m *Any) ToRawInfo() *yaml.Node { 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) + var node yaml.Node + err = yaml.Unmarshal([]byte(m.Yaml), &node) if err == nil { - return info3 + return &node } return nil } // ToRawInfo returns a description of ApiKeySecurity suitable for JSON or YAML export. -func (m *ApiKeySecurity) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ApiKeySecurity) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) // always include this required field. - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) // always include this required field. - info = append(info, yaml.MapItem{Key: "in", Value: m.In}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7121,19 +6867,22 @@ func (m *ApiKeySecurity) ToRawInfo() interface{} { } // ToRawInfo returns a description of BasicAuthenticationSecurity suitable for JSON or YAML export. -func (m *BasicAuthenticationSecurity) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *BasicAuthenticationSecurity) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7141,27 +6890,33 @@ func (m *BasicAuthenticationSecurity) ToRawInfo() interface{} { } // ToRawInfo returns a description of BodyParameter suitable for JSON or YAML export. -func (m *BodyParameter) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *BodyParameter) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } // always include this required field. - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) // always include this required field. - info = append(info, yaml.MapItem{Key: "in", Value: m.In}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } // always include this required field. - info = append(info, yaml.MapItem{Key: "schema", Value: m.Schema.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7169,23 +6924,27 @@ func (m *BodyParameter) ToRawInfo() interface{} { } // ToRawInfo returns a description of Contact suitable for JSON or YAML export. -func (m *Contact) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Contact) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Url != "" { - info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) } if m.Email != "" { - info = append(info, yaml.MapItem{Key: "email", Value: m.Email}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("email")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Email)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7193,14 +6952,15 @@ func (m *Contact) ToRawInfo() interface{} { } // ToRawInfo returns a description of Default suitable for JSON or YAML export. -func (m *Default) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Default) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:false Description:} @@ -7208,14 +6968,15 @@ func (m *Default) ToRawInfo() interface{} { } // ToRawInfo returns a description of Definitions suitable for JSON or YAML export. -func (m *Definitions) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Definitions) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:} @@ -7223,73 +6984,89 @@ func (m *Definitions) ToRawInfo() interface{} { } // ToRawInfo returns a description of Document suitable for JSON or YAML export. -func (m *Document) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Document) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "swagger", Value: m.Swagger}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("swagger")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Swagger)) // always include this required field. - info = append(info, yaml.MapItem{Key: "info", Value: m.Info.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("info")) + info.Content = append(info.Content, m.Info.ToRawInfo()) // &{Name:info Type:Info StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Host != "" { - info = append(info, yaml.MapItem{Key: "host", Value: m.Host}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("host")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Host)) } if m.BasePath != "" { - info = append(info, yaml.MapItem{Key: "basePath", Value: m.BasePath}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("basePath")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BasePath)) } if len(m.Schemes) != 0 { - info = append(info, yaml.MapItem{Key: "schemes", Value: m.Schemes}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schemes")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Schemes)) } if len(m.Consumes) != 0 { - info = append(info, yaml.MapItem{Key: "consumes", Value: m.Consumes}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("consumes")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Consumes)) } if len(m.Produces) != 0 { - info = append(info, yaml.MapItem{Key: "produces", Value: m.Produces}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("produces")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Produces)) } // always include this required field. - info = append(info, yaml.MapItem{Key: "paths", Value: m.Paths.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("paths")) + info.Content = append(info.Content, m.Paths.ToRawInfo()) // &{Name:paths Type:Paths StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Definitions != nil { - info = append(info, yaml.MapItem{Key: "definitions", Value: m.Definitions.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("definitions")) + info.Content = append(info.Content, m.Definitions.ToRawInfo()) } // &{Name:definitions Type:Definitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Parameters != nil { - info = append(info, yaml.MapItem{Key: "parameters", Value: m.Parameters.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, m.Parameters.ToRawInfo()) } // &{Name:parameters Type:ParameterDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Responses != nil { - info = append(info, yaml.MapItem{Key: "responses", Value: m.Responses.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("responses")) + info.Content = append(info.Content, m.Responses.ToRawInfo()) } // &{Name:responses Type:ResponseDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.Security) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Security { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "security", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("security")) + info.Content = append(info.Content, items) } // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.SecurityDefinitions != nil { - info = append(info, yaml.MapItem{Key: "securityDefinitions", Value: m.SecurityDefinitions.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("securityDefinitions")) + info.Content = append(info.Content, m.SecurityDefinitions.ToRawInfo()) } // &{Name:securityDefinitions Type:SecurityDefinitions StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.Tags) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Tags { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "tags", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("tags")) + info.Content = append(info.Content, items) } // &{Name:tags Type:Tag StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7297,14 +7074,15 @@ func (m *Document) ToRawInfo() interface{} { } // ToRawInfo returns a description of Examples suitable for JSON or YAML export. -func (m *Examples) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Examples) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:} @@ -7312,19 +7090,22 @@ func (m *Examples) ToRawInfo() interface{} { } // ToRawInfo returns a description of ExternalDocs suitable for JSON or YAML export. -func (m *ExternalDocs) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ExternalDocs) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } // always include this required field. - info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7332,43 +7113,53 @@ func (m *ExternalDocs) ToRawInfo() interface{} { } // ToRawInfo returns a description of FileSchema suitable for JSON or YAML export. -func (m *FileSchema) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *FileSchema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Title != "" { - info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, 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{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Required)) } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) if m.ReadOnly != false { - info = append(info, yaml.MapItem{Key: "readOnly", Value: m.ReadOnly}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("readOnly")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ReadOnly)) } if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) } // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Example != nil { - info = append(info, yaml.MapItem{Key: "example", Value: m.Example.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7376,87 +7167,110 @@ func (m *FileSchema) ToRawInfo() interface{} { } // ToRawInfo returns a description of FormDataParameterSubSchema suitable for JSON or YAML export. -func (m *FormDataParameterSubSchema) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *FormDataParameterSubSchema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } if m.In != "" { - info = append(info, yaml.MapItem{Key: "in", Value: m.In}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.AllowEmptyValue != false { - info = append(info, yaml.MapItem{Key: "allowEmptyValue", Value: m.AllowEmptyValue}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowEmptyValue")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowEmptyValue)) } if m.Type != "" { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Items != nil { - info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, m.Items.ToRawInfo()) } // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.CollectionFormat != "" { - info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("collectionFormat")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.CollectionFormat)) } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, 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{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } if m.ExclusiveMaximum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } if m.Minimum != 0.0 { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } if m.ExclusiveMinimum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } if m.MaxLength != 0 { - info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) } if m.MinLength != 0 { - info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.MaxItems != 0 { - info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) } if m.MinItems != 0 { - info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } if m.UniqueItems != false { - info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } if len(m.Enum) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Enum { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "enum", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) } // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.MultipleOf != 0.0 { - info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7464,74 +7278,93 @@ func (m *FormDataParameterSubSchema) ToRawInfo() interface{} { } // ToRawInfo returns a description of Header suitable for JSON or YAML export. -func (m *Header) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Header) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Items != nil { - info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, m.Items.ToRawInfo()) } // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.CollectionFormat != "" { - info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("collectionFormat")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.CollectionFormat)) } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, 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{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } if m.ExclusiveMaximum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } if m.Minimum != 0.0 { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } if m.ExclusiveMinimum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } if m.MaxLength != 0 { - info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) } if m.MinLength != 0 { - info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.MaxItems != 0 { - info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) } if m.MinItems != 0 { - info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } if m.UniqueItems != false { - info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } if len(m.Enum) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Enum { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "enum", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) } // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.MultipleOf != 0.0 { - info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7539,84 +7372,106 @@ func (m *Header) ToRawInfo() interface{} { } // ToRawInfo returns a description of HeaderParameterSubSchema suitable for JSON or YAML export. -func (m *HeaderParameterSubSchema) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *HeaderParameterSubSchema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } if m.In != "" { - info = append(info, yaml.MapItem{Key: "in", Value: m.In}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Type != "" { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Items != nil { - info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, m.Items.ToRawInfo()) } // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.CollectionFormat != "" { - info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("collectionFormat")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.CollectionFormat)) } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, 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{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } if m.ExclusiveMaximum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } if m.Minimum != 0.0 { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } if m.ExclusiveMinimum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } if m.MaxLength != 0 { - info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) } if m.MinLength != 0 { - info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.MaxItems != 0 { - info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) } if m.MinItems != 0 { - info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } if m.UniqueItems != false { - info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } if len(m.Enum) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Enum { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "enum", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) } // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.MultipleOf != 0.0 { - info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7624,14 +7479,15 @@ func (m *HeaderParameterSubSchema) ToRawInfo() interface{} { } // ToRawInfo returns a description of Headers suitable for JSON or YAML export. -func (m *Headers) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Headers) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedHeader StringEnumValues:[] MapType:Header Repeated:true Pattern: Implicit:true Description:} @@ -7639,32 +7495,39 @@ func (m *Headers) ToRawInfo() interface{} { } // ToRawInfo returns a description of Info suitable for JSON or YAML export. -func (m *Info) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Info) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) // always include this required field. - info = append(info, yaml.MapItem{Key: "version", Value: m.Version}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("version")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Version)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.TermsOfService != "" { - info = append(info, yaml.MapItem{Key: "termsOfService", Value: m.TermsOfService}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("termsOfService")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.TermsOfService)) } if m.Contact != nil { - info = append(info, yaml.MapItem{Key: "contact", Value: m.Contact.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("contact")) + info.Content = append(info.Content, m.Contact.ToRawInfo()) } // &{Name:contact Type:Contact StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.License != nil { - info = append(info, yaml.MapItem{Key: "license", Value: m.License.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("license")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7672,50 +7535,56 @@ func (m *Info) ToRawInfo() interface{} { } // ToRawInfo returns a description of ItemsItem suitable for JSON or YAML export. -func (m *ItemsItem) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ItemsItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if len(m.Schema) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Schema { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "schema", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, 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{} +func (m *JsonReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } return info } // ToRawInfo returns a description of License suitable for JSON or YAML export. -func (m *License) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *License) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) if m.Url != "" { - info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7723,139 +7592,150 @@ func (m *License) ToRawInfo() interface{} { } // ToRawInfo returns a description of NamedAny suitable for JSON or YAML export. -func (m *NamedAny) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedAny) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} +func (m *NamedHeader) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} +func (m *NamedParameter) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} +func (m *NamedPathItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} +func (m *NamedResponse) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} +func (m *NamedResponseValue) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} +func (m *NamedSchema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} +func (m *NamedSecurityDefinitionsItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} +func (m *NamedString) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Value != "" { - info = append(info, yaml.MapItem{Key: "value", Value: m.Value}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("value")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Value)) } return info } // ToRawInfo returns a description of NamedStringArray suitable for JSON or YAML export. -func (m *NamedStringArray) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedStringArray) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(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{} { +func (m *NonBodyParameter) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // NonBodyParameter // {Name:headerParameterSubSchema Type:HeaderParameterSubSchema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -7882,29 +7762,36 @@ func (m *NonBodyParameter) ToRawInfo() interface{} { } // ToRawInfo returns a description of Oauth2AccessCodeSecurity suitable for JSON or YAML export. -func (m *Oauth2AccessCodeSecurity) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Oauth2AccessCodeSecurity) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) // always include this required field. - info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("flow")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Flow)) if m.Scopes != nil { - info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) + info.Content = append(info.Content, m.Scopes.ToRawInfo()) } // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} // always include this required field. - info = append(info, yaml.MapItem{Key: "authorizationUrl", Value: m.AuthorizationUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("authorizationUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.AuthorizationUrl)) // always include this required field. - info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("tokenUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.TokenUrl)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7912,27 +7799,33 @@ func (m *Oauth2AccessCodeSecurity) ToRawInfo() interface{} { } // ToRawInfo returns a description of Oauth2ApplicationSecurity suitable for JSON or YAML export. -func (m *Oauth2ApplicationSecurity) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Oauth2ApplicationSecurity) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) // always include this required field. - info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("flow")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Flow)) if m.Scopes != nil { - info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) + info.Content = append(info.Content, m.Scopes.ToRawInfo()) } // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} // always include this required field. - info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("tokenUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.TokenUrl)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7940,27 +7833,33 @@ func (m *Oauth2ApplicationSecurity) ToRawInfo() interface{} { } // ToRawInfo returns a description of Oauth2ImplicitSecurity suitable for JSON or YAML export. -func (m *Oauth2ImplicitSecurity) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Oauth2ImplicitSecurity) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) // always include this required field. - info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("flow")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Flow)) if m.Scopes != nil { - info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) + info.Content = append(info.Content, m.Scopes.ToRawInfo()) } // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} // always include this required field. - info = append(info, yaml.MapItem{Key: "authorizationUrl", Value: m.AuthorizationUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("authorizationUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.AuthorizationUrl)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7968,27 +7867,33 @@ func (m *Oauth2ImplicitSecurity) ToRawInfo() interface{} { } // ToRawInfo returns a description of Oauth2PasswordSecurity suitable for JSON or YAML export. -func (m *Oauth2PasswordSecurity) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Oauth2PasswordSecurity) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) // always include this required field. - info = append(info, yaml.MapItem{Key: "flow", Value: m.Flow}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("flow")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Flow)) if m.Scopes != nil { - info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) + info.Content = append(info.Content, m.Scopes.ToRawInfo()) } // &{Name:scopes Type:Oauth2Scopes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} // always include this required field. - info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("tokenUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.TokenUrl)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7996,8 +7901,8 @@ func (m *Oauth2PasswordSecurity) ToRawInfo() interface{} { } // ToRawInfo returns a description of Oauth2Scopes suitable for JSON or YAML export. -func (m *Oauth2Scopes) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Oauth2Scopes) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } @@ -8006,61 +7911,74 @@ func (m *Oauth2Scopes) ToRawInfo() interface{} { } // ToRawInfo returns a description of Operation suitable for JSON or YAML export. -func (m *Operation) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Operation) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if len(m.Tags) != 0 { - info = append(info, yaml.MapItem{Key: "tags", Value: m.Tags}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("tags")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Tags)) } if m.Summary != "" { - info = append(info, yaml.MapItem{Key: "summary", Value: m.Summary}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) } // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.OperationId != "" { - info = append(info, yaml.MapItem{Key: "operationId", Value: m.OperationId}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("operationId")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OperationId)) } if len(m.Produces) != 0 { - info = append(info, yaml.MapItem{Key: "produces", Value: m.Produces}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("produces")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Produces)) } if len(m.Consumes) != 0 { - info = append(info, yaml.MapItem{Key: "consumes", Value: m.Consumes}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("consumes")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Consumes)) } if len(m.Parameters) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Parameters { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "parameters", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, items) } // &{Name:parameters Type:ParametersItem StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:The parameters needed to send a valid API call.} // always include this required field. - info = append(info, yaml.MapItem{Key: "responses", Value: m.Responses.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("responses")) + info.Content = append(info.Content, 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{Key: "schemes", Value: m.Schemes}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schemes")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Schemes)) } if m.Deprecated != false { - info = append(info, yaml.MapItem{Key: "deprecated", Value: m.Deprecated}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } if len(m.Security) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Security { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "security", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("security")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8068,7 +7986,7 @@ func (m *Operation) ToRawInfo() interface{} { } // ToRawInfo returns a description of Parameter suitable for JSON or YAML export. -func (m *Parameter) ToRawInfo() interface{} { +func (m *Parameter) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // Parameter // {Name:bodyParameter Type:BodyParameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -8085,14 +8003,15 @@ func (m *Parameter) ToRawInfo() interface{} { } // ToRawInfo returns a description of ParameterDefinitions suitable for JSON or YAML export. -func (m *ParameterDefinitions) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ParameterDefinitions) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedParameter StringEnumValues:[] MapType:Parameter Repeated:true Pattern: Implicit:true Description:} @@ -8100,7 +8019,7 @@ func (m *ParameterDefinitions) ToRawInfo() interface{} { } // ToRawInfo returns a description of ParametersItem suitable for JSON or YAML export. -func (m *ParametersItem) ToRawInfo() interface{} { +func (m *ParametersItem) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // ParametersItem // {Name:parameter Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -8117,53 +8036,63 @@ func (m *ParametersItem) ToRawInfo() interface{} { } // ToRawInfo returns a description of PathItem suitable for JSON or YAML export. -func (m *PathItem) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *PathItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.XRef != "" { - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) } if m.Get != nil { - info = append(info, yaml.MapItem{Key: "get", Value: m.Get.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("get")) + info.Content = append(info.Content, m.Get.ToRawInfo()) } // &{Name:get Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Put != nil { - info = append(info, yaml.MapItem{Key: "put", Value: m.Put.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("put")) + info.Content = append(info.Content, m.Put.ToRawInfo()) } // &{Name:put Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Post != nil { - info = append(info, yaml.MapItem{Key: "post", Value: m.Post.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("post")) + info.Content = append(info.Content, m.Post.ToRawInfo()) } // &{Name:post Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Delete != nil { - info = append(info, yaml.MapItem{Key: "delete", Value: m.Delete.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("delete")) + info.Content = append(info.Content, m.Delete.ToRawInfo()) } // &{Name:delete Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Options != nil { - info = append(info, yaml.MapItem{Key: "options", Value: m.Options.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("options")) + info.Content = append(info.Content, m.Options.ToRawInfo()) } // &{Name:options Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Head != nil { - info = append(info, yaml.MapItem{Key: "head", Value: m.Head.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("head")) + info.Content = append(info.Content, m.Head.ToRawInfo()) } // &{Name:head Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Patch != nil { - info = append(info, yaml.MapItem{Key: "patch", Value: m.Patch.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("patch")) + info.Content = append(info.Content, m.Patch.ToRawInfo()) } // &{Name:patch Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.Parameters) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Parameters { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "parameters", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8171,83 +8100,105 @@ func (m *PathItem) ToRawInfo() interface{} { } // ToRawInfo returns a description of PathParameterSubSchema suitable for JSON or YAML export. -func (m *PathParameterSubSchema) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *PathParameterSubSchema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) if m.In != "" { - info = append(info, yaml.MapItem{Key: "in", Value: m.In}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Type != "" { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Items != nil { - info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, m.Items.ToRawInfo()) } // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.CollectionFormat != "" { - info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("collectionFormat")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.CollectionFormat)) } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, 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{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } if m.ExclusiveMaximum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } if m.Minimum != 0.0 { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } if m.ExclusiveMinimum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } if m.MaxLength != 0 { - info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) } if m.MinLength != 0 { - info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.MaxItems != 0 { - info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) } if m.MinItems != 0 { - info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } if m.UniqueItems != false { - info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } if len(m.Enum) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Enum { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "enum", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) } // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.MultipleOf != 0.0 { - info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8255,20 +8206,22 @@ func (m *PathParameterSubSchema) ToRawInfo() interface{} { } // ToRawInfo returns a description of Paths suitable for JSON or YAML export. -func (m *Paths) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Paths) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:Path Type:NamedPathItem StringEnumValues:[] MapType:PathItem Repeated:true Pattern:^/ Implicit:true Description:} @@ -8276,72 +8229,90 @@ func (m *Paths) ToRawInfo() interface{} { } // ToRawInfo returns a description of PrimitivesItems suitable for JSON or YAML export. -func (m *PrimitivesItems) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *PrimitivesItems) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Type != "" { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Items != nil { - info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, m.Items.ToRawInfo()) } // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.CollectionFormat != "" { - info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("collectionFormat")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.CollectionFormat)) } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, 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{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } if m.ExclusiveMaximum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } if m.Minimum != 0.0 { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } if m.ExclusiveMinimum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } if m.MaxLength != 0 { - info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) } if m.MinLength != 0 { - info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.MaxItems != 0 { - info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) } if m.MinItems != 0 { - info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } if m.UniqueItems != false { - info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } if len(m.Enum) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Enum { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "enum", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) } // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.MultipleOf != 0.0 { - info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8349,14 +8320,15 @@ func (m *PrimitivesItems) ToRawInfo() interface{} { } // ToRawInfo returns a description of Properties suitable for JSON or YAML export. -func (m *Properties) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Properties) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedSchema StringEnumValues:[] MapType:Schema Repeated:true Pattern: Implicit:true Description:} @@ -8364,87 +8336,110 @@ func (m *Properties) ToRawInfo() interface{} { } // ToRawInfo returns a description of QueryParameterSubSchema suitable for JSON or YAML export. -func (m *QueryParameterSubSchema) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *QueryParameterSubSchema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } if m.In != "" { - info = append(info, yaml.MapItem{Key: "in", Value: m.In}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.AllowEmptyValue != false { - info = append(info, yaml.MapItem{Key: "allowEmptyValue", Value: m.AllowEmptyValue}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowEmptyValue")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowEmptyValue)) } if m.Type != "" { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Items != nil { - info = append(info, yaml.MapItem{Key: "items", Value: m.Items.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, m.Items.ToRawInfo()) } // &{Name:items Type:PrimitivesItems StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.CollectionFormat != "" { - info = append(info, yaml.MapItem{Key: "collectionFormat", Value: m.CollectionFormat}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("collectionFormat")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.CollectionFormat)) } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, 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{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } if m.ExclusiveMaximum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } if m.Minimum != 0.0 { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } if m.ExclusiveMinimum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } if m.MaxLength != 0 { - info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) } if m.MinLength != 0 { - info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.MaxItems != 0 { - info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) } if m.MinItems != 0 { - info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } if m.UniqueItems != false { - info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } if len(m.Enum) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Enum { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "enum", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) } // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.MultipleOf != 0.0 { - info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8452,28 +8447,33 @@ func (m *QueryParameterSubSchema) ToRawInfo() interface{} { } // ToRawInfo returns a description of Response suitable for JSON or YAML export. -func (m *Response) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Response) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) if m.Schema != nil { - info = append(info, yaml.MapItem{Key: "schema", Value: m.Schema.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, m.Schema.ToRawInfo()) } // &{Name:schema Type:SchemaItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Headers != nil { - info = append(info, yaml.MapItem{Key: "headers", Value: m.Headers.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("headers")) + info.Content = append(info.Content, m.Headers.ToRawInfo()) } // &{Name:headers Type:Headers StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Examples != nil { - info = append(info, yaml.MapItem{Key: "examples", Value: m.Examples.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8481,14 +8481,15 @@ func (m *Response) ToRawInfo() interface{} { } // ToRawInfo returns a description of ResponseDefinitions suitable for JSON or YAML export. -func (m *ResponseDefinitions) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ResponseDefinitions) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedResponse StringEnumValues:[] MapType:Response Repeated:true Pattern: Implicit:true Description:} @@ -8496,7 +8497,7 @@ func (m *ResponseDefinitions) ToRawInfo() interface{} { } // ToRawInfo returns a description of ResponseValue suitable for JSON or YAML export. -func (m *ResponseValue) ToRawInfo() interface{} { +func (m *ResponseValue) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // ResponseValue // {Name:response Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -8513,20 +8514,22 @@ func (m *ResponseValue) ToRawInfo() interface{} { } // ToRawInfo returns a description of Responses suitable for JSON or YAML export. -func (m *Responses) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Responses) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.ResponseCode != nil { for _, item := range m.ResponseCode { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8534,130 +8537,162 @@ func (m *Responses) ToRawInfo() interface{} { } // ToRawInfo returns a description of Schema suitable for JSON or YAML export. -func (m *Schema) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Schema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.XRef != "" { - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.Title != "" { - info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, 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{Key: "multipleOf", Value: m.MultipleOf}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) } if m.Maximum != 0.0 { - info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } if m.ExclusiveMaximum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } if m.Minimum != 0.0 { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } if m.ExclusiveMinimum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } if m.MaxLength != 0 { - info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) } if m.MinLength != 0 { - info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.MaxItems != 0 { - info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) } if m.MinItems != 0 { - info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } if m.UniqueItems != false { - info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } if m.MaxProperties != 0 { - info = append(info, yaml.MapItem{Key: "maxProperties", Value: m.MaxProperties}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxProperties")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxProperties)) } if m.MinProperties != 0 { - info = append(info, yaml.MapItem{Key: "minProperties", Value: m.MinProperties}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minProperties")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinProperties)) } if len(m.Required) != 0 { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Required)) } if len(m.Enum) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Enum { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "enum", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) } // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.AdditionalProperties != nil { - info = append(info, yaml.MapItem{Key: "additionalProperties", Value: m.AdditionalProperties.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("additionalProperties")) + info.Content = append(info.Content, 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{Key: "type", Value: m.Type.Value[0]}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type.Value[0])) } else { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type.Value}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Type.Value)) } } // &{Name:type Type:TypeItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Items != nil { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Items.Schema { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "items", Value: items[0]}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, items) } // &{Name:items Type:ItemsItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.AllOf) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.AllOf { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "allOf", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allOf")) + info.Content = append(info.Content, items) } // &{Name:allOf Type:Schema StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.Properties != nil { - info = append(info, yaml.MapItem{Key: "properties", Value: m.Properties.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("properties")) + info.Content = append(info.Content, m.Properties.ToRawInfo()) } // &{Name:properties Type:Properties StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Discriminator != "" { - info = append(info, yaml.MapItem{Key: "discriminator", Value: m.Discriminator}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("discriminator")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Discriminator)) } if m.ReadOnly != false { - info = append(info, yaml.MapItem{Key: "readOnly", Value: m.ReadOnly}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("readOnly")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ReadOnly)) } if m.Xml != nil { - info = append(info, yaml.MapItem{Key: "xml", Value: m.Xml.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("xml")) + info.Content = append(info.Content, m.Xml.ToRawInfo()) } // &{Name:xml Type:Xml StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) } // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Example != nil { - info = append(info, yaml.MapItem{Key: "example", Value: m.Example.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8665,7 +8700,7 @@ func (m *Schema) ToRawInfo() interface{} { } // ToRawInfo returns a description of SchemaItem suitable for JSON or YAML export. -func (m *SchemaItem) ToRawInfo() interface{} { +func (m *SchemaItem) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // SchemaItem // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -8682,14 +8717,15 @@ func (m *SchemaItem) ToRawInfo() interface{} { } // ToRawInfo returns a description of SecurityDefinitions suitable for JSON or YAML export. -func (m *SecurityDefinitions) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *SecurityDefinitions) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedSecurityDefinitionsItem StringEnumValues:[] MapType:SecurityDefinitionsItem Repeated:true Pattern: Implicit:true Description:} @@ -8697,7 +8733,7 @@ func (m *SecurityDefinitions) ToRawInfo() interface{} { } // ToRawInfo returns a description of SecurityDefinitionsItem suitable for JSON or YAML export. -func (m *SecurityDefinitionsItem) ToRawInfo() interface{} { +func (m *SecurityDefinitionsItem) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // SecurityDefinitionsItem // {Name:basicAuthenticationSecurity Type:BasicAuthenticationSecurity StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -8734,14 +8770,15 @@ func (m *SecurityDefinitionsItem) ToRawInfo() interface{} { } // ToRawInfo returns a description of SecurityRequirement suitable for JSON or YAML export. -func (m *SecurityRequirement) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *SecurityRequirement) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedStringArray StringEnumValues:[] MapType:StringArray Repeated:true Pattern: Implicit:true Description:} @@ -8749,28 +8786,32 @@ func (m *SecurityRequirement) ToRawInfo() interface{} { } // ToRawInfo returns a description of StringArray suitable for JSON or YAML export. -func (m *StringArray) ToRawInfo() interface{} { - return m.Value +func (m *StringArray) ToRawInfo() *yaml.Node { + return compiler.NewSequenceNodeForStringArray(m.Value) } // ToRawInfo returns a description of Tag suitable for JSON or YAML export. -func (m *Tag) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Tag) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, 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{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8778,26 +8819,28 @@ func (m *Tag) ToRawInfo() interface{} { } // ToRawInfo returns a description of TypeItem suitable for JSON or YAML export. -func (m *TypeItem) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *TypeItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if len(m.Value) != 0 { - info = append(info, yaml.MapItem{Key: "value", Value: m.Value}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("value")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Value)) } return info } // ToRawInfo returns a description of VendorExtension suitable for JSON or YAML export. -func (m *VendorExtension) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *VendorExtension) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:} @@ -8805,29 +8848,35 @@ func (m *VendorExtension) ToRawInfo() interface{} { } // ToRawInfo returns a description of Xml suitable for JSON or YAML export. -func (m *Xml) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Xml) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Namespace != "" { - info = append(info, yaml.MapItem{Key: "namespace", Value: m.Namespace}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("namespace")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Namespace)) } if m.Prefix != "" { - info = append(info, yaml.MapItem{Key: "prefix", Value: m.Prefix}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("prefix")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Prefix)) } if m.Attribute != false { - info = append(info, yaml.MapItem{Key: "attribute", Value: m.Attribute}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("attribute")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Attribute)) } if m.Wrapped != false { - info = append(info, yaml.MapItem{Key: "wrapped", Value: m.Wrapped}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("wrapped")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Wrapped)) } if m.VendorExtension != nil { for _, item := range m.VendorExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:VendorExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} diff --git a/openapiv2/OpenAPIv2.pb.go b/openapiv2/OpenAPIv2.pb.go index 178bf4d4..a9e551e2 100644 --- a/openapiv2/OpenAPIv2.pb.go +++ b/openapiv2/OpenAPIv2.pb.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/openapiv2/OpenAPIv2.proto b/openapiv2/OpenAPIv2.proto index 2e75f409..00ac1b0a 100644 --- a/openapiv2/OpenAPIv2.proto +++ b/openapiv2/OpenAPIv2.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/openapiv3/OpenAPIv3.go b/openapiv3/OpenAPIv3.go index fa699e94..c7211131 100644 --- a/openapiv3/OpenAPIv3.go +++ b/openapiv3/OpenAPIv3.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package openapi_v3 import ( "fmt" "github.com/googleapis/gnostic/compiler" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" "regexp" "strings" ) @@ -129,10 +129,10 @@ func NewCallback(in interface{}, context *compiler.Context) (*Callback, error) { // repeated NamedPathItem path = 1; // MAP: PathItem ^ x.Path = make([]*NamedPathItem, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if true { pair := &NamedPathItem{} pair.Name = k @@ -148,10 +148,10 @@ func NewCallback(in interface{}, context *compiler.Context) (*Callback, error) { // repeated NamedAny specification_extension = 2; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -232,10 +232,10 @@ func NewCallbacksOrReferences(in interface{}, context *compiler.Context) (*Callb // repeated NamedCallbackOrReference additional_properties = 1; // MAP: CallbackOrReference x.AdditionalProperties = make([]*NamedCallbackOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedCallbackOrReference{} pair.Name = k var err error @@ -350,10 +350,10 @@ func NewComponents(in interface{}, context *compiler.Context) (*Components, erro // repeated NamedAny specification_extension = 10; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -401,7 +401,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -410,7 +410,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // string url = 2; v2 := compiler.MapValueForKey(m, "url") if v2 != nil { - x.Url, ok = v2.(string) + x.Url, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -419,7 +419,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // string email = 3; v3 := compiler.MapValueForKey(m, "email") if v3 != nil { - x.Email, ok = v3.(string) + x.Email, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for email: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -428,10 +428,10 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { // repeated NamedAny specification_extension = 4; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -520,7 +520,7 @@ func NewDiscriminator(in interface{}, context *compiler.Context) (*Discriminator // string property_name = 1; v1 := compiler.MapValueForKey(m, "propertyName") if v1 != nil { - x.PropertyName, ok = v1.(string) + x.PropertyName, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for propertyName: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -538,10 +538,10 @@ func NewDiscriminator(in interface{}, context *compiler.Context) (*Discriminator // repeated NamedAny specification_extension = 3; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -595,7 +595,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // string openapi = 1; v1 := compiler.MapValueForKey(m, "openapi") if v1 != nil { - x.Openapi, ok = v1.(string) + x.Openapi, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for openapi: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -615,9 +615,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v3 != nil { // repeated Server x.Servers = make([]*Server, 0) - a, ok := v3.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v3) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewServer(item, compiler.NewContext("servers", context)) if err != nil { errors = append(errors, err) @@ -649,9 +649,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v6 != nil { // repeated SecurityRequirement x.Security = make([]*SecurityRequirement, 0) - a, ok := v6.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v6) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) if err != nil { errors = append(errors, err) @@ -665,9 +665,9 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v7 != nil { // repeated Tag x.Tags = make([]*Tag, 0) - a, ok := v7.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v7) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewTag(item, compiler.NewContext("tags", context)) if err != nil { errors = append(errors, err) @@ -688,10 +688,10 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { // repeated NamedAny specification_extension = 9; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -739,7 +739,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { // string content_type = 1; v1 := compiler.MapValueForKey(m, "contentType") if v1 != nil { - x.ContentType, ok = v1.(string) + x.ContentType, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for contentType: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -757,7 +757,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { // string style = 3; v3 := compiler.MapValueForKey(m, "style") if v3 != nil { - x.Style, ok = v3.(string) + x.Style, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -766,7 +766,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { // bool explode = 4; v4 := compiler.MapValueForKey(m, "explode") if v4 != nil { - x.Explode, ok = v4.(bool) + x.Explode, ok = compiler.BoolForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -775,7 +775,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { // bool allow_reserved = 5; v5 := compiler.MapValueForKey(m, "allowReserved") if v5 != nil { - x.AllowReserved, ok = v5.(bool) + x.AllowReserved, ok = compiler.BoolForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for allowReserved: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -784,10 +784,10 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { // repeated NamedAny specification_extension = 6; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -828,10 +828,10 @@ func NewEncodings(in interface{}, context *compiler.Context) (*Encodings, error) // repeated NamedEncoding additional_properties = 1; // MAP: Encoding x.AdditionalProperties = make([]*NamedEncoding, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedEncoding{} pair.Name = k var err error @@ -865,7 +865,7 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { // string summary = 1; v1 := compiler.MapValueForKey(m, "summary") if v1 != nil { - x.Summary, ok = v1.(string) + x.Summary, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -874,7 +874,7 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { // string description = 2; v2 := compiler.MapValueForKey(m, "description") if v2 != nil { - x.Description, ok = v2.(string) + x.Description, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -892,7 +892,7 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { // string external_value = 4; v4 := compiler.MapValueForKey(m, "externalValue") if v4 != nil { - x.ExternalValue, ok = v4.(string) + x.ExternalValue, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for externalValue: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -901,10 +901,10 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { // repeated NamedAny specification_extension = 5; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -985,10 +985,10 @@ func NewExamplesOrReferences(in interface{}, context *compiler.Context) (*Exampl // repeated NamedExampleOrReference additional_properties = 1; // MAP: ExampleOrReference x.AdditionalProperties = make([]*NamedExampleOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedExampleOrReference{} pair.Name = k var err error @@ -1015,10 +1015,10 @@ func NewExpression(in interface{}, context *compiler.Context) (*Expression, erro // repeated NamedAny additional_properties = 1; // MAP: Any x.AdditionalProperties = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedAny{} pair.Name = k result := &Any{} @@ -1070,7 +1070,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, // string description = 1; v1 := compiler.MapValueForKey(m, "description") if v1 != nil { - x.Description, ok = v1.(string) + x.Description, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1079,7 +1079,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, // string url = 2; v2 := compiler.MapValueForKey(m, "url") if v2 != nil { - x.Url, ok = v2.(string) + x.Url, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1088,10 +1088,10 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, // repeated NamedAny specification_extension = 3; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1139,7 +1139,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // string description = 1; v1 := compiler.MapValueForKey(m, "description") if v1 != nil { - x.Description, ok = v1.(string) + x.Description, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1148,7 +1148,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // bool required = 2; v2 := compiler.MapValueForKey(m, "required") if v2 != nil { - x.Required, ok = v2.(bool) + x.Required, ok = compiler.BoolForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1157,7 +1157,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // bool deprecated = 3; v3 := compiler.MapValueForKey(m, "deprecated") if v3 != nil { - x.Deprecated, ok = v3.(bool) + x.Deprecated, ok = compiler.BoolForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -1166,7 +1166,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // bool allow_empty_value = 4; v4 := compiler.MapValueForKey(m, "allowEmptyValue") if v4 != nil { - x.AllowEmptyValue, ok = v4.(bool) + x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -1175,7 +1175,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // string style = 5; v5 := compiler.MapValueForKey(m, "style") if v5 != nil { - x.Style, ok = v5.(string) + x.Style, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -1184,7 +1184,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // bool explode = 6; v6 := compiler.MapValueForKey(m, "explode") if v6 != nil { - x.Explode, ok = v6.(bool) + x.Explode, ok = compiler.BoolForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -1193,7 +1193,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // bool allow_reserved = 7; v7 := compiler.MapValueForKey(m, "allowReserved") if v7 != nil { - x.AllowReserved, ok = v7.(bool) + x.AllowReserved, ok = compiler.BoolForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for allowReserved: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -1238,10 +1238,10 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { // repeated NamedAny specification_extension = 12; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1322,10 +1322,10 @@ func NewHeadersOrReferences(in interface{}, context *compiler.Context) (*Headers // repeated NamedHeaderOrReference additional_properties = 1; // MAP: HeaderOrReference x.AdditionalProperties = make([]*NamedHeaderOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedHeaderOrReference{} pair.Name = k var err error @@ -1365,7 +1365,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string title = 1; v1 := compiler.MapValueForKey(m, "title") if v1 != nil { - x.Title, ok = v1.(string) + x.Title, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1374,7 +1374,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string description = 2; v2 := compiler.MapValueForKey(m, "description") if v2 != nil { - x.Description, ok = v2.(string) + x.Description, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1383,7 +1383,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string terms_of_service = 3; v3 := compiler.MapValueForKey(m, "termsOfService") if v3 != nil { - x.TermsOfService, ok = v3.(string) + x.TermsOfService, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for termsOfService: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -1410,7 +1410,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string version = 6; v6 := compiler.MapValueForKey(m, "version") if v6 != nil { - x.Version, ok = v6.(string) + x.Version, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -1419,7 +1419,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // string summary = 7; v7 := compiler.MapValueForKey(m, "summary") if v7 != nil { - x.Summary, ok = v7.(string) + x.Summary, ok = compiler.StringForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -1428,10 +1428,10 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { // repeated NamedAny specification_extension = 8; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1504,7 +1504,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1513,7 +1513,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { // string url = 2; v2 := compiler.MapValueForKey(m, "url") if v2 != nil { - x.Url, ok = v2.(string) + x.Url, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1522,10 +1522,10 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { // repeated NamedAny specification_extension = 3; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1573,7 +1573,7 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { // string operation_ref = 1; v1 := compiler.MapValueForKey(m, "operationRef") if v1 != nil { - x.OperationRef, ok = v1.(string) + x.OperationRef, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for operationRef: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1582,7 +1582,7 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { // string operation_id = 2; v2 := compiler.MapValueForKey(m, "operationId") if v2 != nil { - x.OperationId, ok = v2.(string) + x.OperationId, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -1609,7 +1609,7 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { // string description = 5; v5 := compiler.MapValueForKey(m, "description") if v5 != nil { - x.Description, ok = v5.(string) + x.Description, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -1627,10 +1627,10 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { // repeated NamedAny specification_extension = 7; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1711,10 +1711,10 @@ func NewLinksOrReferences(in interface{}, context *compiler.Context) (*LinksOrRe // repeated NamedLinkOrReference additional_properties = 1; // MAP: LinkOrReference x.AdditionalProperties = make([]*NamedLinkOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedLinkOrReference{} pair.Name = k var err error @@ -1784,10 +1784,10 @@ func NewMediaType(in interface{}, context *compiler.Context) (*MediaType, error) // repeated NamedAny specification_extension = 5; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -1828,10 +1828,10 @@ func NewMediaTypes(in interface{}, context *compiler.Context) (*MediaTypes, erro // repeated NamedMediaType additional_properties = 1; // MAP: MediaType x.AdditionalProperties = make([]*NamedMediaType, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedMediaType{} pair.Name = k var err error @@ -1865,7 +1865,7 @@ func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1903,7 +1903,7 @@ func NewNamedCallbackOrReference(in interface{}, context *compiler.Context) (*Na // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1941,7 +1941,7 @@ func NewNamedEncoding(in interface{}, context *compiler.Context) (*NamedEncoding // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -1979,7 +1979,7 @@ func NewNamedExampleOrReference(in interface{}, context *compiler.Context) (*Nam // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2017,7 +2017,7 @@ func NewNamedHeaderOrReference(in interface{}, context *compiler.Context) (*Name // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2055,7 +2055,7 @@ func NewNamedLinkOrReference(in interface{}, context *compiler.Context) (*NamedL // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2093,7 +2093,7 @@ func NewNamedMediaType(in interface{}, context *compiler.Context) (*NamedMediaTy // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2131,7 +2131,7 @@ func NewNamedParameterOrReference(in interface{}, context *compiler.Context) (*N // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2169,7 +2169,7 @@ func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2207,7 +2207,7 @@ func NewNamedRequestBodyOrReference(in interface{}, context *compiler.Context) ( // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2245,7 +2245,7 @@ func NewNamedResponseOrReference(in interface{}, context *compiler.Context) (*Na // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2283,7 +2283,7 @@ func NewNamedSchemaOrReference(in interface{}, context *compiler.Context) (*Name // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2321,7 +2321,7 @@ func NewNamedSecuritySchemeOrReference(in interface{}, context *compiler.Context // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2359,7 +2359,7 @@ func NewNamedServerVariable(in interface{}, context *compiler.Context) (*NamedSe // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2397,7 +2397,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2406,7 +2406,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er // string value = 2; v2 := compiler.MapValueForKey(m, "value") if v2 != nil { - x.Value, ok = v2.(string) + x.Value, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for value: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2435,7 +2435,7 @@ func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStrin // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2473,7 +2473,7 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) // string authorization_url = 1; v1 := compiler.MapValueForKey(m, "authorizationUrl") if v1 != nil { - x.AuthorizationUrl, ok = v1.(string) + x.AuthorizationUrl, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2482,7 +2482,7 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) // string token_url = 2; v2 := compiler.MapValueForKey(m, "tokenUrl") if v2 != nil { - x.TokenUrl, ok = v2.(string) + x.TokenUrl, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2491,7 +2491,7 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) // string refresh_url = 3; v3 := compiler.MapValueForKey(m, "refreshUrl") if v3 != nil { - x.RefreshUrl, ok = v3.(string) + x.RefreshUrl, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for refreshUrl: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -2509,10 +2509,10 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) // repeated NamedAny specification_extension = 5; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -2596,10 +2596,10 @@ func NewOauthFlows(in interface{}, context *compiler.Context) (*OauthFlows, erro // repeated NamedAny specification_extension = 5; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -2640,10 +2640,10 @@ func NewObject(in interface{}, context *compiler.Context) (*Object, error) { // repeated NamedAny additional_properties = 1; // MAP: Any x.AdditionalProperties = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedAny{} pair.Name = k result := &Any{} @@ -2695,9 +2695,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // repeated string tags = 1; v1 := compiler.MapValueForKey(m, "tags") if v1 != nil { - v, ok := v1.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v1) if ok { - x.Tags = compiler.ConvertInterfaceArrayToStringArray(v) + x.Tags = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for tags: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2706,7 +2706,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // string summary = 2; v2 := compiler.MapValueForKey(m, "summary") if v2 != nil { - x.Summary, ok = v2.(string) + x.Summary, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2715,7 +2715,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -2733,7 +2733,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // string operation_id = 5; v5 := compiler.MapValueForKey(m, "operationId") if v5 != nil { - x.OperationId, ok = v5.(string) + x.OperationId, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -2744,9 +2744,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v6 != nil { // repeated ParameterOrReference x.Parameters = make([]*ParameterOrReference, 0) - a, ok := v6.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v6) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewParameterOrReference(item, compiler.NewContext("parameters", context)) if err != nil { errors = append(errors, err) @@ -2785,7 +2785,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // bool deprecated = 10; v10 := compiler.MapValueForKey(m, "deprecated") if v10 != nil { - x.Deprecated, ok = v10.(bool) + x.Deprecated, ok = compiler.BoolForScalarNode(v10) if !ok { message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) @@ -2796,9 +2796,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v11 != nil { // repeated SecurityRequirement x.Security = make([]*SecurityRequirement, 0) - a, ok := v11.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v11) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewSecurityRequirement(item, compiler.NewContext("security", context)) if err != nil { errors = append(errors, err) @@ -2812,9 +2812,9 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v12 != nil { // repeated Server x.Servers = make([]*Server, 0) - a, ok := v12.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v12) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewServer(item, compiler.NewContext("servers", context)) if err != nil { errors = append(errors, err) @@ -2826,10 +2826,10 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) // repeated NamedAny specification_extension = 13; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -2883,7 +2883,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -2892,7 +2892,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string in = 2; v2 := compiler.MapValueForKey(m, "in") if v2 != nil { - x.In, ok = v2.(string) + x.In, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -2901,7 +2901,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -2910,7 +2910,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // bool required = 4; v4 := compiler.MapValueForKey(m, "required") if v4 != nil { - x.Required, ok = v4.(bool) + x.Required, ok = compiler.BoolForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -2919,7 +2919,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // bool deprecated = 5; v5 := compiler.MapValueForKey(m, "deprecated") if v5 != nil { - x.Deprecated, ok = v5.(bool) + x.Deprecated, ok = compiler.BoolForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -2928,7 +2928,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // bool allow_empty_value = 6; v6 := compiler.MapValueForKey(m, "allowEmptyValue") if v6 != nil { - x.AllowEmptyValue, ok = v6.(bool) + x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -2937,7 +2937,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // string style = 7; v7 := compiler.MapValueForKey(m, "style") if v7 != nil { - x.Style, ok = v7.(string) + x.Style, ok = compiler.StringForScalarNode(v7) if !ok { message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v7, v7) errors = append(errors, compiler.NewError(context, message)) @@ -2946,7 +2946,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // bool explode = 8; v8 := compiler.MapValueForKey(m, "explode") if v8 != nil { - x.Explode, ok = v8.(bool) + x.Explode, ok = compiler.BoolForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -2955,7 +2955,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // bool allow_reserved = 9; v9 := compiler.MapValueForKey(m, "allowReserved") if v9 != nil { - x.AllowReserved, ok = v9.(bool) + x.AllowReserved, ok = compiler.BoolForScalarNode(v9) if !ok { message := fmt.Sprintf("has unexpected value for allowReserved: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -3000,10 +3000,10 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) // repeated NamedAny specification_extension = 14; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3084,10 +3084,10 @@ func NewParametersOrReferences(in interface{}, context *compiler.Context) (*Para // repeated NamedParameterOrReference additional_properties = 1; // MAP: ParameterOrReference x.AdditionalProperties = make([]*NamedParameterOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedParameterOrReference{} pair.Name = k var err error @@ -3121,7 +3121,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { // string _ref = 1; v1 := compiler.MapValueForKey(m, "$ref") if v1 != nil { - x.XRef, ok = v1.(string) + x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3130,7 +3130,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { // string summary = 2; v2 := compiler.MapValueForKey(m, "summary") if v2 != nil { - x.Summary, ok = v2.(string) + x.Summary, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -3139,7 +3139,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -3222,9 +3222,9 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if v12 != nil { // repeated Server x.Servers = make([]*Server, 0) - a, ok := v12.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v12) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewServer(item, compiler.NewContext("servers", context)) if err != nil { errors = append(errors, err) @@ -3238,9 +3238,9 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if v13 != nil { // repeated ParameterOrReference x.Parameters = make([]*ParameterOrReference, 0) - a, ok := v13.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v13) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewParameterOrReference(item, compiler.NewContext("parameters", context)) if err != nil { errors = append(errors, err) @@ -3252,10 +3252,10 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { // repeated NamedAny specification_extension = 14; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3303,10 +3303,10 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { // repeated NamedPathItem path = 1; // MAP: PathItem ^/ x.Path = make([]*NamedPathItem, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "/") { pair := &NamedPathItem{} pair.Name = k @@ -3322,10 +3322,10 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { // repeated NamedAny specification_extension = 2; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3366,10 +3366,10 @@ func NewProperties(in interface{}, context *compiler.Context) (*Properties, erro // repeated NamedSchemaOrReference additional_properties = 1; // MAP: SchemaOrReference x.AdditionalProperties = make([]*NamedSchemaOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedSchemaOrReference{} pair.Name = k var err error @@ -3402,7 +3402,7 @@ func NewReference(in interface{}, context *compiler.Context) (*Reference, error) // string _ref = 1; v1 := compiler.MapValueForKey(m, "$ref") if v1 != nil { - x.XRef, ok = v1.(string) + x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3424,10 +3424,10 @@ func NewRequestBodiesOrReferences(in interface{}, context *compiler.Context) (*R // repeated NamedRequestBodyOrReference additional_properties = 1; // MAP: RequestBodyOrReference x.AdditionalProperties = make([]*NamedRequestBodyOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedRequestBodyOrReference{} pair.Name = k var err error @@ -3467,7 +3467,7 @@ func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, er // string description = 1; v1 := compiler.MapValueForKey(m, "description") if v1 != nil { - x.Description, ok = v1.(string) + x.Description, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3485,7 +3485,7 @@ func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, er // bool required = 3; v3 := compiler.MapValueForKey(m, "required") if v3 != nil { - x.Required, ok = v3.(bool) + x.Required, ok = compiler.BoolForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -3494,10 +3494,10 @@ func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, er // repeated NamedAny specification_extension = 4; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3591,7 +3591,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { // string description = 1; v1 := compiler.MapValueForKey(m, "description") if v1 != nil { - x.Description, ok = v1.(string) + x.Description, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3627,10 +3627,10 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { // repeated NamedAny specification_extension = 5; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3727,10 +3727,10 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) // repeated NamedResponseOrReference response_or_reference = 2; // MAP: ResponseOrReference ^([0-9X]{3})$ x.ResponseOrReference = make([]*NamedResponseOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if pattern3.MatchString(k) { pair := &NamedResponseOrReference{} pair.Name = k @@ -3746,10 +3746,10 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) // repeated NamedAny specification_extension = 3; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -3790,10 +3790,10 @@ func NewResponsesOrReferences(in interface{}, context *compiler.Context) (*Respo // repeated NamedResponseOrReference additional_properties = 1; // MAP: ResponseOrReference x.AdditionalProperties = make([]*NamedResponseOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedResponseOrReference{} pair.Name = k var err error @@ -3827,7 +3827,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool nullable = 1; v1 := compiler.MapValueForKey(m, "nullable") if v1 != nil { - x.Nullable, ok = v1.(bool) + x.Nullable, ok = compiler.BoolForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for nullable: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -3845,7 +3845,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool read_only = 3; v3 := compiler.MapValueForKey(m, "readOnly") if v3 != nil { - x.ReadOnly, ok = v3.(bool) + x.ReadOnly, ok = compiler.BoolForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -3854,7 +3854,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool write_only = 4; v4 := compiler.MapValueForKey(m, "writeOnly") if v4 != nil { - x.WriteOnly, ok = v4.(bool) + x.WriteOnly, ok = compiler.BoolForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for writeOnly: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -3890,7 +3890,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool deprecated = 8; v8 := compiler.MapValueForKey(m, "deprecated") if v8 != nil { - x.Deprecated, ok = v8.(bool) + x.Deprecated, ok = compiler.BoolForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -3899,7 +3899,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string title = 9; v9 := compiler.MapValueForKey(m, "title") if v9 != nil { - x.Title, ok = v9.(string) + x.Title, ok = compiler.StringForScalarNode(v9) if !ok { message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v9, v9) errors = append(errors, compiler.NewError(context, message)) @@ -3908,22 +3908,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // float multiple_of = 10; v10 := compiler.MapValueForKey(m, "multipleOf") if v10 != nil { - switch v10 := v10.(type) { - case float64: - x.MultipleOf = v10 - case float32: - x.MultipleOf = float64(v10) - case uint64: - x.MultipleOf = float64(v10) - case uint32: - x.MultipleOf = float64(v10) - case int64: - x.MultipleOf = float64(v10) - case int32: - x.MultipleOf = float64(v10) - case int: - x.MultipleOf = float64(v10) - default: + v, ok := compiler.FloatForScalarNode(v10) + if ok { + x.MultipleOf = v + } else { message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v10, v10) errors = append(errors, compiler.NewError(context, message)) } @@ -3931,22 +3919,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // float maximum = 11; v11 := compiler.MapValueForKey(m, "maximum") if v11 != nil { - switch v11 := v11.(type) { - case float64: - x.Maximum = v11 - case float32: - x.Maximum = float64(v11) - case uint64: - x.Maximum = float64(v11) - case uint32: - x.Maximum = float64(v11) - case int64: - x.Maximum = float64(v11) - case int32: - x.Maximum = float64(v11) - case int: - x.Maximum = float64(v11) - default: + v, ok := compiler.FloatForScalarNode(v11) + if ok { + x.Maximum = v + } else { message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11) errors = append(errors, compiler.NewError(context, message)) } @@ -3954,7 +3930,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool exclusive_maximum = 12; v12 := compiler.MapValueForKey(m, "exclusiveMaximum") if v12 != nil { - x.ExclusiveMaximum, ok = v12.(bool) + x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v12) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12) errors = append(errors, compiler.NewError(context, message)) @@ -3963,22 +3939,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // float minimum = 13; v13 := compiler.MapValueForKey(m, "minimum") if v13 != nil { - switch v13 := v13.(type) { - case float64: - x.Minimum = v13 - case float32: - x.Minimum = float64(v13) - case uint64: - x.Minimum = float64(v13) - case uint32: - x.Minimum = float64(v13) - case int64: - x.Minimum = float64(v13) - case int32: - x.Minimum = float64(v13) - case int: - x.Minimum = float64(v13) - default: + v, ok := compiler.FloatForScalarNode(v13) + if ok { + x.Minimum = v + } else { message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13) errors = append(errors, compiler.NewError(context, message)) } @@ -3986,7 +3950,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool exclusive_minimum = 14; v14 := compiler.MapValueForKey(m, "exclusiveMinimum") if v14 != nil { - x.ExclusiveMinimum, ok = v14.(bool) + x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v14) if !ok { message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14) errors = append(errors, compiler.NewError(context, message)) @@ -3995,7 +3959,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 max_length = 15; v15 := compiler.MapValueForKey(m, "maxLength") if v15 != nil { - t, ok := v15.(int) + t, ok := compiler.IntForScalarNode(v15) if ok { x.MaxLength = int64(t) } else { @@ -4006,7 +3970,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 min_length = 16; v16 := compiler.MapValueForKey(m, "minLength") if v16 != nil { - t, ok := v16.(int) + t, ok := compiler.IntForScalarNode(v16) if ok { x.MinLength = int64(t) } else { @@ -4017,7 +3981,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string pattern = 17; v17 := compiler.MapValueForKey(m, "pattern") if v17 != nil { - x.Pattern, ok = v17.(string) + x.Pattern, ok = compiler.StringForScalarNode(v17) if !ok { message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17) errors = append(errors, compiler.NewError(context, message)) @@ -4026,7 +3990,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 max_items = 18; v18 := compiler.MapValueForKey(m, "maxItems") if v18 != nil { - t, ok := v18.(int) + t, ok := compiler.IntForScalarNode(v18) if ok { x.MaxItems = int64(t) } else { @@ -4037,7 +4001,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 min_items = 19; v19 := compiler.MapValueForKey(m, "minItems") if v19 != nil { - t, ok := v19.(int) + t, ok := compiler.IntForScalarNode(v19) if ok { x.MinItems = int64(t) } else { @@ -4048,7 +4012,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // bool unique_items = 20; v20 := compiler.MapValueForKey(m, "uniqueItems") if v20 != nil { - x.UniqueItems, ok = v20.(bool) + x.UniqueItems, ok = compiler.BoolForScalarNode(v20) if !ok { message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20) errors = append(errors, compiler.NewError(context, message)) @@ -4057,7 +4021,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 max_properties = 21; v21 := compiler.MapValueForKey(m, "maxProperties") if v21 != nil { - t, ok := v21.(int) + t, ok := compiler.IntForScalarNode(v21) if ok { x.MaxProperties = int64(t) } else { @@ -4068,7 +4032,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // int64 min_properties = 22; v22 := compiler.MapValueForKey(m, "minProperties") if v22 != nil { - t, ok := v22.(int) + t, ok := compiler.IntForScalarNode(v22) if ok { x.MinProperties = int64(t) } else { @@ -4079,9 +4043,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // repeated string required = 23; v23 := compiler.MapValueForKey(m, "required") if v23 != nil { - v, ok := v23.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v23) if ok { - x.Required = compiler.ConvertInterfaceArrayToStringArray(v) + x.Required = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v23, v23) errors = append(errors, compiler.NewError(context, message)) @@ -4092,9 +4056,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v24 != nil { // repeated Any x.Enum = make([]*Any, 0) - a, ok := v24.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v24) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewAny(item, compiler.NewContext("enum", context)) if err != nil { errors = append(errors, err) @@ -4106,7 +4070,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string type = 25; v25 := compiler.MapValueForKey(m, "type") if v25 != nil { - x.Type, ok = v25.(string) + x.Type, ok = compiler.StringForScalarNode(v25) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v25, v25) errors = append(errors, compiler.NewError(context, message)) @@ -4117,9 +4081,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v26 != nil { // repeated SchemaOrReference x.AllOf = make([]*SchemaOrReference, 0) - a, ok := v26.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v26) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewSchemaOrReference(item, compiler.NewContext("allOf", context)) if err != nil { errors = append(errors, err) @@ -4133,9 +4097,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v27 != nil { // repeated SchemaOrReference x.OneOf = make([]*SchemaOrReference, 0) - a, ok := v27.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v27) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewSchemaOrReference(item, compiler.NewContext("oneOf", context)) if err != nil { errors = append(errors, err) @@ -4149,9 +4113,9 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v28 != nil { // repeated SchemaOrReference x.AnyOf = make([]*SchemaOrReference, 0) - a, ok := v28.([]interface{}) + a, ok := compiler.SequenceNodeForNode(v28) if ok { - for _, item := range a { + for _, item := range a.Content { y, err := NewSchemaOrReference(item, compiler.NewContext("anyOf", context)) if err != nil { errors = append(errors, err) @@ -4208,7 +4172,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string description = 34; v34 := compiler.MapValueForKey(m, "description") if v34 != nil { - x.Description, ok = v34.(string) + x.Description, ok = compiler.StringForScalarNode(v34) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v34, v34) errors = append(errors, compiler.NewError(context, message)) @@ -4217,7 +4181,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // string format = 35; v35 := compiler.MapValueForKey(m, "format") if v35 != nil { - x.Format, ok = v35.(string) + x.Format, ok = compiler.StringForScalarNode(v35) if !ok { message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v35, v35) errors = append(errors, compiler.NewError(context, message)) @@ -4226,10 +4190,10 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { // repeated NamedAny specification_extension = 36; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4310,10 +4274,10 @@ func NewSchemasOrReferences(in interface{}, context *compiler.Context) (*Schemas // repeated NamedSchemaOrReference additional_properties = 1; // MAP: SchemaOrReference x.AdditionalProperties = make([]*NamedSchemaOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedSchemaOrReference{} pair.Name = k var err error @@ -4340,10 +4304,10 @@ func NewSecurityRequirement(in interface{}, context *compiler.Context) (*Securit // repeated NamedStringArray additional_properties = 1; // MAP: StringArray x.AdditionalProperties = make([]*NamedStringArray, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedStringArray{} pair.Name = k var err error @@ -4383,7 +4347,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche // string type = 1; v1 := compiler.MapValueForKey(m, "type") if v1 != nil { - x.Type, ok = v1.(string) + x.Type, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4392,7 +4356,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche // string description = 2; v2 := compiler.MapValueForKey(m, "description") if v2 != nil { - x.Description, ok = v2.(string) + x.Description, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -4401,7 +4365,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche // string name = 3; v3 := compiler.MapValueForKey(m, "name") if v3 != nil { - x.Name, ok = v3.(string) + x.Name, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -4410,7 +4374,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche // string in = 4; v4 := compiler.MapValueForKey(m, "in") if v4 != nil { - x.In, ok = v4.(string) + x.In, ok = compiler.StringForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -4419,7 +4383,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche // string scheme = 5; v5 := compiler.MapValueForKey(m, "scheme") if v5 != nil { - x.Scheme, ok = v5.(string) + x.Scheme, ok = compiler.StringForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for scheme: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -4428,7 +4392,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche // string bearer_format = 6; v6 := compiler.MapValueForKey(m, "bearerFormat") if v6 != nil { - x.BearerFormat, ok = v6.(string) + x.BearerFormat, ok = compiler.StringForScalarNode(v6) if !ok { message := fmt.Sprintf("has unexpected value for bearerFormat: %+v (%T)", v6, v6) errors = append(errors, compiler.NewError(context, message)) @@ -4446,7 +4410,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche // string open_id_connect_url = 8; v8 := compiler.MapValueForKey(m, "openIdConnectUrl") if v8 != nil { - x.OpenIdConnectUrl, ok = v8.(string) + x.OpenIdConnectUrl, ok = compiler.StringForScalarNode(v8) if !ok { message := fmt.Sprintf("has unexpected value for openIdConnectUrl: %+v (%T)", v8, v8) errors = append(errors, compiler.NewError(context, message)) @@ -4455,10 +4419,10 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche // repeated NamedAny specification_extension = 9; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4539,10 +4503,10 @@ func NewSecuritySchemesOrReferences(in interface{}, context *compiler.Context) ( // repeated NamedSecuritySchemeOrReference additional_properties = 1; // MAP: SecuritySchemeOrReference x.AdditionalProperties = make([]*NamedSecuritySchemeOrReference, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedSecuritySchemeOrReference{} pair.Name = k var err error @@ -4582,7 +4546,7 @@ func NewServer(in interface{}, context *compiler.Context) (*Server, error) { // string url = 1; v1 := compiler.MapValueForKey(m, "url") if v1 != nil { - x.Url, ok = v1.(string) + x.Url, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4591,7 +4555,7 @@ func NewServer(in interface{}, context *compiler.Context) (*Server, error) { // string description = 2; v2 := compiler.MapValueForKey(m, "description") if v2 != nil { - x.Description, ok = v2.(string) + x.Description, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -4609,10 +4573,10 @@ func NewServer(in interface{}, context *compiler.Context) (*Server, error) { // repeated NamedAny specification_extension = 4; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4666,9 +4630,9 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab // repeated string enum = 1; v1 := compiler.MapValueForKey(m, "enum") if v1 != nil { - v, ok := v1.([]interface{}) + v, ok := compiler.SequenceNodeForNode(v1) if ok { - x.Enum = compiler.ConvertInterfaceArrayToStringArray(v) + x.Enum = compiler.StringArrayForSequenceNode(v) } else { message := fmt.Sprintf("has unexpected value for enum: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4677,7 +4641,7 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab // string default = 2; v2 := compiler.MapValueForKey(m, "default") if v2 != nil { - x.Default, ok = v2.(string) + x.Default, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for default: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -4686,7 +4650,7 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab // string description = 3; v3 := compiler.MapValueForKey(m, "description") if v3 != nil { - x.Description, ok = v3.(string) + x.Description, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -4695,10 +4659,10 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab // repeated NamedAny specification_extension = 4; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4739,10 +4703,10 @@ func NewServerVariables(in interface{}, context *compiler.Context) (*ServerVaria // repeated NamedServerVariable additional_properties = 1; // MAP: ServerVariable x.AdditionalProperties = make([]*NamedServerVariable, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedServerVariable{} pair.Name = k var err error @@ -4821,13 +4785,13 @@ func NewStrings(in interface{}, context *compiler.Context) (*Strings, error) { // repeated NamedString additional_properties = 1; // MAP: string x.AdditionalProperties = make([]*NamedString, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] pair := &NamedString{} pair.Name = k - pair.Value = v.(string) + pair.Value, _ = compiler.StringForScalarNode(v) x.AdditionalProperties = append(x.AdditionalProperties, pair) } } @@ -4860,7 +4824,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4869,7 +4833,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { // string description = 2; v2 := compiler.MapValueForKey(m, "description") if v2 != nil { - x.Description, ok = v2.(string) + x.Description, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -4887,10 +4851,10 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { // repeated NamedAny specification_extension = 4; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -4938,7 +4902,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // string name = 1; v1 := compiler.MapValueForKey(m, "name") if v1 != nil { - x.Name, ok = v1.(string) + x.Name, ok = compiler.StringForScalarNode(v1) if !ok { message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) errors = append(errors, compiler.NewError(context, message)) @@ -4947,7 +4911,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // string namespace = 2; v2 := compiler.MapValueForKey(m, "namespace") if v2 != nil { - x.Namespace, ok = v2.(string) + x.Namespace, ok = compiler.StringForScalarNode(v2) if !ok { message := fmt.Sprintf("has unexpected value for namespace: %+v (%T)", v2, v2) errors = append(errors, compiler.NewError(context, message)) @@ -4956,7 +4920,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // string prefix = 3; v3 := compiler.MapValueForKey(m, "prefix") if v3 != nil { - x.Prefix, ok = v3.(string) + x.Prefix, ok = compiler.StringForScalarNode(v3) if !ok { message := fmt.Sprintf("has unexpected value for prefix: %+v (%T)", v3, v3) errors = append(errors, compiler.NewError(context, message)) @@ -4965,7 +4929,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // bool attribute = 4; v4 := compiler.MapValueForKey(m, "attribute") if v4 != nil { - x.Attribute, ok = v4.(bool) + x.Attribute, ok = compiler.BoolForScalarNode(v4) if !ok { message := fmt.Sprintf("has unexpected value for attribute: %+v (%T)", v4, v4) errors = append(errors, compiler.NewError(context, message)) @@ -4974,7 +4938,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // bool wrapped = 5; v5 := compiler.MapValueForKey(m, "wrapped") if v5 != nil { - x.Wrapped, ok = v5.(bool) + x.Wrapped, ok = compiler.BoolForScalarNode(v5) if !ok { message := fmt.Sprintf("has unexpected value for wrapped: %+v (%T)", v5, v5) errors = append(errors, compiler.NewError(context, message)) @@ -4983,10 +4947,10 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { // repeated NamedAny specification_extension = 6; // MAP: Any ^x- x.SpecificationExtension = make([]*NamedAny, 0) - for _, item := range m { - k, ok := compiler.StringValue(item.Key) + for i := 0; i < len(m.Content); i += 2 { + k, ok := compiler.StringForScalarNode(m.Content[i]) if ok { - v := item.Value + v := m.Content[i+1] if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k @@ -6674,7 +6638,7 @@ func (m *Xml) ResolveReferences(root string) (interface{}, error) { } // ToRawInfo returns a description of AdditionalPropertiesItem suitable for JSON or YAML export. -func (m *AdditionalPropertiesItem) ToRawInfo() interface{} { +func (m *AdditionalPropertiesItem) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // AdditionalPropertiesItem // {Name:schemaOrReference Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -6684,34 +6648,24 @@ func (m *AdditionalPropertiesItem) ToRawInfo() interface{} { } // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if v1, ok := m.GetOneof().(*AdditionalPropertiesItem_Boolean); ok { - return v1.Boolean + return compiler.NewScalarNodeForBool(v1.Boolean) } return nil } // ToRawInfo returns a description of Any suitable for JSON or YAML export. -func (m *Any) ToRawInfo() interface{} { +func (m *Any) ToRawInfo() *yaml.Node { 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) + var node yaml.Node + err = yaml.Unmarshal([]byte(m.Yaml), &node) if err == nil { - return info3 + return &node } return nil } // ToRawInfo returns a description of AnyOrExpression suitable for JSON or YAML export. -func (m *AnyOrExpression) ToRawInfo() interface{} { +func (m *AnyOrExpression) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // AnyOrExpression // {Name:any Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -6728,20 +6682,22 @@ func (m *AnyOrExpression) ToRawInfo() interface{} { } // ToRawInfo returns a description of Callback suitable for JSON or YAML export. -func (m *Callback) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Callback) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Path != nil { for _, item := range m.Path { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:Path Type:NamedPathItem StringEnumValues:[] MapType:PathItem Repeated:true Pattern:^ Implicit:true Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -6749,7 +6705,7 @@ func (m *Callback) ToRawInfo() interface{} { } // ToRawInfo returns a description of CallbackOrReference suitable for JSON or YAML export. -func (m *CallbackOrReference) ToRawInfo() interface{} { +func (m *CallbackOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // CallbackOrReference // {Name:callback Type:Callback StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -6766,14 +6722,15 @@ func (m *CallbackOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of CallbacksOrReferences suitable for JSON or YAML export. -func (m *CallbacksOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *CallbacksOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedCallbackOrReference StringEnumValues:[] MapType:CallbackOrReference Repeated:true Pattern: Implicit:true Description:} @@ -6781,50 +6738,60 @@ func (m *CallbacksOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of Components suitable for JSON or YAML export. -func (m *Components) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Components) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Schemas != nil { - info = append(info, yaml.MapItem{Key: "schemas", Value: m.Schemas.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schemas")) + info.Content = append(info.Content, m.Schemas.ToRawInfo()) } // &{Name:schemas Type:SchemasOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Responses != nil { - info = append(info, yaml.MapItem{Key: "responses", Value: m.Responses.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("responses")) + info.Content = append(info.Content, m.Responses.ToRawInfo()) } // &{Name:responses Type:ResponsesOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Parameters != nil { - info = append(info, yaml.MapItem{Key: "parameters", Value: m.Parameters.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, m.Parameters.ToRawInfo()) } // &{Name:parameters Type:ParametersOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Examples != nil { - info = append(info, yaml.MapItem{Key: "examples", Value: m.Examples.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, m.Examples.ToRawInfo()) } // &{Name:examples Type:ExamplesOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.RequestBodies != nil { - info = append(info, yaml.MapItem{Key: "requestBodies", Value: m.RequestBodies.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("requestBodies")) + info.Content = append(info.Content, m.RequestBodies.ToRawInfo()) } // &{Name:requestBodies Type:RequestBodiesOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Headers != nil { - info = append(info, yaml.MapItem{Key: "headers", Value: m.Headers.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("headers")) + info.Content = append(info.Content, m.Headers.ToRawInfo()) } // &{Name:headers Type:HeadersOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SecuritySchemes != nil { - info = append(info, yaml.MapItem{Key: "securitySchemes", Value: m.SecuritySchemes.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("securitySchemes")) + info.Content = append(info.Content, m.SecuritySchemes.ToRawInfo()) } // &{Name:securitySchemes Type:SecuritySchemesOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Links != nil { - info = append(info, yaml.MapItem{Key: "links", Value: m.Links.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("links")) + info.Content = append(info.Content, m.Links.ToRawInfo()) } // &{Name:links Type:LinksOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Callbacks != nil { - info = append(info, yaml.MapItem{Key: "callbacks", Value: m.Callbacks.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("callbacks")) + info.Content = append(info.Content, m.Callbacks.ToRawInfo()) } // &{Name:callbacks Type:CallbacksOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -6832,23 +6799,27 @@ func (m *Components) ToRawInfo() interface{} { } // ToRawInfo returns a description of Contact suitable for JSON or YAML export. -func (m *Contact) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Contact) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Url != "" { - info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) } if m.Email != "" { - info = append(info, yaml.MapItem{Key: "email", Value: m.Email}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("email")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Email)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -6856,39 +6827,42 @@ func (m *Contact) ToRawInfo() interface{} { } // ToRawInfo returns a description of DefaultType suitable for JSON or YAML export. -func (m *DefaultType) ToRawInfo() interface{} { +func (m *DefaultType) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // DefaultType // {Name:number Type:float StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if v0, ok := m.GetOneof().(*DefaultType_Number); ok { - return v0.Number + return compiler.NewScalarNodeForFloat(v0.Number) } // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if v1, ok := m.GetOneof().(*DefaultType_Boolean); ok { - return v1.Boolean + return compiler.NewScalarNodeForBool(v1.Boolean) } // {Name:string Type:string StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if v2, ok := m.GetOneof().(*DefaultType_String_); ok { - return v2.String_ + return compiler.NewScalarNodeForString(v2.String_) } return nil } // ToRawInfo returns a description of Discriminator suitable for JSON or YAML export. -func (m *Discriminator) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Discriminator) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "propertyName", Value: m.PropertyName}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("propertyName")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.PropertyName)) if m.Mapping != nil { - info = append(info, yaml.MapItem{Key: "mapping", Value: m.Mapping.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("mapping")) + info.Content = append(info.Content, m.Mapping.ToRawInfo()) } // &{Name:mapping Type:Strings StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -6896,54 +6870,63 @@ func (m *Discriminator) ToRawInfo() interface{} { } // ToRawInfo returns a description of Document suitable for JSON or YAML export. -func (m *Document) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Document) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "openapi", Value: m.Openapi}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("openapi")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Openapi)) // always include this required field. - info = append(info, yaml.MapItem{Key: "info", Value: m.Info.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("info")) + info.Content = append(info.Content, m.Info.ToRawInfo()) // &{Name:info Type:Info StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.Servers) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Servers { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "servers", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("servers")) + info.Content = append(info.Content, items) } // &{Name:servers Type:Server StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} // always include this required field. - info = append(info, yaml.MapItem{Key: "paths", Value: m.Paths.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("paths")) + info.Content = append(info.Content, m.Paths.ToRawInfo()) // &{Name:paths Type:Paths StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Components != nil { - info = append(info, yaml.MapItem{Key: "components", Value: m.Components.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("components")) + info.Content = append(info.Content, m.Components.ToRawInfo()) } // &{Name:components Type:Components StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.Security) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Security { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "security", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("security")) + info.Content = append(info.Content, items) } // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if len(m.Tags) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Tags { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "tags", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("tags")) + info.Content = append(info.Content, items) } // &{Name:tags Type:Tag StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) } // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -6951,30 +6934,36 @@ func (m *Document) ToRawInfo() interface{} { } // ToRawInfo returns a description of Encoding suitable for JSON or YAML export. -func (m *Encoding) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Encoding) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.ContentType != "" { - info = append(info, yaml.MapItem{Key: "contentType", Value: m.ContentType}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("contentType")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.ContentType)) } if m.Headers != nil { - info = append(info, yaml.MapItem{Key: "headers", Value: m.Headers.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("headers")) + info.Content = append(info.Content, m.Headers.ToRawInfo()) } // &{Name:headers Type:HeadersOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Style != "" { - info = append(info, yaml.MapItem{Key: "style", Value: m.Style}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) } if m.Explode != false { - info = append(info, yaml.MapItem{Key: "explode", Value: m.Explode}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) } if m.AllowReserved != false { - info = append(info, yaml.MapItem{Key: "allowReserved", Value: m.AllowReserved}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -6982,14 +6971,15 @@ func (m *Encoding) ToRawInfo() interface{} { } // ToRawInfo returns a description of Encodings suitable for JSON or YAML export. -func (m *Encodings) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Encodings) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedEncoding StringEnumValues:[] MapType:Encoding Repeated:true Pattern: Implicit:true Description:} @@ -6997,24 +6987,28 @@ func (m *Encodings) ToRawInfo() interface{} { } // ToRawInfo returns a description of Example suitable for JSON or YAML export. -func (m *Example) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Example) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Summary != "" { - info = append(info, yaml.MapItem{Key: "summary", Value: m.Summary}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } // &{Name:value Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.ExternalValue != "" { - info = append(info, yaml.MapItem{Key: "externalValue", Value: m.ExternalValue}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalValue")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.ExternalValue)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7022,7 +7016,7 @@ func (m *Example) ToRawInfo() interface{} { } // ToRawInfo returns a description of ExampleOrReference suitable for JSON or YAML export. -func (m *ExampleOrReference) ToRawInfo() interface{} { +func (m *ExampleOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // ExampleOrReference // {Name:example Type:Example StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -7039,14 +7033,15 @@ func (m *ExampleOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of ExamplesOrReferences suitable for JSON or YAML export. -func (m *ExamplesOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ExamplesOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedExampleOrReference StringEnumValues:[] MapType:ExampleOrReference Repeated:true Pattern: Implicit:true Description:} @@ -7054,14 +7049,15 @@ func (m *ExamplesOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of Expression suitable for JSON or YAML export. -func (m *Expression) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Expression) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:} @@ -7069,19 +7065,22 @@ func (m *Expression) ToRawInfo() interface{} { } // ToRawInfo returns a description of ExternalDocs suitable for JSON or YAML export. -func (m *ExternalDocs) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ExternalDocs) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } // always include this required field. - info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7089,51 +7088,63 @@ func (m *ExternalDocs) ToRawInfo() interface{} { } // ToRawInfo returns a description of Header suitable for JSON or YAML export. -func (m *Header) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Header) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } if m.Deprecated != false { - info = append(info, yaml.MapItem{Key: "deprecated", Value: m.Deprecated}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } if m.AllowEmptyValue != false { - info = append(info, yaml.MapItem{Key: "allowEmptyValue", Value: m.AllowEmptyValue}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowEmptyValue")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowEmptyValue)) } if m.Style != "" { - info = append(info, yaml.MapItem{Key: "style", Value: m.Style}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) } if m.Explode != false { - info = append(info, yaml.MapItem{Key: "explode", Value: m.Explode}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) } if m.AllowReserved != false { - info = append(info, yaml.MapItem{Key: "allowReserved", Value: m.AllowReserved}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) } if m.Schema != nil { - info = append(info, yaml.MapItem{Key: "schema", Value: m.Schema.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, m.Schema.ToRawInfo()) } // &{Name:schema Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Example != nil { - info = append(info, yaml.MapItem{Key: "example", Value: m.Example.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, m.Example.ToRawInfo()) } // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Examples != nil { - info = append(info, yaml.MapItem{Key: "examples", Value: m.Examples.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, m.Examples.ToRawInfo()) } // &{Name:examples Type:ExamplesOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Content != nil { - info = append(info, yaml.MapItem{Key: "content", Value: m.Content.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) + info.Content = append(info.Content, m.Content.ToRawInfo()) } // &{Name:content Type:MediaTypes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7141,7 +7152,7 @@ func (m *Header) ToRawInfo() interface{} { } // ToRawInfo returns a description of HeaderOrReference suitable for JSON or YAML export. -func (m *HeaderOrReference) ToRawInfo() interface{} { +func (m *HeaderOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // HeaderOrReference // {Name:header Type:Header StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -7158,14 +7169,15 @@ func (m *HeaderOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of HeadersOrReferences suitable for JSON or YAML export. -func (m *HeadersOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *HeadersOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedHeaderOrReference StringEnumValues:[] MapType:HeaderOrReference Repeated:true Pattern: Implicit:true Description:} @@ -7173,35 +7185,43 @@ func (m *HeadersOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of Info suitable for JSON or YAML export. -func (m *Info) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Info) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.TermsOfService != "" { - info = append(info, yaml.MapItem{Key: "termsOfService", Value: m.TermsOfService}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("termsOfService")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.TermsOfService)) } if m.Contact != nil { - info = append(info, yaml.MapItem{Key: "contact", Value: m.Contact.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("contact")) + info.Content = append(info.Content, m.Contact.ToRawInfo()) } // &{Name:contact Type:Contact StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.License != nil { - info = append(info, yaml.MapItem{Key: "license", Value: m.License.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("license")) + info.Content = append(info.Content, m.License.ToRawInfo()) } // &{Name:license Type:License StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} // always include this required field. - info = append(info, yaml.MapItem{Key: "version", Value: m.Version}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("version")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Version)) if m.Summary != "" { - info = append(info, yaml.MapItem{Key: "summary", Value: m.Summary}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7209,36 +7229,40 @@ func (m *Info) ToRawInfo() interface{} { } // ToRawInfo returns a description of ItemsItem suitable for JSON or YAML export. -func (m *ItemsItem) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ItemsItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if len(m.SchemaOrReference) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.SchemaOrReference { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "schemaOrReference", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schemaOrReference")) + info.Content = append(info.Content, items) } // &{Name:schemaOrReference Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} return info } // ToRawInfo returns a description of License suitable for JSON or YAML export. -func (m *License) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *License) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) if m.Url != "" { - info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7246,35 +7270,42 @@ func (m *License) ToRawInfo() interface{} { } // ToRawInfo returns a description of Link suitable for JSON or YAML export. -func (m *Link) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Link) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.OperationRef != "" { - info = append(info, yaml.MapItem{Key: "operationRef", Value: m.OperationRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("operationRef")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OperationRef)) } if m.OperationId != "" { - info = append(info, yaml.MapItem{Key: "operationId", Value: m.OperationId}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("operationId")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OperationId)) } if m.Parameters != nil { - info = append(info, yaml.MapItem{Key: "parameters", Value: m.Parameters.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, m.Parameters.ToRawInfo()) } // &{Name:parameters Type:AnyOrExpression StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.RequestBody != nil { - info = append(info, yaml.MapItem{Key: "requestBody", Value: m.RequestBody.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("requestBody")) + info.Content = append(info.Content, m.RequestBody.ToRawInfo()) } // &{Name:requestBody Type:AnyOrExpression StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Server != nil { - info = append(info, yaml.MapItem{Key: "server", Value: m.Server.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("server")) + info.Content = append(info.Content, m.Server.ToRawInfo()) } // &{Name:server Type:Server StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7282,7 +7313,7 @@ func (m *Link) ToRawInfo() interface{} { } // ToRawInfo returns a description of LinkOrReference suitable for JSON or YAML export. -func (m *LinkOrReference) ToRawInfo() interface{} { +func (m *LinkOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // LinkOrReference // {Name:link Type:Link StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -7299,14 +7330,15 @@ func (m *LinkOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of LinksOrReferences suitable for JSON or YAML export. -func (m *LinksOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *LinksOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedLinkOrReference StringEnumValues:[] MapType:LinkOrReference Repeated:true Pattern: Implicit:true Description:} @@ -7314,30 +7346,35 @@ func (m *LinksOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of MediaType suitable for JSON or YAML export. -func (m *MediaType) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *MediaType) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Schema != nil { - info = append(info, yaml.MapItem{Key: "schema", Value: m.Schema.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, m.Schema.ToRawInfo()) } // &{Name:schema Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Example != nil { - info = append(info, yaml.MapItem{Key: "example", Value: m.Example.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, m.Example.ToRawInfo()) } // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Examples != nil { - info = append(info, yaml.MapItem{Key: "examples", Value: m.Examples.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, m.Examples.ToRawInfo()) } // &{Name:examples Type:ExamplesOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Encoding != nil { - info = append(info, yaml.MapItem{Key: "encoding", Value: m.Encoding.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("encoding")) + info.Content = append(info.Content, m.Encoding.ToRawInfo()) } // &{Name:encoding Type:Encodings StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7345,14 +7382,15 @@ func (m *MediaType) ToRawInfo() interface{} { } // ToRawInfo returns a description of MediaTypes suitable for JSON or YAML export. -func (m *MediaTypes) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *MediaTypes) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedMediaType StringEnumValues:[] MapType:MediaType Repeated:true Pattern: Implicit:true Description:} @@ -7360,237 +7398,259 @@ func (m *MediaTypes) ToRawInfo() interface{} { } // ToRawInfo returns a description of NamedAny suitable for JSON or YAML export. -func (m *NamedAny) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedAny) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedCallbackOrReference suitable for JSON or YAML export. -func (m *NamedCallbackOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedCallbackOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:CallbackOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedEncoding suitable for JSON or YAML export. -func (m *NamedEncoding) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedEncoding) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:Encoding StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedExampleOrReference suitable for JSON or YAML export. -func (m *NamedExampleOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedExampleOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:ExampleOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedHeaderOrReference suitable for JSON or YAML export. -func (m *NamedHeaderOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedHeaderOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:HeaderOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedLinkOrReference suitable for JSON or YAML export. -func (m *NamedLinkOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedLinkOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:LinkOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedMediaType suitable for JSON or YAML export. -func (m *NamedMediaType) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedMediaType) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:MediaType StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedParameterOrReference suitable for JSON or YAML export. -func (m *NamedParameterOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedParameterOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:ParameterOrReference 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{} +func (m *NamedPathItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:PathItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedRequestBodyOrReference suitable for JSON or YAML export. -func (m *NamedRequestBodyOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedRequestBodyOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:RequestBodyOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedResponseOrReference suitable for JSON or YAML export. -func (m *NamedResponseOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedResponseOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:ResponseOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedSchemaOrReference suitable for JSON or YAML export. -func (m *NamedSchemaOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedSchemaOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedSecuritySchemeOrReference suitable for JSON or YAML export. -func (m *NamedSecuritySchemeOrReference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedSecuritySchemeOrReference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:SecuritySchemeOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of NamedServerVariable suitable for JSON or YAML export. -func (m *NamedServerVariable) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedServerVariable) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:ServerVariable 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{} +func (m *NamedString) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Value != "" { - info = append(info, yaml.MapItem{Key: "value", Value: m.Value}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("value")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Value)) } return info } // ToRawInfo returns a description of NamedStringArray suitable for JSON or YAML export. -func (m *NamedStringArray) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *NamedStringArray) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } // &{Name:value Type:StringArray StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:Mapped value} return info } // ToRawInfo returns a description of OauthFlow suitable for JSON or YAML export. -func (m *OauthFlow) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *OauthFlow) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AuthorizationUrl != "" { - info = append(info, yaml.MapItem{Key: "authorizationUrl", Value: m.AuthorizationUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("authorizationUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.AuthorizationUrl)) } if m.TokenUrl != "" { - info = append(info, yaml.MapItem{Key: "tokenUrl", Value: m.TokenUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("tokenUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.TokenUrl)) } if m.RefreshUrl != "" { - info = append(info, yaml.MapItem{Key: "refreshUrl", Value: m.RefreshUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("refreshUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.RefreshUrl)) } if m.Scopes != nil { - info = append(info, yaml.MapItem{Key: "scopes", Value: m.Scopes.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("scopes")) + info.Content = append(info.Content, m.Scopes.ToRawInfo()) } // &{Name:scopes Type:Strings StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7598,30 +7658,35 @@ func (m *OauthFlow) ToRawInfo() interface{} { } // ToRawInfo returns a description of OauthFlows suitable for JSON or YAML export. -func (m *OauthFlows) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *OauthFlows) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Implicit != nil { - info = append(info, yaml.MapItem{Key: "implicit", Value: m.Implicit.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("implicit")) + info.Content = append(info.Content, m.Implicit.ToRawInfo()) } // &{Name:implicit Type:OauthFlow StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Password != nil { - info = append(info, yaml.MapItem{Key: "password", Value: m.Password.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("password")) + info.Content = append(info.Content, m.Password.ToRawInfo()) } // &{Name:password Type:OauthFlow StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.ClientCredentials != nil { - info = append(info, yaml.MapItem{Key: "clientCredentials", Value: m.ClientCredentials.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("clientCredentials")) + info.Content = append(info.Content, m.ClientCredentials.ToRawInfo()) } // &{Name:clientCredentials Type:OauthFlow StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.AuthorizationCode != nil { - info = append(info, yaml.MapItem{Key: "authorizationCode", Value: m.AuthorizationCode.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("authorizationCode")) + info.Content = append(info.Content, m.AuthorizationCode.ToRawInfo()) } // &{Name:authorizationCode Type:OauthFlow StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7629,14 +7694,15 @@ func (m *OauthFlows) ToRawInfo() interface{} { } // ToRawInfo returns a description of Object suitable for JSON or YAML export. -func (m *Object) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Object) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern: Implicit:true Description:} @@ -7644,68 +7710,81 @@ func (m *Object) ToRawInfo() interface{} { } // ToRawInfo returns a description of Operation suitable for JSON or YAML export. -func (m *Operation) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Operation) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if len(m.Tags) != 0 { - info = append(info, yaml.MapItem{Key: "tags", Value: m.Tags}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("tags")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Tags)) } if m.Summary != "" { - info = append(info, yaml.MapItem{Key: "summary", Value: m.Summary}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) } // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.OperationId != "" { - info = append(info, yaml.MapItem{Key: "operationId", Value: m.OperationId}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("operationId")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OperationId)) } if len(m.Parameters) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Parameters { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "parameters", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, items) } // &{Name:parameters Type:ParameterOrReference StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.RequestBody != nil { - info = append(info, yaml.MapItem{Key: "requestBody", Value: m.RequestBody.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("requestBody")) + info.Content = append(info.Content, m.RequestBody.ToRawInfo()) } // &{Name:requestBody Type:RequestBodyOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} // always include this required field. - info = append(info, yaml.MapItem{Key: "responses", Value: m.Responses.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("responses")) + info.Content = append(info.Content, m.Responses.ToRawInfo()) // &{Name:responses Type:Responses StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Callbacks != nil { - info = append(info, yaml.MapItem{Key: "callbacks", Value: m.Callbacks.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("callbacks")) + info.Content = append(info.Content, m.Callbacks.ToRawInfo()) } // &{Name:callbacks Type:CallbacksOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Deprecated != false { - info = append(info, yaml.MapItem{Key: "deprecated", Value: m.Deprecated}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } if len(m.Security) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Security { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "security", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("security")) + info.Content = append(info.Content, items) } // &{Name:security Type:SecurityRequirement StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if len(m.Servers) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Servers { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "servers", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("servers")) + info.Content = append(info.Content, items) } // &{Name:servers Type:Server StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7713,55 +7792,69 @@ func (m *Operation) ToRawInfo() interface{} { } // ToRawInfo returns a description of Parameter suitable for JSON or YAML export. -func (m *Parameter) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Parameter) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) // always include this required field. - info = append(info, yaml.MapItem{Key: "in", Value: m.In}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } if m.Deprecated != false { - info = append(info, yaml.MapItem{Key: "deprecated", Value: m.Deprecated}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } if m.AllowEmptyValue != false { - info = append(info, yaml.MapItem{Key: "allowEmptyValue", Value: m.AllowEmptyValue}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowEmptyValue")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowEmptyValue)) } if m.Style != "" { - info = append(info, yaml.MapItem{Key: "style", Value: m.Style}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("style")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Style)) } if m.Explode != false { - info = append(info, yaml.MapItem{Key: "explode", Value: m.Explode}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("explode")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Explode)) } if m.AllowReserved != false { - info = append(info, yaml.MapItem{Key: "allowReserved", Value: m.AllowReserved}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allowReserved")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.AllowReserved)) } if m.Schema != nil { - info = append(info, yaml.MapItem{Key: "schema", Value: m.Schema.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("schema")) + info.Content = append(info.Content, m.Schema.ToRawInfo()) } // &{Name:schema Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Example != nil { - info = append(info, yaml.MapItem{Key: "example", Value: m.Example.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, m.Example.ToRawInfo()) } // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Examples != nil { - info = append(info, yaml.MapItem{Key: "examples", Value: m.Examples.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("examples")) + info.Content = append(info.Content, m.Examples.ToRawInfo()) } // &{Name:examples Type:ExamplesOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Content != nil { - info = append(info, yaml.MapItem{Key: "content", Value: m.Content.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) + info.Content = append(info.Content, m.Content.ToRawInfo()) } // &{Name:content Type:MediaTypes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7769,7 +7862,7 @@ func (m *Parameter) ToRawInfo() interface{} { } // ToRawInfo returns a description of ParameterOrReference suitable for JSON or YAML export. -func (m *ParameterOrReference) ToRawInfo() interface{} { +func (m *ParameterOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // ParameterOrReference // {Name:parameter Type:Parameter StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -7786,14 +7879,15 @@ func (m *ParameterOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of ParametersOrReferences suitable for JSON or YAML export. -func (m *ParametersOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ParametersOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedParameterOrReference StringEnumValues:[] MapType:ParameterOrReference Repeated:true Pattern: Implicit:true Description:} @@ -7801,71 +7895,85 @@ func (m *ParametersOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of PathItem suitable for JSON or YAML export. -func (m *PathItem) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *PathItem) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.XRef != "" { - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) } if m.Summary != "" { - info = append(info, yaml.MapItem{Key: "summary", Value: m.Summary}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("summary")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Summary)) } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Get != nil { - info = append(info, yaml.MapItem{Key: "get", Value: m.Get.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("get")) + info.Content = append(info.Content, m.Get.ToRawInfo()) } // &{Name:get Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Put != nil { - info = append(info, yaml.MapItem{Key: "put", Value: m.Put.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("put")) + info.Content = append(info.Content, m.Put.ToRawInfo()) } // &{Name:put Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Post != nil { - info = append(info, yaml.MapItem{Key: "post", Value: m.Post.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("post")) + info.Content = append(info.Content, m.Post.ToRawInfo()) } // &{Name:post Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Delete != nil { - info = append(info, yaml.MapItem{Key: "delete", Value: m.Delete.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("delete")) + info.Content = append(info.Content, m.Delete.ToRawInfo()) } // &{Name:delete Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Options != nil { - info = append(info, yaml.MapItem{Key: "options", Value: m.Options.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("options")) + info.Content = append(info.Content, m.Options.ToRawInfo()) } // &{Name:options Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Head != nil { - info = append(info, yaml.MapItem{Key: "head", Value: m.Head.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("head")) + info.Content = append(info.Content, m.Head.ToRawInfo()) } // &{Name:head Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Patch != nil { - info = append(info, yaml.MapItem{Key: "patch", Value: m.Patch.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("patch")) + info.Content = append(info.Content, m.Patch.ToRawInfo()) } // &{Name:patch Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Trace != nil { - info = append(info, yaml.MapItem{Key: "trace", Value: m.Trace.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("trace")) + info.Content = append(info.Content, m.Trace.ToRawInfo()) } // &{Name:trace Type:Operation StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if len(m.Servers) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Servers { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "servers", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("servers")) + info.Content = append(info.Content, items) } // &{Name:servers Type:Server StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if len(m.Parameters) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Parameters { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "parameters", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("parameters")) + info.Content = append(info.Content, items) } // &{Name:parameters Type:ParameterOrReference StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7873,20 +7981,22 @@ func (m *PathItem) ToRawInfo() interface{} { } // ToRawInfo returns a description of Paths suitable for JSON or YAML export. -func (m *Paths) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Paths) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Path != nil { for _, item := range m.Path { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:Path Type:NamedPathItem StringEnumValues:[] MapType:PathItem Repeated:true Pattern:^/ Implicit:true Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7894,14 +8004,15 @@ func (m *Paths) ToRawInfo() interface{} { } // ToRawInfo returns a description of Properties suitable for JSON or YAML export. -func (m *Properties) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Properties) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedSchemaOrReference StringEnumValues:[] MapType:SchemaOrReference Repeated:true Pattern: Implicit:true Description:} @@ -7909,25 +8020,27 @@ func (m *Properties) ToRawInfo() interface{} { } // ToRawInfo returns a description of Reference suitable for JSON or YAML export. -func (m *Reference) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Reference) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "$ref", Value: m.XRef}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("$ref")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.XRef)) return info } // ToRawInfo returns a description of RequestBodiesOrReferences suitable for JSON or YAML export. -func (m *RequestBodiesOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *RequestBodiesOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedRequestBodyOrReference StringEnumValues:[] MapType:RequestBodyOrReference Repeated:true Pattern: Implicit:true Description:} @@ -7935,23 +8048,27 @@ func (m *RequestBodiesOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of RequestBody suitable for JSON or YAML export. -func (m *RequestBody) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *RequestBody) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } // always include this required field. - info = append(info, yaml.MapItem{Key: "content", Value: m.Content.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) + info.Content = append(info.Content, m.Content.ToRawInfo()) // &{Name:content Type:MediaTypes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Required != false { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Required)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -7959,7 +8076,7 @@ func (m *RequestBody) ToRawInfo() interface{} { } // ToRawInfo returns a description of RequestBodyOrReference suitable for JSON or YAML export. -func (m *RequestBodyOrReference) ToRawInfo() interface{} { +func (m *RequestBodyOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // RequestBodyOrReference // {Name:requestBody Type:RequestBody StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -7976,28 +8093,33 @@ func (m *RequestBodyOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of Response suitable for JSON or YAML export. -func (m *Response) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Response) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) if m.Headers != nil { - info = append(info, yaml.MapItem{Key: "headers", Value: m.Headers.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("headers")) + info.Content = append(info.Content, m.Headers.ToRawInfo()) } // &{Name:headers Type:HeadersOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Content != nil { - info = append(info, yaml.MapItem{Key: "content", Value: m.Content.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("content")) + info.Content = append(info.Content, m.Content.ToRawInfo()) } // &{Name:content Type:MediaTypes StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Links != nil { - info = append(info, yaml.MapItem{Key: "links", Value: m.Links.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("links")) + info.Content = append(info.Content, m.Links.ToRawInfo()) } // &{Name:links Type:LinksOrReferences StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8005,7 +8127,7 @@ func (m *Response) ToRawInfo() interface{} { } // ToRawInfo returns a description of ResponseOrReference suitable for JSON or YAML export. -func (m *ResponseOrReference) ToRawInfo() interface{} { +func (m *ResponseOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // ResponseOrReference // {Name:response Type:Response StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -8022,24 +8144,27 @@ func (m *ResponseOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of Responses suitable for JSON or YAML export. -func (m *Responses) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Responses) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, m.Default.ToRawInfo()) } // &{Name:default Type:ResponseOrReference StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.ResponseOrReference != nil { for _, item := range m.ResponseOrReference { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:ResponseOrReference Type:NamedResponseOrReference StringEnumValues:[] MapType:ResponseOrReference Repeated:true Pattern:^([0-9X]{3})$ Implicit:true Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8047,14 +8172,15 @@ func (m *Responses) ToRawInfo() interface{} { } // ToRawInfo returns a description of ResponsesOrReferences suitable for JSON or YAML export. -func (m *ResponsesOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ResponsesOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedResponseOrReference StringEnumValues:[] MapType:ResponseOrReference Repeated:true Pattern: Implicit:true Description:} @@ -8062,152 +8188,188 @@ func (m *ResponsesOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of Schema suitable for JSON or YAML export. -func (m *Schema) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Schema) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Nullable != false { - info = append(info, yaml.MapItem{Key: "nullable", Value: m.Nullable}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("nullable")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Nullable)) } if m.Discriminator != nil { - info = append(info, yaml.MapItem{Key: "discriminator", Value: m.Discriminator.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("discriminator")) + info.Content = append(info.Content, m.Discriminator.ToRawInfo()) } // &{Name:discriminator Type:Discriminator StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.ReadOnly != false { - info = append(info, yaml.MapItem{Key: "readOnly", Value: m.ReadOnly}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("readOnly")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ReadOnly)) } if m.WriteOnly != false { - info = append(info, yaml.MapItem{Key: "writeOnly", Value: m.WriteOnly}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("writeOnly")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.WriteOnly)) } if m.Xml != nil { - info = append(info, yaml.MapItem{Key: "xml", Value: m.Xml.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("xml")) + info.Content = append(info.Content, m.Xml.ToRawInfo()) } // &{Name:xml Type:Xml StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) } // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Example != nil { - info = append(info, yaml.MapItem{Key: "example", Value: m.Example.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("example")) + info.Content = append(info.Content, m.Example.ToRawInfo()) } // &{Name:example Type:Any StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Deprecated != false { - info = append(info, yaml.MapItem{Key: "deprecated", Value: m.Deprecated}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("deprecated")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Deprecated)) } if m.Title != "" { - info = append(info, yaml.MapItem{Key: "title", Value: m.Title}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("title")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Title)) } if m.MultipleOf != 0.0 { - info = append(info, yaml.MapItem{Key: "multipleOf", Value: m.MultipleOf}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("multipleOf")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.MultipleOf)) } if m.Maximum != 0.0 { - info = append(info, yaml.MapItem{Key: "maximum", Value: m.Maximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Maximum)) } if m.ExclusiveMaximum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMaximum", Value: m.ExclusiveMaximum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMaximum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMaximum)) } if m.Minimum != 0.0 { - info = append(info, yaml.MapItem{Key: "minimum", Value: m.Minimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForFloat(m.Minimum)) } if m.ExclusiveMinimum != false { - info = append(info, yaml.MapItem{Key: "exclusiveMinimum", Value: m.ExclusiveMinimum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("exclusiveMinimum")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.ExclusiveMinimum)) } if m.MaxLength != 0 { - info = append(info, yaml.MapItem{Key: "maxLength", Value: m.MaxLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxLength)) } if m.MinLength != 0 { - info = append(info, yaml.MapItem{Key: "minLength", Value: m.MinLength}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minLength")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinLength)) } if m.Pattern != "" { - info = append(info, yaml.MapItem{Key: "pattern", Value: m.Pattern}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("pattern")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Pattern)) } if m.MaxItems != 0 { - info = append(info, yaml.MapItem{Key: "maxItems", Value: m.MaxItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxItems)) } if m.MinItems != 0 { - info = append(info, yaml.MapItem{Key: "minItems", Value: m.MinItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinItems)) } if m.UniqueItems != false { - info = append(info, yaml.MapItem{Key: "uniqueItems", Value: m.UniqueItems}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("uniqueItems")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.UniqueItems)) } if m.MaxProperties != 0 { - info = append(info, yaml.MapItem{Key: "maxProperties", Value: m.MaxProperties}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("maxProperties")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MaxProperties)) } if m.MinProperties != 0 { - info = append(info, yaml.MapItem{Key: "minProperties", Value: m.MinProperties}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("minProperties")) + info.Content = append(info.Content, compiler.NewScalarNodeForInt(m.MinProperties)) } if len(m.Required) != 0 { - info = append(info, yaml.MapItem{Key: "required", Value: m.Required}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("required")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Required)) } if len(m.Enum) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Enum { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "enum", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, items) } // &{Name:enum Type:Any StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.Type != "" { - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) } if len(m.AllOf) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.AllOf { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "allOf", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("allOf")) + info.Content = append(info.Content, items) } // &{Name:allOf Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if len(m.OneOf) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.OneOf { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "oneOf", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("oneOf")) + info.Content = append(info.Content, items) } // &{Name:oneOf Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if len(m.AnyOf) != 0 { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.AnyOf { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "anyOf", Value: items}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("anyOf")) + info.Content = append(info.Content, items) } // &{Name:anyOf Type:SchemaOrReference StringEnumValues:[] MapType: Repeated:true Pattern: Implicit:false Description:} if m.Not != nil { - info = append(info, yaml.MapItem{Key: "not", Value: m.Not.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("not")) + info.Content = append(info.Content, m.Not.ToRawInfo()) } // &{Name:not Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Items != nil { - items := make([]interface{}, 0) + items := compiler.NewSequenceNode() for _, item := range m.Items.SchemaOrReference { - items = append(items, item.ToRawInfo()) + items.Content = append(items.Content, item.ToRawInfo()) } - info = append(info, yaml.MapItem{Key: "items", Value: items[0]}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) + info.Content = append(info.Content, items) } // &{Name:items Type:ItemsItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Properties != nil { - info = append(info, yaml.MapItem{Key: "properties", Value: m.Properties.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("properties")) + info.Content = append(info.Content, m.Properties.ToRawInfo()) } // &{Name:properties Type:Properties StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.AdditionalProperties != nil { - info = append(info, yaml.MapItem{Key: "additionalProperties", Value: m.AdditionalProperties.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("additionalProperties")) + info.Content = append(info.Content, m.AdditionalProperties.ToRawInfo()) } // &{Name:additionalProperties Type:AdditionalPropertiesItem StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Default != nil { - info = append(info, yaml.MapItem{Key: "default", Value: m.Default.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, m.Default.ToRawInfo()) } // &{Name:default Type:DefaultType StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Format != "" { - info = append(info, yaml.MapItem{Key: "format", Value: m.Format}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("format")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Format)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8215,7 +8377,7 @@ func (m *Schema) ToRawInfo() interface{} { } // ToRawInfo returns a description of SchemaOrReference suitable for JSON or YAML export. -func (m *SchemaOrReference) ToRawInfo() interface{} { +func (m *SchemaOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // SchemaOrReference // {Name:schema Type:Schema StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -8232,14 +8394,15 @@ func (m *SchemaOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of SchemasOrReferences suitable for JSON or YAML export. -func (m *SchemasOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *SchemasOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedSchemaOrReference StringEnumValues:[] MapType:SchemaOrReference Repeated:true Pattern: Implicit:true Description:} @@ -8247,14 +8410,15 @@ func (m *SchemasOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of SecurityRequirement suitable for JSON or YAML export. -func (m *SecurityRequirement) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *SecurityRequirement) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedStringArray StringEnumValues:[] MapType:StringArray Repeated:true Pattern: Implicit:true Description:} @@ -8262,38 +8426,47 @@ func (m *SecurityRequirement) ToRawInfo() interface{} { } // ToRawInfo returns a description of SecurityScheme suitable for JSON or YAML export. -func (m *SecurityScheme) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *SecurityScheme) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "type", Value: m.Type}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("type")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Type)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.In != "" { - info = append(info, yaml.MapItem{Key: "in", Value: m.In}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("in")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.In)) } if m.Scheme != "" { - info = append(info, yaml.MapItem{Key: "scheme", Value: m.Scheme}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("scheme")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Scheme)) } if m.BearerFormat != "" { - info = append(info, yaml.MapItem{Key: "bearerFormat", Value: m.BearerFormat}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("bearerFormat")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.BearerFormat)) } if m.Flows != nil { - info = append(info, yaml.MapItem{Key: "flows", Value: m.Flows.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("flows")) + info.Content = append(info.Content, m.Flows.ToRawInfo()) } // &{Name:flows Type:OauthFlows StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.OpenIdConnectUrl != "" { - info = append(info, yaml.MapItem{Key: "openIdConnectUrl", Value: m.OpenIdConnectUrl}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("openIdConnectUrl")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.OpenIdConnectUrl)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8301,7 +8474,7 @@ func (m *SecurityScheme) ToRawInfo() interface{} { } // ToRawInfo returns a description of SecuritySchemeOrReference suitable for JSON or YAML export. -func (m *SecuritySchemeOrReference) ToRawInfo() interface{} { +func (m *SecuritySchemeOrReference) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // SecuritySchemeOrReference // {Name:securityScheme Type:SecurityScheme StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} @@ -8318,14 +8491,15 @@ func (m *SecuritySchemeOrReference) ToRawInfo() interface{} { } // ToRawInfo returns a description of SecuritySchemesOrReferences suitable for JSON or YAML export. -func (m *SecuritySchemesOrReferences) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *SecuritySchemesOrReferences) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedSecuritySchemeOrReference StringEnumValues:[] MapType:SecuritySchemeOrReference Repeated:true Pattern: Implicit:true Description:} @@ -8333,23 +8507,27 @@ func (m *SecuritySchemesOrReferences) ToRawInfo() interface{} { } // ToRawInfo returns a description of Server suitable for JSON or YAML export. -func (m *Server) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Server) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "url", Value: m.Url}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("url")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Url)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.Variables != nil { - info = append(info, yaml.MapItem{Key: "variables", Value: m.Variables.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("variables")) + info.Content = append(info.Content, m.Variables.ToRawInfo()) } // &{Name:variables Type:ServerVariables StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8357,22 +8535,26 @@ func (m *Server) ToRawInfo() interface{} { } // ToRawInfo returns a description of ServerVariable suitable for JSON or YAML export. -func (m *ServerVariable) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ServerVariable) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if len(m.Enum) != 0 { - info = append(info, yaml.MapItem{Key: "enum", Value: m.Enum}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("enum")) + info.Content = append(info.Content, compiler.NewSequenceNodeForStringArray(m.Enum)) } // always include this required field. - info = append(info, yaml.MapItem{Key: "default", Value: m.Default}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("default")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Default)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8380,14 +8562,15 @@ func (m *ServerVariable) ToRawInfo() interface{} { } // ToRawInfo returns a description of ServerVariables suitable for JSON or YAML export. -func (m *ServerVariables) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *ServerVariables) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.AdditionalProperties != nil { for _, item := range m.AdditionalProperties { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:additionalProperties Type:NamedServerVariable StringEnumValues:[] MapType:ServerVariable Repeated:true Pattern: Implicit:true Description:} @@ -8395,32 +8578,32 @@ func (m *ServerVariables) ToRawInfo() interface{} { } // ToRawInfo returns a description of SpecificationExtension suitable for JSON or YAML export. -func (m *SpecificationExtension) ToRawInfo() interface{} { +func (m *SpecificationExtension) ToRawInfo() *yaml.Node { // ONE OF WRAPPER // SpecificationExtension // {Name:number Type:float StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if v0, ok := m.GetOneof().(*SpecificationExtension_Number); ok { - return v0.Number + return compiler.NewScalarNodeForFloat(v0.Number) } // {Name:boolean Type:bool StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if v1, ok := m.GetOneof().(*SpecificationExtension_Boolean); ok { - return v1.Boolean + return compiler.NewScalarNodeForBool(v1.Boolean) } // {Name:string Type:string StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if v2, ok := m.GetOneof().(*SpecificationExtension_String_); ok { - return v2.String_ + return compiler.NewScalarNodeForString(v2.String_) } return nil } // ToRawInfo returns a description of StringArray suitable for JSON or YAML export. -func (m *StringArray) ToRawInfo() interface{} { - return m.Value +func (m *StringArray) ToRawInfo() *yaml.Node { + return compiler.NewSequenceNodeForStringArray(m.Value) } // ToRawInfo returns a description of Strings suitable for JSON or YAML export. -func (m *Strings) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Strings) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } @@ -8429,23 +8612,27 @@ func (m *Strings) ToRawInfo() interface{} { } // ToRawInfo returns a description of Tag suitable for JSON or YAML export. -func (m *Tag) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Tag) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } // always include this required field. - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) if m.Description != "" { - info = append(info, yaml.MapItem{Key: "description", Value: m.Description}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("description")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Description)) } if m.ExternalDocs != nil { - info = append(info, yaml.MapItem{Key: "externalDocs", Value: m.ExternalDocs.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("externalDocs")) + info.Content = append(info.Content, m.ExternalDocs.ToRawInfo()) } // &{Name:externalDocs Type:ExternalDocs StringEnumValues:[] MapType: Repeated:false Pattern: Implicit:false Description:} if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} @@ -8453,29 +8640,35 @@ func (m *Tag) ToRawInfo() interface{} { } // ToRawInfo returns a description of Xml suitable for JSON or YAML export. -func (m *Xml) ToRawInfo() interface{} { - info := yaml.MapSlice{} +func (m *Xml) ToRawInfo() *yaml.Node { + info := compiler.NewMappingNode() if m == nil { return info } if m.Name != "" { - info = append(info, yaml.MapItem{Key: "name", Value: m.Name}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("name")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Name)) } if m.Namespace != "" { - info = append(info, yaml.MapItem{Key: "namespace", Value: m.Namespace}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("namespace")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Namespace)) } if m.Prefix != "" { - info = append(info, yaml.MapItem{Key: "prefix", Value: m.Prefix}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("prefix")) + info.Content = append(info.Content, compiler.NewScalarNodeForString(m.Prefix)) } if m.Attribute != false { - info = append(info, yaml.MapItem{Key: "attribute", Value: m.Attribute}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("attribute")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Attribute)) } if m.Wrapped != false { - info = append(info, yaml.MapItem{Key: "wrapped", Value: m.Wrapped}) + info.Content = append(info.Content, compiler.NewScalarNodeForString("wrapped")) + info.Content = append(info.Content, compiler.NewScalarNodeForBool(m.Wrapped)) } if m.SpecificationExtension != nil { for _, item := range m.SpecificationExtension { - info = append(info, yaml.MapItem{Key: item.Name, Value: item.Value.ToRawInfo()}) + info.Content = append(info.Content, compiler.NewScalarNodeForString(item.Name)) + info.Content = append(info.Content, item.Value.ToRawInfo()) } } // &{Name:SpecificationExtension Type:NamedAny StringEnumValues:[] MapType:Any Repeated:true Pattern:^x- Implicit:true Description:} diff --git a/openapiv3/OpenAPIv3.pb.go b/openapiv3/OpenAPIv3.pb.go index 7b80d987..0dfc9909 100644 --- a/openapiv3/OpenAPIv3.pb.go +++ b/openapiv3/OpenAPIv3.pb.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -1628,8 +1628,8 @@ type Info struct { Contact *Contact `protobuf:"bytes,4,opt,name=contact,proto3" json:"contact,omitempty"` License *License `protobuf:"bytes,5,opt,name=license,proto3" json:"license,omitempty"` Version string `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"` - SpecificationExtension []*NamedAny `protobuf:"bytes,7,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` - Summary string `protobuf:"bytes,8,opt,name=summary,proto3" json:"summary,omitempty"` + Summary string `protobuf:"bytes,7,opt,name=summary,proto3" json:"summary,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,8,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` } func (x *Info) Reset() { @@ -1706,18 +1706,18 @@ func (x *Info) GetVersion() string { return "" } -func (x *Info) GetSpecificationExtension() []*NamedAny { +func (x *Info) GetSummary() string { if x != nil { - return x.SpecificationExtension + return x.Summary } - return nil + return "" } -func (x *Info) GetSummary() string { +func (x *Info) GetSpecificationExtension() []*NamedAny { if x != nil { - return x.Summary + return x.SpecificationExtension } - return "" + return nil } type ItemsItem struct { @@ -6076,13 +6076,13 @@ var file_openapiv3_OpenAPIv3_proto_rawDesc = []byte{ 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, - 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, - 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x5a, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, + 0x18, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, + 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, + 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, + 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x5a, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x4d, 0x0a, 0x13, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, diff --git a/openapiv3/OpenAPIv3.proto b/openapiv3/OpenAPIv3.proto index f7024d22..734a7c3b 100644 --- a/openapiv3/OpenAPIv3.proto +++ b/openapiv3/OpenAPIv3.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -208,8 +208,8 @@ message Info { Contact contact = 4; License license = 5; string version = 6; - repeated NamedAny specification_extension = 7; - string summary = 8; + string summary = 7; + repeated NamedAny specification_extension = 8; } message ItemsItem { From bc8994b95dfc13dba429c7fa233b6df3f8a1968e Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Sat, 11 Jul 2020 10:31:58 -0700 Subject: [PATCH 05/13] passing most of the core tests --- apps/petstore-builder/builder_test.go | 2 +- compiler/helpers.go | 12 + generate-gnostic/generate-compiler.go | 17 +- gnostic_test.go | 2 +- jsonwriter/writer.go | 152 ++++---- lib/gnostic.go | 4 + openapiv2/OpenAPIv2.go | 478 +++++++++++++------------- openapiv3/OpenAPIv3.go | 229 ++++++------ 8 files changed, 445 insertions(+), 451 deletions(-) diff --git a/apps/petstore-builder/builder_test.go b/apps/petstore-builder/builder_test.go index 31538958..ffc4046e 100644 --- a/apps/petstore-builder/builder_test.go +++ b/apps/petstore-builder/builder_test.go @@ -57,7 +57,7 @@ func testBuilder(version string, t *testing.T) { // Verify that the generated text matches our reference. err = exec.Command("diff", textFile, textReference).Run() if err != nil { - t.Logf("Diff failed: %+v", err) + t.Logf("Diff %s vs %s failed: %+v", textFile, textReference, err) t.FailNow() } diff --git a/compiler/helpers.go b/compiler/helpers.go index f18a35b1..ae967ba1 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -373,3 +373,15 @@ func Description(item interface{}) string { } return fmt.Sprintf("%+v", item) } + +// Display returns a description of a node for use in error messages. +func Display(node *yaml.Node) string { + switch node.Kind { + case yaml.ScalarNode: + switch node.Tag { + case "!!str": + return fmt.Sprintf("%s (string)", node.Value) + } + } + return fmt.Sprintf("%+v (%T)", node, node) +} diff --git a/generate-gnostic/generate-compiler.go b/generate-gnostic/generate-compiler.go index d3a85ab3..b2072768 100644 --- a/generate-gnostic/generate-compiler.go +++ b/generate-gnostic/generate-compiler.go @@ -463,7 +463,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" if ok {") code.Print(" x.%s = compiler.StringArrayForSequenceNode(v)", fieldName) code.Print(" } else {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) + code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print("}") @@ -480,7 +480,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } stringArrayLiteral += "}" code.Print("if ok && !compiler.StringArrayContainsValues(%s, x.%s) {", stringArrayLiteral, fieldName) - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v\", v%d)", propertyName, fieldNumber) + code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print("}") } @@ -491,7 +491,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print("if (v%d != nil) {", fieldNumber) code.Print(" x.%s, ok = compiler.StringForScalarNode(v%d)", fieldName, fieldNumber) code.Print(" if !ok {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) + code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print(" }") @@ -509,7 +509,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st stringArrayLiteral += "}" code.Print("if ok && !compiler.StringArrayContainsValue(%s, x.%s) {", stringArrayLiteral, fieldName) - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) + code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print("}") } @@ -522,7 +522,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" if ok {") code.Print(" x.%s = v", fieldName) code.Print(" } else {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) + code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print(" }") code.Print("}") @@ -533,7 +533,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" if ok {") code.Print(" x.%s = int64(t)", fieldName) code.Print(" } else {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) + code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print(" }") code.Print("}") @@ -550,7 +550,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print("if (v%d != nil) {", fieldNumber) code.Print(" x.%s, ok = compiler.BoolForScalarNode(v%d)", fieldName, fieldNumber) code.Print(" if !ok {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%+v (%%T)\", v%d, v%d)", propertyName, fieldNumber, fieldNumber) + code.Print(" message := fmt.Sprintf(\"has unexpected value for %s: %%s\", compiler.Display(v%d))", propertyName, fieldNumber) code.Print(" errors = append(errors, compiler.NewError(context, message))") code.Print(" }") code.Print("}") @@ -871,6 +871,9 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam } code.Print(" items.Content = append(items.Content, item.ToRawInfo())") code.Print("}") + + code.Print("if len(items.Content) == 1 {items = items.Content[0]}") + code.Print("info.Content = append(info.Content, compiler.NewScalarNodeForString(\"items\"))") code.Print("info.Content = append(info.Content, items)") } else { diff --git a/gnostic_test.go b/gnostic_test.go index bc9cbec0..349bd19c 100644 --- a/gnostic_test.go +++ b/gnostic_test.go @@ -195,7 +195,7 @@ func TestJSONOutput(t *testing.T) { // Verify that both models have the same internal representation. err = exec.Command("diff", textFile, textFile2).Run() if err != nil { - t.Logf("Diff failed: %+v", err) + t.Logf("Diff failed (%s vs %s): %+v", textFile, textFile2, err) t.FailNow() } else { // if the test succeeded, clean up diff --git a/jsonwriter/writer.go b/jsonwriter/writer.go index c070cd68..5b5f2238 100644 --- a/jsonwriter/writer.go +++ b/jsonwriter/writer.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) const indentation = " " @@ -44,109 +44,73 @@ func (w *writer) writeString(s string) { w.b.Write([]byte(s)) } -func (w *writer) writeMap(info interface{}, indent string) { - w.writeString("{\n") - innerIndent := indent + indentation - switch pairs := info.(type) { - case yaml.MapSlice: - for i, pair := range pairs { - // first print the key - w.writeString(fmt.Sprintf("%s\"%+v\": ", innerIndent, pair.Key)) - // then the value - switch value := pair.Value.(type) { - case string: - w.writeString("\"") - w.writeString(escape(value)) - w.writeString("\"") - case bool: - if value { - w.writeString("true") - } else { - w.writeString("false") - } - case []interface{}: - w.writeArray(value, innerIndent) - case yaml.MapSlice: - w.writeMap(value, innerIndent) - case int: - w.writeString(fmt.Sprintf("%d", value)) - case int64: - w.writeString(fmt.Sprintf("%d", value)) - case []string: - w.writeStringArray(value, innerIndent) - case float64: - w.writeString(fmt.Sprintf("%f", value)) - case []yaml.MapSlice: - w.writeMapSliceArray(value, innerIndent) - default: - w.writeString(fmt.Sprintf("???MapItem(%+v, %T)", value, value)) - } - if i < len(pairs)-1 { - w.writeString(",") - } - w.writeString("\n") - } - default: - // t is some other type that we didn't name. +func (w *writer) writeMap(node *yaml.Node, indent string) { + if node.Kind != yaml.MappingNode { + w.writeString(fmt.Sprintf("invalid node for map: %+v", node)) + return } - w.writeString(indent) - w.writeString("}") -} - -func (w *writer) writeArray(array []interface{}, indent string) { - w.writeString("[\n") + w.writeString("{\n") innerIndent := indent + indentation - for i, item := range array { - w.writeString(innerIndent) - switch item := item.(type) { - case string: - w.writeString("\"") - w.writeString(item) - w.writeString("\"") - case bool: - if item { - w.writeString("true") - } else { - w.writeString("false") - } - case yaml.MapSlice: - w.writeMap(item, innerIndent) - default: - w.writeString(fmt.Sprintf("???ArrayItem(%+v)", item)) + for i := 0; i < len(node.Content); i += 2 { + // first print the key + key := node.Content[i].Value + w.writeString(fmt.Sprintf("%s\"%+v\": ", innerIndent, key)) + // then the value + value := node.Content[i+1] + switch value.Kind { + case yaml.MappingNode: + w.writeMap(value, innerIndent) + case yaml.SequenceNode: + w.writeSequence(value, innerIndent) + case yaml.ScalarNode: + w.writeScalar(value, innerIndent) } - if i < len(array)-1 { + if i < len(node.Content)-2 { w.writeString(",") } w.writeString("\n") } w.writeString(indent) - w.writeString("]") + w.writeString("}") } -func (w *writer) writeStringArray(array []string, indent string) { - w.writeString("[\n") - innerIndent := indent + indentation - for i, item := range array { - w.writeString(innerIndent) +func (w *writer) writeScalar(node *yaml.Node, indent string) { + if node.Kind != yaml.ScalarNode { + w.writeString(fmt.Sprintf("invalid node for scalar: %+v", node)) + return + } + switch node.Tag { + case "!!str": w.writeString("\"") - w.writeString(escape(item)) + w.writeString(escape(node.Value)) w.writeString("\"") - if i < len(array)-1 { - w.writeString(",") - } - w.writeString("\n") + case "!!int": + w.writeString(node.Value) + case "!!float": + w.writeString(node.Value) + case "!!bool": + w.writeString(node.Value) } - w.writeString(indent) - w.writeString("]") } -func (w *writer) writeMapSliceArray(array []yaml.MapSlice, indent string) { +func (w *writer) writeSequence(node *yaml.Node, indent string) { + if node.Kind != yaml.SequenceNode { + w.writeString(fmt.Sprintf("invalid node for sequence: %+v", node)) + return + } w.writeString("[\n") innerIndent := indent + indentation - for i, item := range array { + for i, value := range node.Content { w.writeString(innerIndent) - w.writeMap(item, innerIndent) - if i < len(array)-1 { + switch value.Kind { + case yaml.MappingNode: + w.writeMap(value, innerIndent) + case yaml.SequenceNode: + w.writeSequence(value, innerIndent) + case yaml.ScalarNode: + w.writeScalar(value, innerIndent) + } + if i < len(node.Content)-1 { w.writeString(",") } w.writeString("\n") @@ -156,13 +120,19 @@ func (w *writer) writeMapSliceArray(array []yaml.MapSlice, indent string) { } // Marshal writes a yaml.MapSlice as JSON -func Marshal(in interface{}) (out []byte, err error) { +func Marshal(in *yaml.Node) (out []byte, err error) { var w writer - m, ok := in.(yaml.MapSlice) - if !ok { + + switch in.Kind { + case yaml.DocumentNode: + w.writeMap(in.Content[0], "") + w.writeString("\n") + case yaml.MappingNode: + w.writeMap(in, "") + w.writeString("\n") + default: return nil, errors.New("invalid type passed to Marshal") } - w.writeMap(m, "") - w.writeString("\n") + return w.bytes(), err } diff --git a/lib/gnostic.go b/lib/gnostic.go index 3dca0169..f9645971 100644 --- a/lib/gnostic.go +++ b/lib/gnostic.go @@ -538,6 +538,10 @@ func (g *Gnostic) writeJSONYAMLOutput(message proto.Message) { if g.jsonOutputPath != "" { var bytes []byte if rawInfo != nil { + rawInfo := &yaml.Node{ + Kind: yaml.DocumentNode, + Content: []*yaml.Node{rawInfo}, + } bytes, _ = jsonwriter.Marshal(rawInfo) if err != nil { fmt.Fprintf(os.Stderr, "Error generating json output %s\n", err.Error()) diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index 0e93c8c7..b1996c74 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -18,11 +18,10 @@ package openapi_v2 import ( "fmt" - "regexp" - "strings" - "github.com/googleapis/gnostic/compiler" "gopkg.in/yaml.v3" + "regexp" + "strings" ) // Version returns the package name (and OpenAPI version). @@ -98,13 +97,13 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [apiKey] if ok && !compiler.StringArrayContainsValue([]string{"apiKey"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -113,7 +112,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri if v2 != nil { x.Name, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -122,13 +121,13 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri if v3 != nil { x.In, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [header query] if ok && !compiler.StringArrayContainsValue([]string{"header", "query"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -137,7 +136,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri if v4 != nil { x.Description, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -203,13 +202,13 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [basic] if ok && !compiler.StringArrayContainsValue([]string{"basic"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -218,7 +217,7 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( if v2 != nil { x.Description, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -284,7 +283,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter if v1 != nil { x.Description, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -293,7 +292,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter if v2 != nil { x.Name, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -302,13 +301,13 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter if v3 != nil { x.In, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [body] if ok && !compiler.StringArrayContainsValue([]string{"body"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -317,7 +316,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter if v4 != nil { x.Required, ok = compiler.BoolForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -386,7 +385,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -395,7 +394,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { if v2 != nil { x.Url, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -404,7 +403,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { if v3 != nil { x.Email, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for email: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for email: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -542,13 +541,13 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v1 != nil { x.Swagger, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for swagger: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for swagger: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [2.0] if ok && !compiler.StringArrayContainsValue([]string{"2.0"}, x.Swagger) { - message := fmt.Sprintf("has unexpected value for swagger: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for swagger: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -566,7 +565,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v3 != nil { x.Host, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for host: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for host: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -575,7 +574,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v4 != nil { x.BasePath, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for basePath: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for basePath: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -586,13 +585,13 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if ok { x.Schemes = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for schemes: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for schemes: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [http https ws wss] if ok && !compiler.StringArrayContainsValues([]string{"http", "https", "ws", "wss"}, x.Schemes) { - message := fmt.Sprintf("has unexpected value for schemes: %+v", v5) + message := fmt.Sprintf("has unexpected value for schemes: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -603,7 +602,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if ok { x.Consumes = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for consumes: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for consumes: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -614,7 +613,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if ok { x.Produces = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for produces: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for produces: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -808,7 +807,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, if v1 != nil { x.Description, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -817,7 +816,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, if v2 != nil { x.Url, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -883,7 +882,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro if v1 != nil { x.Format, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -892,7 +891,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro if v2 != nil { x.Title, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -901,7 +900,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -921,7 +920,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro if ok { x.Required = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -930,13 +929,13 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro if v6 != nil { x.Type, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [file] if ok && !compiler.StringArrayContainsValue([]string{"file"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -945,7 +944,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro if v7 != nil { x.ReadOnly, ok = compiler.BoolForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for readOnly: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1023,7 +1022,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v1 != nil { x.Required, ok = compiler.BoolForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1032,13 +1031,13 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v2 != nil { x.In, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [formData] if ok && !compiler.StringArrayContainsValue([]string{"formData"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1047,7 +1046,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1056,7 +1055,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v4 != nil { x.Name, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1065,7 +1064,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v5 != nil { x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for allowEmptyValue: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1074,13 +1073,13 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v6 != nil { x.Type, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [string number boolean integer array file] if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array", "file"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1089,7 +1088,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v7 != nil { x.Format, ok = compiler.StringForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1107,13 +1106,13 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v9 != nil { x.CollectionFormat, ok = compiler.StringForScalarNode(v9) if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [csv ssv tsv pipes multi] if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes", "multi"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1133,7 +1132,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if ok { x.Maximum = v } else { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1142,7 +1141,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v12 != nil { x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v12) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1153,7 +1152,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if ok { x.Minimum = v } else { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1162,7 +1161,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v14 != nil { x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v14) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1173,7 +1172,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if ok { x.MaxLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1184,7 +1183,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if ok { x.MinLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v16, v16) + message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v16)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1193,7 +1192,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v17 != nil { x.Pattern, ok = compiler.StringForScalarNode(v17) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1204,7 +1203,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if ok { x.MaxItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v18, v18) + message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v18)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1215,7 +1214,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if ok { x.MinItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v19, v19) + message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v19)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1224,7 +1223,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if v20 != nil { x.UniqueItems, ok = compiler.BoolForScalarNode(v20) if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20) + message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v20)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1251,7 +1250,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if ok { x.MultipleOf = v } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v22, v22) + message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v22)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1317,13 +1316,13 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [string number integer boolean array] if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "integer", "boolean", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1332,7 +1331,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v2 != nil { x.Format, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1350,13 +1349,13 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v4 != nil { x.CollectionFormat, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [csv ssv tsv pipes] if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1376,7 +1375,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if ok { x.Maximum = v } else { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1385,7 +1384,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v7 != nil { x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1396,7 +1395,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if ok { x.Minimum = v } else { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1405,7 +1404,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v9 != nil { x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v9) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1416,7 +1415,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if ok { x.MaxLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1427,7 +1426,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if ok { x.MinLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1436,7 +1435,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v12 != nil { x.Pattern, ok = compiler.StringForScalarNode(v12) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1447,7 +1446,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if ok { x.MaxItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1458,7 +1457,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if ok { x.MinItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1467,7 +1466,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v15 != nil { x.UniqueItems, ok = compiler.BoolForScalarNode(v15) if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1494,7 +1493,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if ok { x.MultipleOf = v } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1503,7 +1502,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v18 != nil { x.Description, ok = compiler.StringForScalarNode(v18) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v18, v18) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v18)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1563,7 +1562,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v1 != nil { x.Required, ok = compiler.BoolForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1572,13 +1571,13 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v2 != nil { x.In, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [header] if ok && !compiler.StringArrayContainsValue([]string{"header"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1587,7 +1586,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1596,7 +1595,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v4 != nil { x.Name, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1605,13 +1604,13 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v5 != nil { x.Type, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [string number boolean integer array] if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1620,7 +1619,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v6 != nil { x.Format, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1638,13 +1637,13 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v8 != nil { x.CollectionFormat, ok = compiler.StringForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [csv ssv tsv pipes] if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1664,7 +1663,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if ok { x.Maximum = v } else { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1673,7 +1672,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v11 != nil { x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v11) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1684,7 +1683,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if ok { x.Minimum = v } else { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1693,7 +1692,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v13 != nil { x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v13) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1704,7 +1703,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if ok { x.MaxLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1715,7 +1714,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if ok { x.MinLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1724,7 +1723,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v16 != nil { x.Pattern, ok = compiler.StringForScalarNode(v16) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v16)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1735,7 +1734,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if ok { x.MaxItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1746,7 +1745,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if ok { x.MinItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v18, v18) + message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v18)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1755,7 +1754,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if v19 != nil { x.UniqueItems, ok = compiler.BoolForScalarNode(v19) if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19) + message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v19)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1782,7 +1781,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if ok { x.MultipleOf = v } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v21, v21) + message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v21)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1878,7 +1877,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v1 != nil { x.Title, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1887,7 +1886,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v2 != nil { x.Version, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for version: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1896,7 +1895,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1905,7 +1904,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v4 != nil { x.TermsOfService, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for termsOfService: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for termsOfService: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2001,7 +2000,7 @@ func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference if v1 != nil { x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2010,7 +2009,7 @@ func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference if v2 != nil { x.Description, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2045,7 +2044,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2054,7 +2053,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { if v2 != nil { x.Url, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2114,7 +2113,7 @@ func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2152,7 +2151,7 @@ func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, er if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2190,7 +2189,7 @@ func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParamet if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2228,7 +2227,7 @@ func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2266,7 +2265,7 @@ func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2304,7 +2303,7 @@ func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedRes if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2342,7 +2341,7 @@ func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, er if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2380,7 +2379,7 @@ func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2418,7 +2417,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2427,7 +2426,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er if v2 != nil { x.Value, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for value: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for value: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2456,7 +2455,7 @@ func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStrin if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2568,13 +2567,13 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [oauth2] if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2583,13 +2582,13 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa if v2 != nil { x.Flow, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [accessCode] if ok && !compiler.StringArrayContainsValue([]string{"accessCode"}, x.Flow) { - message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2607,7 +2606,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa if v4 != nil { x.AuthorizationUrl, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for authorizationUrl: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2616,7 +2615,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa if v5 != nil { x.TokenUrl, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for tokenUrl: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2625,7 +2624,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa if v6 != nil { x.Description, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2691,13 +2690,13 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [oauth2] if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2706,13 +2705,13 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O if v2 != nil { x.Flow, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [application] if ok && !compiler.StringArrayContainsValue([]string{"application"}, x.Flow) { - message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2730,7 +2729,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O if v4 != nil { x.TokenUrl, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for tokenUrl: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2739,7 +2738,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O if v5 != nil { x.Description, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2805,13 +2804,13 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [oauth2] if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2820,13 +2819,13 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut if v2 != nil { x.Flow, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [implicit] if ok && !compiler.StringArrayContainsValue([]string{"implicit"}, x.Flow) { - message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2844,7 +2843,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut if v4 != nil { x.AuthorizationUrl, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for authorizationUrl: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2853,7 +2852,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut if v5 != nil { x.Description, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2919,13 +2918,13 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [oauth2] if ok && !compiler.StringArrayContainsValue([]string{"oauth2"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2934,13 +2933,13 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut if v2 != nil { x.Flow, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [password] if ok && !compiler.StringArrayContainsValue([]string{"password"}, x.Flow) { - message := fmt.Sprintf("has unexpected value for flow: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for flow: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2958,7 +2957,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut if v4 != nil { x.TokenUrl, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for tokenUrl: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2967,7 +2966,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut if v5 != nil { x.Description, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3061,7 +3060,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if ok { x.Tags = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for tags: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for tags: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3070,7 +3069,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v2 != nil { x.Summary, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for summary: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3079,7 +3078,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3097,7 +3096,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v5 != nil { x.OperationId, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for operationId: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3108,7 +3107,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if ok { x.Produces = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for produces: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for produces: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3119,7 +3118,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if ok { x.Consumes = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for consumes: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for consumes: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3155,13 +3154,13 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if ok { x.Schemes = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for schemes: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for schemes: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [http https ws wss] if ok && !compiler.StringArrayContainsValues([]string{"http", "https", "ws", "wss"}, x.Schemes) { - message := fmt.Sprintf("has unexpected value for schemes: %+v", v10) + message := fmt.Sprintf("has unexpected value for schemes: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3170,7 +3169,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v11 != nil { x.Deprecated, ok = compiler.BoolForScalarNode(v11) if !ok { - message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for deprecated: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3356,7 +3355,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if v1 != nil { x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3501,7 +3500,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v1 != nil { x.Required, ok = compiler.BoolForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3510,13 +3509,13 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v2 != nil { x.In, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [path] if ok && !compiler.StringArrayContainsValue([]string{"path"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3525,7 +3524,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3534,7 +3533,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v4 != nil { x.Name, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3543,13 +3542,13 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v5 != nil { x.Type, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [string number boolean integer array] if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3558,7 +3557,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v6 != nil { x.Format, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3576,13 +3575,13 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v8 != nil { x.CollectionFormat, ok = compiler.StringForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [csv ssv tsv pipes] if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3602,7 +3601,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if ok { x.Maximum = v } else { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3611,7 +3610,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v11 != nil { x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v11) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3622,7 +3621,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if ok { x.Minimum = v } else { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3631,7 +3630,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v13 != nil { x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v13) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3642,7 +3641,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if ok { x.MaxLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3653,7 +3652,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if ok { x.MinLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3662,7 +3661,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v16 != nil { x.Pattern, ok = compiler.StringForScalarNode(v16) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v16, v16) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v16)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3673,7 +3672,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if ok { x.MaxItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3684,7 +3683,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if ok { x.MinItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v18, v18) + message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v18)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3693,7 +3692,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if v19 != nil { x.UniqueItems, ok = compiler.BoolForScalarNode(v19) if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v19, v19) + message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v19)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3720,7 +3719,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if ok { x.MultipleOf = v } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v21, v21) + message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v21)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3850,13 +3849,13 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [string number integer boolean array] if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "integer", "boolean", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3865,7 +3864,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if v2 != nil { x.Format, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3883,13 +3882,13 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if v4 != nil { x.CollectionFormat, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [csv ssv tsv pipes] if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3909,7 +3908,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if ok { x.Maximum = v } else { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3918,7 +3917,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if v7 != nil { x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3929,7 +3928,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if ok { x.Minimum = v } else { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3938,7 +3937,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if v9 != nil { x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v9) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3949,7 +3948,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if ok { x.MaxLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3960,7 +3959,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if ok { x.MinLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3969,7 +3968,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if v12 != nil { x.Pattern, ok = compiler.StringForScalarNode(v12) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3980,7 +3979,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if ok { x.MaxItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3991,7 +3990,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if ok { x.MinItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4000,7 +3999,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if v15 != nil { x.UniqueItems, ok = compiler.BoolForScalarNode(v15) if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4027,7 +4026,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if ok { x.MultipleOf = v } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4117,7 +4116,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v1 != nil { x.Required, ok = compiler.BoolForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4126,13 +4125,13 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v2 != nil { x.In, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [query] if ok && !compiler.StringArrayContainsValue([]string{"query"}, x.In) { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4141,7 +4140,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4150,7 +4149,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v4 != nil { x.Name, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4159,7 +4158,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v5 != nil { x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for allowEmptyValue: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4168,13 +4167,13 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v6 != nil { x.Type, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [string number boolean integer array] if ok && !compiler.StringArrayContainsValue([]string{"string", "number", "boolean", "integer", "array"}, x.Type) { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4183,7 +4182,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v7 != nil { x.Format, ok = compiler.StringForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4201,13 +4200,13 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v9 != nil { x.CollectionFormat, ok = compiler.StringForScalarNode(v9) if !ok { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } // check for valid enum values // [csv ssv tsv pipes multi] if ok && !compiler.StringArrayContainsValue([]string{"csv", "ssv", "tsv", "pipes", "multi"}, x.CollectionFormat) { - message := fmt.Sprintf("has unexpected value for collectionFormat: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for collectionFormat: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4227,7 +4226,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if ok { x.Maximum = v } else { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4236,7 +4235,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v12 != nil { x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v12) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4247,7 +4246,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if ok { x.Minimum = v } else { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4256,7 +4255,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v14 != nil { x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v14) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4267,7 +4266,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if ok { x.MaxLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4278,7 +4277,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if ok { x.MinLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v16, v16) + message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v16)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4287,7 +4286,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v17 != nil { x.Pattern, ok = compiler.StringForScalarNode(v17) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4298,7 +4297,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if ok { x.MaxItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v18, v18) + message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v18)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4309,7 +4308,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if ok { x.MinItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v19, v19) + message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v19)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4318,7 +4317,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if v20 != nil { x.UniqueItems, ok = compiler.BoolForScalarNode(v20) if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20) + message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v20)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4345,7 +4344,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if ok { x.MultipleOf = v } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v22, v22) + message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v22)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4411,7 +4410,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { if v1 != nil { x.Description, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4638,7 +4637,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v1 != nil { x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4647,7 +4646,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v2 != nil { x.Format, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4656,7 +4655,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v3 != nil { x.Title, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4665,7 +4664,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v4 != nil { x.Description, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4685,7 +4684,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MultipleOf = v } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4696,7 +4695,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.Maximum = v } else { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4705,7 +4704,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v8 != nil { x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4716,7 +4715,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.Minimum = v } else { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4725,7 +4724,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v10 != nil { x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v10) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4736,7 +4735,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MaxLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4747,7 +4746,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MinLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4756,7 +4755,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v13 != nil { x.Pattern, ok = compiler.StringForScalarNode(v13) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4767,7 +4766,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MaxItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4778,7 +4777,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MinItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4787,7 +4786,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v16 != nil { x.UniqueItems, ok = compiler.BoolForScalarNode(v16) if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v16, v16) + message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v16)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4798,7 +4797,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MaxProperties = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxProperties: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for maxProperties: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4809,7 +4808,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MinProperties = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minProperties: %+v (%T)", v18, v18) + message := fmt.Sprintf("has unexpected value for minProperties: %s", compiler.Display(v18)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4820,7 +4819,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.Required = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v19, v19) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v19)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4897,7 +4896,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v26 != nil { x.Discriminator, ok = compiler.StringForScalarNode(v26) if !ok { - message := fmt.Sprintf("has unexpected value for discriminator: %+v (%T)", v26, v26) + message := fmt.Sprintf("has unexpected value for discriminator: %s", compiler.Display(v26)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4906,7 +4905,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v27 != nil { x.ReadOnly, ok = compiler.BoolForScalarNode(v27) if !ok { - message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v27, v27) + message := fmt.Sprintf("has unexpected value for readOnly: %s", compiler.Display(v27)) errors = append(errors, compiler.NewError(context, message)) } } @@ -5212,7 +5211,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -5221,7 +5220,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { if v2 != nil { x.Description, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -5360,7 +5359,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -5369,7 +5368,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v2 != nil { x.Namespace, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for namespace: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for namespace: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -5378,7 +5377,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v3 != nil { x.Prefix, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for prefix: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for prefix: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -5387,7 +5386,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v4 != nil { x.Attribute, ok = compiler.BoolForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for attribute: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for attribute: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -5396,7 +5395,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v5 != nil { x.Wrapped, ok = compiler.BoolForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for wrapped: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for wrapped: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -8648,6 +8647,9 @@ func (m *Schema) ToRawInfo() *yaml.Node { for _, item := range m.Items.Schema { items.Content = append(items.Content, item.ToRawInfo()) } + if len(items.Content) == 1 { + items = items.Content[0] + } info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) info.Content = append(info.Content, items) } diff --git a/openapiv3/OpenAPIv3.go b/openapiv3/OpenAPIv3.go index c7211131..c6424678 100644 --- a/openapiv3/OpenAPIv3.go +++ b/openapiv3/OpenAPIv3.go @@ -403,7 +403,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -412,7 +412,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { if v2 != nil { x.Url, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -421,7 +421,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { if v3 != nil { x.Email, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for email: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for email: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -522,7 +522,7 @@ func NewDiscriminator(in interface{}, context *compiler.Context) (*Discriminator if v1 != nil { x.PropertyName, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for propertyName: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for propertyName: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -597,7 +597,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v1 != nil { x.Openapi, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for openapi: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for openapi: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -741,7 +741,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { if v1 != nil { x.ContentType, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for contentType: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for contentType: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -759,7 +759,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { if v3 != nil { x.Style, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for style: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -768,7 +768,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { if v4 != nil { x.Explode, ok = compiler.BoolForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for explode: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -777,7 +777,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { if v5 != nil { x.AllowReserved, ok = compiler.BoolForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for allowReserved: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for allowReserved: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -867,7 +867,7 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { if v1 != nil { x.Summary, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for summary: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -876,7 +876,7 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { if v2 != nil { x.Description, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -894,7 +894,7 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { if v4 != nil { x.ExternalValue, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for externalValue: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for externalValue: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1072,7 +1072,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, if v1 != nil { x.Description, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1081,7 +1081,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, if v2 != nil { x.Url, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1141,7 +1141,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v1 != nil { x.Description, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1150,7 +1150,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v2 != nil { x.Required, ok = compiler.BoolForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1159,7 +1159,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v3 != nil { x.Deprecated, ok = compiler.BoolForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for deprecated: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1168,7 +1168,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v4 != nil { x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for allowEmptyValue: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1177,7 +1177,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v5 != nil { x.Style, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for style: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1186,7 +1186,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v6 != nil { x.Explode, ok = compiler.BoolForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for explode: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1195,7 +1195,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if v7 != nil { x.AllowReserved, ok = compiler.BoolForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for allowReserved: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for allowReserved: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1367,7 +1367,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v1 != nil { x.Title, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1376,7 +1376,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v2 != nil { x.Description, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1385,7 +1385,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v3 != nil { x.TermsOfService, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for termsOfService: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for termsOfService: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1412,7 +1412,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v6 != nil { x.Version, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for version: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1421,7 +1421,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if v7 != nil { x.Summary, ok = compiler.StringForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for summary: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1506,7 +1506,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1515,7 +1515,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { if v2 != nil { x.Url, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1575,7 +1575,7 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { if v1 != nil { x.OperationRef, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for operationRef: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for operationRef: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1584,7 +1584,7 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { if v2 != nil { x.OperationId, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for operationId: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1611,7 +1611,7 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { if v5 != nil { x.Description, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1867,7 +1867,7 @@ func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1905,7 +1905,7 @@ func NewNamedCallbackOrReference(in interface{}, context *compiler.Context) (*Na if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1943,7 +1943,7 @@ func NewNamedEncoding(in interface{}, context *compiler.Context) (*NamedEncoding if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1981,7 +1981,7 @@ func NewNamedExampleOrReference(in interface{}, context *compiler.Context) (*Nam if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2019,7 +2019,7 @@ func NewNamedHeaderOrReference(in interface{}, context *compiler.Context) (*Name if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2057,7 +2057,7 @@ func NewNamedLinkOrReference(in interface{}, context *compiler.Context) (*NamedL if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2095,7 +2095,7 @@ func NewNamedMediaType(in interface{}, context *compiler.Context) (*NamedMediaTy if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2133,7 +2133,7 @@ func NewNamedParameterOrReference(in interface{}, context *compiler.Context) (*N if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2171,7 +2171,7 @@ func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2209,7 +2209,7 @@ func NewNamedRequestBodyOrReference(in interface{}, context *compiler.Context) ( if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2247,7 +2247,7 @@ func NewNamedResponseOrReference(in interface{}, context *compiler.Context) (*Na if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2285,7 +2285,7 @@ func NewNamedSchemaOrReference(in interface{}, context *compiler.Context) (*Name if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2323,7 +2323,7 @@ func NewNamedSecuritySchemeOrReference(in interface{}, context *compiler.Context if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2361,7 +2361,7 @@ func NewNamedServerVariable(in interface{}, context *compiler.Context) (*NamedSe if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2399,7 +2399,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2408,7 +2408,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er if v2 != nil { x.Value, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for value: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for value: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2437,7 +2437,7 @@ func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStrin if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2475,7 +2475,7 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) if v1 != nil { x.AuthorizationUrl, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for authorizationUrl: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for authorizationUrl: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2484,7 +2484,7 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) if v2 != nil { x.TokenUrl, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for tokenUrl: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for tokenUrl: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2493,7 +2493,7 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) if v3 != nil { x.RefreshUrl, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for refreshUrl: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for refreshUrl: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2699,7 +2699,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if ok { x.Tags = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for tags: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for tags: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2708,7 +2708,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v2 != nil { x.Summary, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for summary: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2717,7 +2717,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2735,7 +2735,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v5 != nil { x.OperationId, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for operationId: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for operationId: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2787,7 +2787,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if v10 != nil { x.Deprecated, ok = compiler.BoolForScalarNode(v10) if !ok { - message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for deprecated: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2885,7 +2885,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2894,7 +2894,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v2 != nil { x.In, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2903,7 +2903,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2912,7 +2912,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v4 != nil { x.Required, ok = compiler.BoolForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2921,7 +2921,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v5 != nil { x.Deprecated, ok = compiler.BoolForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for deprecated: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2930,7 +2930,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v6 != nil { x.AllowEmptyValue, ok = compiler.BoolForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for allowEmptyValue: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for allowEmptyValue: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2939,7 +2939,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v7 != nil { x.Style, ok = compiler.StringForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for style: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for style: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2948,7 +2948,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v8 != nil { x.Explode, ok = compiler.BoolForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for explode: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for explode: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2957,7 +2957,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v9 != nil { x.AllowReserved, ok = compiler.BoolForScalarNode(v9) if !ok { - message := fmt.Sprintf("has unexpected value for allowReserved: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for allowReserved: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3123,7 +3123,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if v1 != nil { x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3132,7 +3132,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if v2 != nil { x.Summary, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for summary: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for summary: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3141,7 +3141,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3404,7 +3404,7 @@ func NewReference(in interface{}, context *compiler.Context) (*Reference, error) if v1 != nil { x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3469,7 +3469,7 @@ func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, er if v1 != nil { x.Description, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3487,7 +3487,7 @@ func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, er if v3 != nil { x.Required, ok = compiler.BoolForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3593,7 +3593,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { if v1 != nil { x.Description, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3829,7 +3829,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v1 != nil { x.Nullable, ok = compiler.BoolForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for nullable: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for nullable: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3847,7 +3847,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v3 != nil { x.ReadOnly, ok = compiler.BoolForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for readOnly: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3856,7 +3856,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v4 != nil { x.WriteOnly, ok = compiler.BoolForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for writeOnly: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for writeOnly: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3892,7 +3892,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v8 != nil { x.Deprecated, ok = compiler.BoolForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for deprecated: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for deprecated: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3901,7 +3901,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v9 != nil { x.Title, ok = compiler.StringForScalarNode(v9) if !ok { - message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3912,7 +3912,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MultipleOf = v } else { - message := fmt.Sprintf("has unexpected value for multipleOf: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for multipleOf: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3923,7 +3923,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.Maximum = v } else { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3932,7 +3932,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v12 != nil { x.ExclusiveMaximum, ok = compiler.BoolForScalarNode(v12) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for exclusiveMaximum: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3943,7 +3943,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.Minimum = v } else { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3952,7 +3952,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v14 != nil { x.ExclusiveMinimum, ok = compiler.BoolForScalarNode(v14) if !ok { - message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for exclusiveMinimum: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3963,7 +3963,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MaxLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxLength: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for maxLength: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3974,7 +3974,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MinLength = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minLength: %+v (%T)", v16, v16) + message := fmt.Sprintf("has unexpected value for minLength: %s", compiler.Display(v16)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3983,7 +3983,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v17 != nil { x.Pattern, ok = compiler.StringForScalarNode(v17) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -3994,7 +3994,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MaxItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxItems: %+v (%T)", v18, v18) + message := fmt.Sprintf("has unexpected value for maxItems: %s", compiler.Display(v18)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4005,7 +4005,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MinItems = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minItems: %+v (%T)", v19, v19) + message := fmt.Sprintf("has unexpected value for minItems: %s", compiler.Display(v19)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4014,7 +4014,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v20 != nil { x.UniqueItems, ok = compiler.BoolForScalarNode(v20) if !ok { - message := fmt.Sprintf("has unexpected value for uniqueItems: %+v (%T)", v20, v20) + message := fmt.Sprintf("has unexpected value for uniqueItems: %s", compiler.Display(v20)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4025,7 +4025,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MaxProperties = int64(t) } else { - message := fmt.Sprintf("has unexpected value for maxProperties: %+v (%T)", v21, v21) + message := fmt.Sprintf("has unexpected value for maxProperties: %s", compiler.Display(v21)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4036,7 +4036,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.MinProperties = int64(t) } else { - message := fmt.Sprintf("has unexpected value for minProperties: %+v (%T)", v22, v22) + message := fmt.Sprintf("has unexpected value for minProperties: %s", compiler.Display(v22)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4047,7 +4047,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.Required = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v23, v23) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v23)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4072,7 +4072,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v25 != nil { x.Type, ok = compiler.StringForScalarNode(v25) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v25, v25) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v25)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4174,7 +4174,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v34 != nil { x.Description, ok = compiler.StringForScalarNode(v34) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v34, v34) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v34)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4183,7 +4183,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v35 != nil { x.Format, ok = compiler.StringForScalarNode(v35) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v35, v35) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v35)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4349,7 +4349,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche if v1 != nil { x.Type, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4358,7 +4358,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche if v2 != nil { x.Description, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4367,7 +4367,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche if v3 != nil { x.Name, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4376,7 +4376,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche if v4 != nil { x.In, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for in: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for in: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4385,7 +4385,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche if v5 != nil { x.Scheme, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for scheme: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for scheme: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4394,7 +4394,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche if v6 != nil { x.BearerFormat, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for bearerFormat: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for bearerFormat: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4412,7 +4412,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche if v8 != nil { x.OpenIdConnectUrl, ok = compiler.StringForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for openIdConnectUrl: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for openIdConnectUrl: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4548,7 +4548,7 @@ func NewServer(in interface{}, context *compiler.Context) (*Server, error) { if v1 != nil { x.Url, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for url: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for url: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4557,7 +4557,7 @@ func NewServer(in interface{}, context *compiler.Context) (*Server, error) { if v2 != nil { x.Description, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4634,7 +4634,7 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab if ok { x.Enum = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for enum: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for enum: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4643,7 +4643,7 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab if v2 != nil { x.Default, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for default: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for default: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4652,7 +4652,7 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4826,7 +4826,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4835,7 +4835,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { if v2 != nil { x.Description, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4904,7 +4904,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4913,7 +4913,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v2 != nil { x.Namespace, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for namespace: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for namespace: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4922,7 +4922,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v3 != nil { x.Prefix, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for prefix: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for prefix: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4931,7 +4931,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v4 != nil { x.Attribute, ok = compiler.BoolForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for attribute: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for attribute: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -4940,7 +4940,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if v5 != nil { x.Wrapped, ok = compiler.BoolForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for wrapped: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for wrapped: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -8339,6 +8339,9 @@ func (m *Schema) ToRawInfo() *yaml.Node { for _, item := range m.Items.SchemaOrReference { items.Content = append(items.Content, item.ToRawInfo()) } + if len(items.Content) == 1 { + items = items.Content[0] + } info.Content = append(info.Content, compiler.NewScalarNodeForString("items")) info.Content = append(info.Content, items) } From 8ac37fe8d10d0ef75ee4988f4fad3d365137614c Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Sat, 11 Jul 2020 17:30:03 -0700 Subject: [PATCH 06/13] ugly-passing all unit tests (requires hand-editing the generated main.go files for extensions, to-fix next) --- compiler/extension-handler.go | 16 +- compiler/helpers.go | 51 +++++- discovery/discovery.go | 177 +++++++++++---------- generate-gnostic/generate-compiler.go | 13 +- generate-gnostic/generate-extension.go | 18 ++- jsonwriter/writer.go | 4 + lib/gnostic.go | 7 + openapiv2/OpenAPIv2.go | 67 ++++---- openapiv3/OpenAPIv3.go | 67 ++++---- testdata/library-example-with-ext.text.out | 4 +- tools/j2y2j/main.go | 10 ++ 11 files changed, 265 insertions(+), 169 deletions(-) diff --git a/compiler/extension-handler.go b/compiler/extension-handler.go index 1f85b650..baaa8d77 100644 --- a/compiler/extension-handler.go +++ b/compiler/extension-handler.go @@ -16,17 +16,17 @@ package compiler import ( "bytes" + "errors" "fmt" + "log" "os/exec" "strings" - "errors" - "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/any" ext_plugin "github.com/googleapis/gnostic/extensions" - yaml "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v3" ) // ExtensionHandler describes a binary that is called by the compiler to handle specification extensions. @@ -35,7 +35,7 @@ type ExtensionHandler struct { } // HandleExtension calls a binary extension handler. -func HandleExtension(context *Context, in interface{}, extensionName string) (bool, *any.Any, error) { +func HandleExtension(context *Context, in *yaml.Node, extensionName string) (bool, *any.Any, error) { handled := false var errFromPlugin error var outFromPlugin *any.Any @@ -51,10 +51,11 @@ func HandleExtension(context *Context, in interface{}, extensionName string) (bo } } } + log.Printf("%s %t %+v", extensionName, handled, outFromPlugin) return handled, outFromPlugin, errFromPlugin } -func (extensionHandlers *ExtensionHandler) handle(in interface{}, extensionName string) (*any.Any, error) { +func (extensionHandlers *ExtensionHandler) handle(in *yaml.Node, extensionName string) (*any.Any, error) { if extensionHandlers.Name != "" { binary, _ := yaml.Marshal(in) @@ -74,9 +75,11 @@ func (extensionHandlers *ExtensionHandler) handle(in interface{}, extensionName requestBytes, _ := proto.Marshal(request) cmd := exec.Command(extensionHandlers.Name) + log.Printf("calling %s", extensionHandlers.Name) + log.Printf("with request %+v", request) cmd.Stdin = bytes.NewReader(requestBytes) output, err := cmd.Output() - + log.Printf("output %+v", output) if err != nil { fmt.Printf("Error: %+v\n", err) return nil, err @@ -88,6 +91,7 @@ func (extensionHandlers *ExtensionHandler) handle(in interface{}, extensionName fmt.Printf("%s\n", string(output)) return nil, err } + log.Printf("response %+v", response) if !response.Handled { return nil, nil } diff --git a/compiler/helpers.go b/compiler/helpers.go index ae967ba1..e01d4063 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -118,6 +118,12 @@ func SequenceNodeForNode(node *yaml.Node) (*yaml.Node, bool) { // BoolForScalarNode returns the bool value of a node. func BoolForScalarNode(node *yaml.Node) (bool, bool) { + if node == nil { + return false, false + } + if node.Kind == yaml.DocumentNode { + return BoolForScalarNode(node.Content[0]) + } if node.Kind != yaml.ScalarNode { return false, false } @@ -133,6 +139,12 @@ func BoolForScalarNode(node *yaml.Node) (bool, bool) { // IntForScalarNode returns the integer value of a node. func IntForScalarNode(node *yaml.Node) (int64, bool) { + if node == nil { + return 0, false + } + if node.Kind == yaml.DocumentNode { + return IntForScalarNode(node.Content[0]) + } if node.Kind != yaml.ScalarNode { return 0, false } @@ -148,6 +160,12 @@ func IntForScalarNode(node *yaml.Node) (int64, bool) { // FloatForScalarNode returns the float value of a node. func FloatForScalarNode(node *yaml.Node) (float64, bool) { + if node == nil { + return 0.0, false + } + if node.Kind == yaml.DocumentNode { + return FloatForScalarNode(node.Content[0]) + } if node.Kind != yaml.ScalarNode { return 0.0, false } @@ -166,13 +184,22 @@ func StringForScalarNode(node *yaml.Node) (string, bool) { if node == nil { return "", false } - if node.Kind != yaml.ScalarNode { - return "", false + if node.Kind == yaml.DocumentNode { + return StringForScalarNode(node.Content[0]) } - if node.Tag != "!!str" { + switch node.Kind { + case yaml.ScalarNode: + switch node.Tag { + case "!!str": + return node.Value, true + case "!!null": + return "", true + default: + return "", false + } + default: return "", false } - return node.Value, true } // StringArrayForSequenceNode converts a sequence node to an array of strings, if possible. @@ -385,3 +412,19 @@ func Display(node *yaml.Node) string { } return fmt.Sprintf("%+v (%T)", node, node) } + +// Marshal creates a yaml version of a structure in our preferred style +func Marshal(in *yaml.Node) []byte { + clearStyle(in) + //bytes, _ := yaml.Marshal(&yaml.Node{Kind: yaml.DocumentNode, Content: []*yaml.Node{in}}) + bytes, _ := yaml.Marshal(in) + + return bytes +} + +func clearStyle(node *yaml.Node) { + node.Style = 0 + for _, c := range node.Content { + clearStyle(c) + } +} diff --git a/discovery/discovery.go b/discovery/discovery.go index 5ea7da80..df2a2ecd 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -52,7 +52,7 @@ func NewAnnotations(in interface{}, context *compiler.Context) (*Annotations, er if ok { x.Required = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -64,7 +64,7 @@ func NewAnnotations(in interface{}, context *compiler.Context) (*Annotations, er func NewAny(in interface{}, context *compiler.Context) (*Any, error) { errors := make([]error, 0) x := &Any{} - bytes, _ := yaml.Marshal(in) + bytes := compiler.Marshal(in.(*yaml.Node)) x.Yaml = string(bytes) return x, compiler.NewErrorGroupOrNil(errors) } @@ -125,7 +125,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v1 != nil { x.Kind, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for kind: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for kind: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -134,7 +134,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v2 != nil { x.DiscoveryVersion, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for discoveryVersion: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for discoveryVersion: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -143,7 +143,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v3 != nil { x.Id, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for id: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -152,7 +152,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v4 != nil { x.Name, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -161,7 +161,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v5 != nil { x.Version, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for version: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for version: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -170,7 +170,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v6 != nil { x.Revision, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for revision: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for revision: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -179,7 +179,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v7 != nil { x.Title, ok = compiler.StringForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for title: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for title: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -188,7 +188,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v8 != nil { x.Description, ok = compiler.StringForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -206,7 +206,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v10 != nil { x.DocumentationLink, ok = compiler.StringForScalarNode(v10) if !ok { - message := fmt.Sprintf("has unexpected value for documentationLink: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for documentationLink: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -217,7 +217,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if ok { x.Labels = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for labels: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for labels: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -226,7 +226,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v12 != nil { x.Protocol, ok = compiler.StringForScalarNode(v12) if !ok { - message := fmt.Sprintf("has unexpected value for protocol: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for protocol: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -235,7 +235,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v13 != nil { x.BaseUrl, ok = compiler.StringForScalarNode(v13) if !ok { - message := fmt.Sprintf("has unexpected value for baseUrl: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for baseUrl: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -244,7 +244,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v14 != nil { x.BasePath, ok = compiler.StringForScalarNode(v14) if !ok { - message := fmt.Sprintf("has unexpected value for basePath: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for basePath: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -253,7 +253,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v15 != nil { x.RootUrl, ok = compiler.StringForScalarNode(v15) if !ok { - message := fmt.Sprintf("has unexpected value for rootUrl: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for rootUrl: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -262,7 +262,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v16 != nil { x.ServicePath, ok = compiler.StringForScalarNode(v16) if !ok { - message := fmt.Sprintf("has unexpected value for servicePath: %+v (%T)", v16, v16) + message := fmt.Sprintf("has unexpected value for servicePath: %s", compiler.Display(v16)) errors = append(errors, compiler.NewError(context, message)) } } @@ -271,7 +271,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v17 != nil { x.BatchPath, ok = compiler.StringForScalarNode(v17) if !ok { - message := fmt.Sprintf("has unexpected value for batchPath: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for batchPath: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -300,7 +300,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if ok { x.Features = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for features: %+v (%T)", v20, v20) + message := fmt.Sprintf("has unexpected value for features: %s", compiler.Display(v20)) errors = append(errors, compiler.NewError(context, message)) } } @@ -336,7 +336,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v24 != nil { x.Etag, ok = compiler.StringForScalarNode(v24) if !ok { - message := fmt.Sprintf("has unexpected value for etag: %+v (%T)", v24, v24) + message := fmt.Sprintf("has unexpected value for etag: %s", compiler.Display(v24)) errors = append(errors, compiler.NewError(context, message)) } } @@ -345,7 +345,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v25 != nil { x.OwnerDomain, ok = compiler.StringForScalarNode(v25) if !ok { - message := fmt.Sprintf("has unexpected value for ownerDomain: %+v (%T)", v25, v25) + message := fmt.Sprintf("has unexpected value for ownerDomain: %s", compiler.Display(v25)) errors = append(errors, compiler.NewError(context, message)) } } @@ -354,7 +354,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v26 != nil { x.OwnerName, ok = compiler.StringForScalarNode(v26) if !ok { - message := fmt.Sprintf("has unexpected value for ownerName: %+v (%T)", v26, v26) + message := fmt.Sprintf("has unexpected value for ownerName: %s", compiler.Display(v26)) errors = append(errors, compiler.NewError(context, message)) } } @@ -363,7 +363,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v27 != nil { x.VersionModule, ok = compiler.BoolForScalarNode(v27) if !ok { - message := fmt.Sprintf("has unexpected value for version_module: %+v (%T)", v27, v27) + message := fmt.Sprintf("has unexpected value for version_module: %s", compiler.Display(v27)) errors = append(errors, compiler.NewError(context, message)) } } @@ -372,7 +372,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v28 != nil { x.CanonicalName, ok = compiler.StringForScalarNode(v28) if !ok { - message := fmt.Sprintf("has unexpected value for canonicalName: %+v (%T)", v28, v28) + message := fmt.Sprintf("has unexpected value for canonicalName: %s", compiler.Display(v28)) errors = append(errors, compiler.NewError(context, message)) } } @@ -381,7 +381,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v29 != nil { x.FullyEncodeReservedExpansion, ok = compiler.BoolForScalarNode(v29) if !ok { - message := fmt.Sprintf("has unexpected value for fullyEncodeReservedExpansion: %+v (%T)", v29, v29) + message := fmt.Sprintf("has unexpected value for fullyEncodeReservedExpansion: %s", compiler.Display(v29)) errors = append(errors, compiler.NewError(context, message)) } } @@ -390,7 +390,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v30 != nil { x.PackagePath, ok = compiler.StringForScalarNode(v30) if !ok { - message := fmt.Sprintf("has unexpected value for packagePath: %+v (%T)", v30, v30) + message := fmt.Sprintf("has unexpected value for packagePath: %s", compiler.Display(v30)) errors = append(errors, compiler.NewError(context, message)) } } @@ -399,7 +399,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if v31 != nil { x.MtlsRootUrl, ok = compiler.StringForScalarNode(v31) if !ok { - message := fmt.Sprintf("has unexpected value for mtlsRootUrl: %+v (%T)", v31, v31) + message := fmt.Sprintf("has unexpected value for mtlsRootUrl: %s", compiler.Display(v31)) errors = append(errors, compiler.NewError(context, message)) } } @@ -434,7 +434,7 @@ func NewIcons(in interface{}, context *compiler.Context) (*Icons, error) { if v1 != nil { x.X16, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for x16: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for x16: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -443,7 +443,7 @@ func NewIcons(in interface{}, context *compiler.Context) (*Icons, error) { if v2 != nil { x.X32, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for x32: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for x32: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -474,7 +474,7 @@ func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, er if ok { x.Accept = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for accept: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for accept: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -483,7 +483,7 @@ func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, er if v2 != nil { x.MaxSize, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for maxSize: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for maxSize: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -501,7 +501,7 @@ func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, er if v4 != nil { x.SupportsSubscription, ok = compiler.BoolForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for supportsSubscription: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for supportsSubscription: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -530,7 +530,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v1 != nil { x.Id, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for id: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -539,7 +539,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v2 != nil { x.Path, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for path: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -548,7 +548,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v3 != nil { x.HttpMethod, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for httpMethod: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for httpMethod: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -557,7 +557,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v4 != nil { x.Description, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -577,7 +577,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if ok { x.ParameterOrder = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for parameterOrder: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for parameterOrder: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -606,7 +606,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if ok { x.Scopes = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for scopes: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for scopes: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -615,7 +615,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v10 != nil { x.SupportsMediaDownload, ok = compiler.BoolForScalarNode(v10) if !ok { - message := fmt.Sprintf("has unexpected value for supportsMediaDownload: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for supportsMediaDownload: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -624,7 +624,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v11 != nil { x.SupportsMediaUpload, ok = compiler.BoolForScalarNode(v11) if !ok { - message := fmt.Sprintf("has unexpected value for supportsMediaUpload: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for supportsMediaUpload: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -633,7 +633,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v12 != nil { x.UseMediaDownloadService, ok = compiler.BoolForScalarNode(v12) if !ok { - message := fmt.Sprintf("has unexpected value for useMediaDownloadService: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for useMediaDownloadService: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -651,7 +651,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v14 != nil { x.SupportsSubscription, ok = compiler.BoolForScalarNode(v14) if !ok { - message := fmt.Sprintf("has unexpected value for supportsSubscription: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for supportsSubscription: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -660,7 +660,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v15 != nil { x.FlatPath, ok = compiler.StringForScalarNode(v15) if !ok { - message := fmt.Sprintf("has unexpected value for flatPath: %+v (%T)", v15, v15) + message := fmt.Sprintf("has unexpected value for flatPath: %s", compiler.Display(v15)) errors = append(errors, compiler.NewError(context, message)) } } @@ -669,7 +669,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { if v16 != nil { x.EtagRequired, ok = compiler.BoolForScalarNode(v16) if !ok { - message := fmt.Sprintf("has unexpected value for etagRequired: %+v (%T)", v16, v16) + message := fmt.Sprintf("has unexpected value for etagRequired: %s", compiler.Display(v16)) errors = append(errors, compiler.NewError(context, message)) } } @@ -728,7 +728,7 @@ func NewNamedMethod(in interface{}, context *compiler.Context) (*NamedMethod, er if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -766,7 +766,7 @@ func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParamet if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -804,7 +804,7 @@ func NewNamedResource(in interface{}, context *compiler.Context) (*NamedResource if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -842,7 +842,7 @@ func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, er if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -880,7 +880,7 @@ func NewNamedScope(in interface{}, context *compiler.Context) (*NamedScope, erro if v1 != nil { x.Name, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for name: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for name: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -947,7 +947,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v1 != nil { x.Id, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for id: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -956,7 +956,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v2 != nil { x.Type, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -965,7 +965,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v3 != nil { x.XRef, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -974,7 +974,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v4 != nil { x.Description, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -983,7 +983,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v5 != nil { x.Default, ok = compiler.StringForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for default: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for default: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -992,7 +992,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v6 != nil { x.Required, ok = compiler.BoolForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1001,7 +1001,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v7 != nil { x.Format, ok = compiler.StringForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1010,7 +1010,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v8 != nil { x.Pattern, ok = compiler.StringForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1019,7 +1019,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v9 != nil { x.Minimum, ok = compiler.StringForScalarNode(v9) if !ok { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1028,7 +1028,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v10 != nil { x.Maximum, ok = compiler.StringForScalarNode(v10) if !ok { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1039,7 +1039,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if ok { x.Enum = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for enum: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for enum: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1050,7 +1050,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if ok { x.EnumDescriptions = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for enumDescriptions: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for enumDescriptions: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1059,7 +1059,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v13 != nil { x.Repeated, ok = compiler.BoolForScalarNode(v13) if !ok { - message := fmt.Sprintf("has unexpected value for repeated: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for repeated: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1068,7 +1068,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if v14 != nil { x.Location, ok = compiler.StringForScalarNode(v14) if !ok { - message := fmt.Sprintf("has unexpected value for location: %+v (%T)", v14, v14) + message := fmt.Sprintf("has unexpected value for location: %s", compiler.Display(v14)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1201,7 +1201,7 @@ func NewRequest(in interface{}, context *compiler.Context) (*Request, error) { if v1 != nil { x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1210,7 +1210,7 @@ func NewRequest(in interface{}, context *compiler.Context) (*Request, error) { if v2 != nil { x.ParameterName, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for parameterName: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for parameterName: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1307,7 +1307,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { if v1 != nil { x.XRef, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1336,7 +1336,7 @@ func NewResumable(in interface{}, context *compiler.Context) (*Resumable, error) if v1 != nil { x.Multipart, ok = compiler.BoolForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for multipart: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for multipart: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1345,7 +1345,7 @@ func NewResumable(in interface{}, context *compiler.Context) (*Resumable, error) if v2 != nil { x.Path, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for path: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1374,7 +1374,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v1 != nil { x.Id, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for id: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for id: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1383,7 +1383,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v2 != nil { x.Type, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for type: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for type: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1392,7 +1392,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v3 != nil { x.Description, ok = compiler.StringForScalarNode(v3) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v3, v3) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v3)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1401,7 +1401,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v4 != nil { x.Default, ok = compiler.StringForScalarNode(v4) if !ok { - message := fmt.Sprintf("has unexpected value for default: %+v (%T)", v4, v4) + message := fmt.Sprintf("has unexpected value for default: %s", compiler.Display(v4)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1410,7 +1410,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v5 != nil { x.Required, ok = compiler.BoolForScalarNode(v5) if !ok { - message := fmt.Sprintf("has unexpected value for required: %+v (%T)", v5, v5) + message := fmt.Sprintf("has unexpected value for required: %s", compiler.Display(v5)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1419,7 +1419,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v6 != nil { x.Format, ok = compiler.StringForScalarNode(v6) if !ok { - message := fmt.Sprintf("has unexpected value for format: %+v (%T)", v6, v6) + message := fmt.Sprintf("has unexpected value for format: %s", compiler.Display(v6)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1428,7 +1428,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v7 != nil { x.Pattern, ok = compiler.StringForScalarNode(v7) if !ok { - message := fmt.Sprintf("has unexpected value for pattern: %+v (%T)", v7, v7) + message := fmt.Sprintf("has unexpected value for pattern: %s", compiler.Display(v7)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1437,7 +1437,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v8 != nil { x.Minimum, ok = compiler.StringForScalarNode(v8) if !ok { - message := fmt.Sprintf("has unexpected value for minimum: %+v (%T)", v8, v8) + message := fmt.Sprintf("has unexpected value for minimum: %s", compiler.Display(v8)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1446,7 +1446,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v9 != nil { x.Maximum, ok = compiler.StringForScalarNode(v9) if !ok { - message := fmt.Sprintf("has unexpected value for maximum: %+v (%T)", v9, v9) + message := fmt.Sprintf("has unexpected value for maximum: %s", compiler.Display(v9)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1457,7 +1457,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.Enum = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for enum: %+v (%T)", v10, v10) + message := fmt.Sprintf("has unexpected value for enum: %s", compiler.Display(v10)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1468,7 +1468,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if ok { x.EnumDescriptions = compiler.StringArrayForSequenceNode(v) } else { - message := fmt.Sprintf("has unexpected value for enumDescriptions: %+v (%T)", v11, v11) + message := fmt.Sprintf("has unexpected value for enumDescriptions: %s", compiler.Display(v11)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1477,7 +1477,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v12 != nil { x.Repeated, ok = compiler.BoolForScalarNode(v12) if !ok { - message := fmt.Sprintf("has unexpected value for repeated: %+v (%T)", v12, v12) + message := fmt.Sprintf("has unexpected value for repeated: %s", compiler.Display(v12)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1486,7 +1486,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v13 != nil { x.Location, ok = compiler.StringForScalarNode(v13) if !ok { - message := fmt.Sprintf("has unexpected value for location: %+v (%T)", v13, v13) + message := fmt.Sprintf("has unexpected value for location: %s", compiler.Display(v13)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1522,7 +1522,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v17 != nil { x.XRef, ok = compiler.StringForScalarNode(v17) if !ok { - message := fmt.Sprintf("has unexpected value for $ref: %+v (%T)", v17, v17) + message := fmt.Sprintf("has unexpected value for $ref: %s", compiler.Display(v17)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1540,7 +1540,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if v19 != nil { x.ReadOnly, ok = compiler.BoolForScalarNode(v19) if !ok { - message := fmt.Sprintf("has unexpected value for readOnly: %+v (%T)", v19, v19) + message := fmt.Sprintf("has unexpected value for readOnly: %s", compiler.Display(v19)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1599,7 +1599,7 @@ func NewScope(in interface{}, context *compiler.Context) (*Scope, error) { if v1 != nil { x.Description, ok = compiler.StringForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for description: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for description: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1658,7 +1658,7 @@ func NewSimple(in interface{}, context *compiler.Context) (*Simple, error) { if v1 != nil { x.Multipart, ok = compiler.BoolForScalarNode(v1) if !ok { - message := fmt.Sprintf("has unexpected value for multipart: %+v (%T)", v1, v1) + message := fmt.Sprintf("has unexpected value for multipart: %s", compiler.Display(v1)) errors = append(errors, compiler.NewError(context, message)) } } @@ -1667,7 +1667,7 @@ func NewSimple(in interface{}, context *compiler.Context) (*Simple, error) { if v2 != nil { x.Path, ok = compiler.StringForScalarNode(v2) if !ok { - message := fmt.Sprintf("has unexpected value for path: %+v (%T)", v2, v2) + message := fmt.Sprintf("has unexpected value for path: %s", compiler.Display(v2)) errors = append(errors, compiler.NewError(context, message)) } } @@ -2148,7 +2148,12 @@ func (m *Any) ToRawInfo() *yaml.Node { var node yaml.Node err = yaml.Unmarshal([]byte(m.Yaml), &node) if err == nil { + if node.Kind == yaml.DocumentNode { + return node.Content[0] + } return &node + } else { + return nil } return nil } diff --git a/generate-gnostic/generate-compiler.go b/generate-gnostic/generate-compiler.go index b2072768..c14b0100 100644 --- a/generate-gnostic/generate-compiler.go +++ b/generate-gnostic/generate-compiler.go @@ -195,7 +195,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } } else if typeModel.IsBlob { code.Print("x := &Any{}") - code.Print("bytes, _ := yaml.Marshal(in)") + code.Print("bytes := compiler.Marshal(in.(*yaml.Node))") code.Print("x.Yaml = string(bytes)") } else if typeModel.Name == "StringArray" { code.Print("x := &StringArray{}") @@ -588,7 +588,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" if err != nil {") code.Print(" errors = append(errors, err)") code.Print(" } else {") - code.Print(" bytes, _ := yaml.Marshal(v)") + code.Print(" bytes := compiler.Marshal(v)") code.Print(" result.Yaml = string(bytes)") code.Print(" result.Value = resultFromExt") code.Print(" pair.Value = result") @@ -759,7 +759,14 @@ func (domain *Domain) generateToRawInfoMethodForType(code *printer.Code, typeNam code.Print("var err error") code.Print("var node yaml.Node") code.Print("err = yaml.Unmarshal([]byte(m.Yaml), &node)") - code.Print("if err == nil {return &node}") + code.Print("if err == nil {") + code.Print(" if node.Kind == yaml.DocumentNode {") + code.Print(" return node.Content[0]") + code.Print(" }") + code.Print(" return &node") + code.Print("} else {") + code.Print(" return nil") + code.Print("}") code.Print("return nil") } else if typeName == "StringArray" { code.Print("return compiler.NewSequenceNodeForStringArray(m.Value)") diff --git a/generate-gnostic/generate-extension.go b/generate-gnostic/generate-extension.go index 3ede5b55..3b6581fa 100644 --- a/generate-gnostic/generate-extension.go +++ b/generate-gnostic/generate-extension.go @@ -66,17 +66,17 @@ const additionalCompilerCodeWithMain = "" + const caseStringForObjectTypes = "\n" + "case \"%s\":\n" + - "var info yaml.MapSlice\n" + + "var info yaml.Node\n" + "err := yaml.Unmarshal([]byte(yamlInput), &info)\n" + "if err != nil {\n" + " return true, nil, err\n" + "}\n" + - "newObject, err := %s.New%s(info, compiler.NewContext(\"$root\", nil))\n" + + "newObject, err := %s.New%s(&info, compiler.NewContext(\"$root\", nil))\n" + "return true, newObject, err" const caseStringForWrapperTypes = "\n" + "case \"%s\":\n" + - "var info %s\n" + + "var info yaml.Node\n" + "err := yaml.Unmarshal([]byte(yamlInput), &info)\n" + "if err != nil {\n" + " return true, nil, err\n" + @@ -294,10 +294,16 @@ func GenerateExtension(schemaFile string, outDir string) error { var cases string for _, extensionName := range extensionNameKeys { if extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo == nil { - cases += fmt.Sprintf(caseStringForObjectTypes, extensionName, goPackageName, extensionNameToMessageName[extensionName].schemaName) + cases += fmt.Sprintf(caseStringForObjectTypes, + extensionName, + goPackageName, + extensionNameToMessageName[extensionName].schemaName) } else { wrapperTypeIncluded = true - cases += fmt.Sprintf(caseStringForWrapperTypes, extensionName, extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.goTypeName, extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.wrapperProtoName) + cases += fmt.Sprintf(caseStringForWrapperTypes, + extensionName, + // extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.goTypeName, + extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.wrapperProtoName) } } @@ -306,7 +312,7 @@ func GenerateExtension(schemaFile string, outDir string) error { "github.com/golang/protobuf/proto", "github.com/googleapis/gnostic/extensions", "github.com/googleapis/gnostic/compiler", - "gopkg.in/yaml.v2", + "gopkg.in/yaml.v3", outDirRelativeToPackageRoot + "/" + "proto", } if wrapperTypeIncluded { diff --git a/jsonwriter/writer.go b/jsonwriter/writer.go index 5b5f2238..a7f35e30 100644 --- a/jsonwriter/writer.go +++ b/jsonwriter/writer.go @@ -45,6 +45,10 @@ func (w *writer) writeString(s string) { } func (w *writer) writeMap(node *yaml.Node, indent string) { + if node.Kind == yaml.DocumentNode { + w.writeMap(node.Content[0], indent) + return + } if node.Kind != yaml.MappingNode { w.writeString(fmt.Sprintf("invalid node for map: %+v", node)) return diff --git a/lib/gnostic.go b/lib/gnostic.go index f9645971..2f62dc8c 100644 --- a/lib/gnostic.go +++ b/lib/gnostic.go @@ -521,6 +521,12 @@ func (g *Gnostic) writeJSONYAMLOutput(message proto.Message) { document := message.(*discovery_v1.Document) rawInfo = document.ToRawInfo() } + if rawInfo.Kind != yaml.DocumentNode { + rawInfo = &yaml.Node{ + Kind: yaml.DocumentNode, + Content: []*yaml.Node{rawInfo}, + } + } // Optionally write description in yaml format. if g.yamlOutputPath != "" { var bytes []byte @@ -528,6 +534,7 @@ func (g *Gnostic) writeJSONYAMLOutput(message proto.Message) { bytes, err = yaml.Marshal(rawInfo) if err != nil { fmt.Fprintf(os.Stderr, "Error generating yaml output %s\n", err.Error()) + fmt.Fprintf(os.Stderr, "info %+v", rawInfo) } writeFile(g.yamlOutputPath, bytes, g.sourceName, "yaml") } else { diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index b1996c74..e32a2c99 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -65,7 +65,7 @@ func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*Ad func NewAny(in interface{}, context *compiler.Context) (*Any, error) { errors := make([]error, 0) x := &Any{} - bytes, _ := yaml.Marshal(in) + bytes := compiler.Marshal(in.(*yaml.Node)) x.Yaml = string(bytes) return x, compiler.NewErrorGroupOrNil(errors) } @@ -156,7 +156,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -237,7 +237,7 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -345,7 +345,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -423,7 +423,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -466,7 +466,7 @@ func NewDefault(in interface{}, context *compiler.Context) (*Default, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -719,7 +719,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -762,7 +762,7 @@ func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -836,7 +836,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -982,7 +982,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1270,7 +1270,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1522,7 +1522,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1801,7 +1801,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1942,7 +1942,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2073,7 +2073,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2644,7 +2644,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2758,7 +2758,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2872,7 +2872,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2986,7 +2986,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3205,7 +3205,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3454,7 +3454,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3739,7 +3739,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3790,7 +3790,7 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4046,7 +4046,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4364,7 +4364,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4457,7 +4457,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4597,7 +4597,7 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4952,7 +4952,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -5249,7 +5249,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -5320,7 +5320,7 @@ func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExten if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -5415,7 +5415,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -6831,7 +6831,12 @@ func (m *Any) ToRawInfo() *yaml.Node { var node yaml.Node err = yaml.Unmarshal([]byte(m.Yaml), &node) if err == nil { + if node.Kind == yaml.DocumentNode { + return node.Content[0] + } return &node + } else { + return nil } return nil } diff --git a/openapiv3/OpenAPIv3.go b/openapiv3/OpenAPIv3.go index c6424678..aeca1d9d 100644 --- a/openapiv3/OpenAPIv3.go +++ b/openapiv3/OpenAPIv3.go @@ -65,7 +65,7 @@ func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*Ad func NewAny(in interface{}, context *compiler.Context) (*Any, error) { errors := make([]error, 0) x := &Any{} - bytes, _ := yaml.Marshal(in) + bytes := compiler.Marshal(in.(*yaml.Node)) x.Yaml = string(bytes) return x, compiler.NewErrorGroupOrNil(errors) } @@ -161,7 +161,7 @@ func NewCallback(in interface{}, context *compiler.Context) (*Callback, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -363,7 +363,7 @@ func NewComponents(in interface{}, context *compiler.Context) (*Components, erro if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -441,7 +441,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -551,7 +551,7 @@ func NewDiscriminator(in interface{}, context *compiler.Context) (*Discriminator if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -701,7 +701,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -797,7 +797,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -914,7 +914,7 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1027,7 +1027,7 @@ func NewExpression(in interface{}, context *compiler.Context) (*Expression, erro if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1101,7 +1101,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1251,7 +1251,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1441,7 +1441,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1535,7 +1535,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1640,7 +1640,7 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -1797,7 +1797,7 @@ func NewMediaType(in interface{}, context *compiler.Context) (*MediaType, error) if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2522,7 +2522,7 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2609,7 +2609,7 @@ func NewOauthFlows(in interface{}, context *compiler.Context) (*OauthFlows, erro if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2652,7 +2652,7 @@ func NewObject(in interface{}, context *compiler.Context) (*Object, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -2839,7 +2839,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3013,7 +3013,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3265,7 +3265,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3335,7 +3335,7 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3507,7 +3507,7 @@ func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, er if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3640,7 +3640,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -3759,7 +3759,7 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4203,7 +4203,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4432,7 +4432,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4586,7 +4586,7 @@ func NewServer(in interface{}, context *compiler.Context) (*Server, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4672,7 +4672,7 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4864,7 +4864,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -4960,7 +4960,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { if err != nil { errors = append(errors, err) } else { - bytes, _ := yaml.Marshal(v) + bytes := compiler.Marshal(v) result.Yaml = string(bytes) result.Value = resultFromExt pair.Value = result @@ -6659,7 +6659,12 @@ func (m *Any) ToRawInfo() *yaml.Node { var node yaml.Node err = yaml.Unmarshal([]byte(m.Yaml), &node) if err == nil { + if node.Kind == yaml.DocumentNode { + return node.Content[0] + } return &node + } else { + return nil } return nil } diff --git a/testdata/library-example-with-ext.text.out b/testdata/library-example-with-ext.text.out index e735bdf8..3486cce9 100644 --- a/testdata/library-example-with-ext.text.out +++ b/testdata/library-example-with-ext.text.out @@ -195,8 +195,8 @@ vendor_extension: < name: "x-sampleone-mysimpleint64" value: < value: < - type_url: "type.googleapis.com/google.protobuf.StringValue" - value: "\n\00512345" + type_url: "type.googleapis.com/google.protobuf.Int64Value" + value: "\010\271`" > yaml: "12345\n" > diff --git a/tools/j2y2j/main.go b/tools/j2y2j/main.go index 15d73442..ac8cdfbf 100644 --- a/tools/j2y2j/main.go +++ b/tools/j2y2j/main.go @@ -32,6 +32,14 @@ func usage() { os.Exit(0) } +func dump(node *yaml.Node, indent string) { + node.Style = 0 + fmt.Printf("%s%s: %+v\n", indent, node.Value, node) + for _, c := range node.Content { + dump(c, indent+" ") + } +} + func main() { if len(os.Args) != 3 { usage() @@ -45,6 +53,8 @@ func main() { var node yaml.Node err = yaml.Unmarshal(file, &node) + dump(&node, "") + switch os.Args[2] { case "--json": result := jsonschema.Render(&node) From 5bce2158b6564e288f08db5581d8a0e257e96e8d Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Sat, 11 Jul 2020 18:39:53 -0700 Subject: [PATCH 07/13] cleaner passing of unit tests, all generated files are propertly generated now. --- compiler/extension-handler.go | 6 ------ extensions/sample/x-sampleone.json | 2 +- generate-gnostic/generate-extension.go | 17 +++++++++++------ go.mod | 1 - go.sum | 1 - 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/compiler/extension-handler.go b/compiler/extension-handler.go index baaa8d77..dcb7e138 100644 --- a/compiler/extension-handler.go +++ b/compiler/extension-handler.go @@ -18,7 +18,6 @@ import ( "bytes" "errors" "fmt" - "log" "os/exec" "strings" @@ -51,7 +50,6 @@ func HandleExtension(context *Context, in *yaml.Node, extensionName string) (boo } } } - log.Printf("%s %t %+v", extensionName, handled, outFromPlugin) return handled, outFromPlugin, errFromPlugin } @@ -75,11 +73,8 @@ func (extensionHandlers *ExtensionHandler) handle(in *yaml.Node, extensionName s requestBytes, _ := proto.Marshal(request) cmd := exec.Command(extensionHandlers.Name) - log.Printf("calling %s", extensionHandlers.Name) - log.Printf("with request %+v", request) cmd.Stdin = bytes.NewReader(requestBytes) output, err := cmd.Output() - log.Printf("output %+v", output) if err != nil { fmt.Printf("Error: %+v\n", err) return nil, err @@ -91,7 +86,6 @@ func (extensionHandlers *ExtensionHandler) handle(in *yaml.Node, extensionName s fmt.Printf("%s\n", string(output)) return nil, err } - log.Printf("response %+v", response) if !response.Handled { return nil, nil } diff --git a/extensions/sample/x-sampleone.json b/extensions/sample/x-sampleone.json index e07ee149..b5cbc7ea 100644 --- a/extensions/sample/x-sampleone.json +++ b/extensions/sample/x-sampleone.json @@ -47,7 +47,7 @@ "id": "x-sampleone-mysimpleboolean" }, "PrimitiveInt64": { - "type": "string", + "type": "integer", "id": "x-sampleone-mysimpleint64" } diff --git a/generate-gnostic/generate-extension.go b/generate-gnostic/generate-extension.go index 3b6581fa..9e7eb9c3 100644 --- a/generate-gnostic/generate-extension.go +++ b/generate-gnostic/generate-extension.go @@ -71,6 +71,7 @@ const caseStringForObjectTypes = "\n" + "if err != nil {\n" + " return true, nil, err\n" + "}\n" + + "info = *info.Content[0]\n" + "newObject, err := %s.New%s(&info, compiler.NewContext(\"$root\", nil))\n" + "return true, newObject, err" @@ -81,7 +82,11 @@ const caseStringForWrapperTypes = "\n" + "if err != nil {\n" + " return true, nil, err\n" + "}\n" + - "newObject := &wrappers.%s{Value: info}\n" + + "v, ok := compiler.%sForScalarNode(&info)\n" + + "if !ok {\n" + + " return true, nil, nil\n" + + "}\n" + + "newObject := &wrappers.%s{Value: v}\n" + "return true, newObject, nil" // generateMainFile generates the main program for an extension. @@ -132,10 +137,10 @@ type primitiveTypeInfo struct { } var supportedPrimitiveTypeInfos = map[string]primitiveTypeInfo{ - "string": primitiveTypeInfo{goTypeName: "string", wrapperProtoName: "StringValue"}, - "number": primitiveTypeInfo{goTypeName: "float64", wrapperProtoName: "DoubleValue"}, - "integer": primitiveTypeInfo{goTypeName: "int64", wrapperProtoName: "Int64Value"}, - "boolean": primitiveTypeInfo{goTypeName: "bool", wrapperProtoName: "BoolValue"}, + "string": primitiveTypeInfo{goTypeName: "String", wrapperProtoName: "StringValue"}, + "number": primitiveTypeInfo{goTypeName: "Float", wrapperProtoName: "DoubleValue"}, + "integer": primitiveTypeInfo{goTypeName: "Int", wrapperProtoName: "Int64Value"}, + "boolean": primitiveTypeInfo{goTypeName: "Bool", wrapperProtoName: "BoolValue"}, // TODO: Investigate how to support arrays. For now users will not be allowed to // create extension handlers for arrays and they will have to use the // plane yaml string as is. @@ -302,7 +307,7 @@ func GenerateExtension(schemaFile string, outDir string) error { wrapperTypeIncluded = true cases += fmt.Sprintf(caseStringForWrapperTypes, extensionName, - // extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.goTypeName, + extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.goTypeName, extensionNameToMessageName[extensionName].optionalPrimitiveTypeInfo.wrapperProtoName) } diff --git a/go.mod b/go.mod index 1edf3fab..a3837905 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,5 @@ require ( github.com/stoewer/go-strcase v1.2.0 google.golang.org/protobuf v1.23.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 - gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 ) diff --git a/go.sum b/go.sum index 452af758..f0d27b31 100644 --- a/go.sum +++ b/go.sum @@ -32,7 +32,6 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From c579765c2fee2b7f750f3fd733f1d9a75d5dd8dc Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Sat, 11 Jul 2020 19:43:47 -0700 Subject: [PATCH 08/13] many type assertions eliminated --- compiler/helpers.go | 51 +--- compiler/reader.go | 2 +- discovery/discovery.go | 127 ++++---- generate-gnostic/generate-compiler.go | 109 +++---- lib/gnostic.go | 2 +- openapiv2/OpenAPIv2.go | 259 ++++++++-------- openapiv3/OpenAPIv3.go | 407 +++++++++++++------------- 7 files changed, 435 insertions(+), 522 deletions(-) diff --git a/compiler/helpers.go b/compiler/helpers.go index e01d4063..5e62bc57 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -27,29 +27,11 @@ import ( // compiler helper functions, usually called from generated code // UnpackMap gets a *yaml.Node if possible. -func UnpackMap(in interface{}) (*yaml.Node, bool) { +func UnpackMap(in *yaml.Node) (*yaml.Node, bool) { if in == nil { return nil, false } - m, ok := in.(*yaml.Node) - if ok { - if m == nil { - return nil, false - } - 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.Node{ - Kind: yaml.MappingNode, - Content: make([]*yaml.Node, 0), - }, true - } - */ - return nil, false + return in, true } // SortedKeysForMap returns the sorted keys of a yamlv2.MapSlice. @@ -322,35 +304,6 @@ func NewScalarNodeForInt(i int64) *yaml.Node { } } -// 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 { - keys = append(keys, k) - } - sort.Strings(keys) - for _, k := range keys { - v := m[k] - description += fmt.Sprintf("%s%s:\n", indent, k) - description += DescribeMap(v, indent+" ") - } - return description - } - a, ok := in.([]interface{}) - if ok { - for i, v := range a { - description += fmt.Sprintf("%s%d:\n", indent, i) - description += DescribeMap(v, indent+" ") - } - return description - } - description += fmt.Sprintf("%s%+v\n", indent, in) - return description -} - // PluralProperties returns the string "properties" pluralized. func PluralProperties(count int) string { if count == 1 { diff --git a/compiler/reader.go b/compiler/reader.go index 6375a146..e1d8eddd 100644 --- a/compiler/reader.go +++ b/compiler/reader.go @@ -234,7 +234,7 @@ func readInfoFromBytes(filename string, bytes []byte) (*yaml.Node, error) { } // ReadInfoForRef reads a file and return the fragment needed to resolve a $ref. -func ReadInfoForRef(basefile string, ref string) (interface{}, error) { +func ReadInfoForRef(basefile string, ref string) (*yaml.Node, error) { fileCacheMutex.Lock() defer fileCacheMutex.Unlock() infoCacheMutex.Lock() diff --git a/discovery/discovery.go b/discovery/discovery.go index df2a2ecd..3bbd33c4 100644 --- a/discovery/discovery.go +++ b/discovery/discovery.go @@ -30,7 +30,7 @@ func Version() string { } // NewAnnotations creates an object of type Annotations if possible, returning an error if not. -func NewAnnotations(in interface{}, context *compiler.Context) (*Annotations, error) { +func NewAnnotations(in *yaml.Node, context *compiler.Context) (*Annotations, error) { errors := make([]error, 0) x := &Annotations{} m, ok := compiler.UnpackMap(in) @@ -61,16 +61,16 @@ func NewAnnotations(in interface{}, context *compiler.Context) (*Annotations, er } // NewAny creates an object of type Any if possible, returning an error if not. -func NewAny(in interface{}, context *compiler.Context) (*Any, error) { +func NewAny(in *yaml.Node, context *compiler.Context) (*Any, error) { errors := make([]error, 0) x := &Any{} - bytes := compiler.Marshal(in.(*yaml.Node)) + bytes := compiler.Marshal(in) x.Yaml = string(bytes) return x, compiler.NewErrorGroupOrNil(errors) } // NewAuth creates an object of type Auth if possible, returning an error if not. -func NewAuth(in interface{}, context *compiler.Context) (*Auth, error) { +func NewAuth(in *yaml.Node, context *compiler.Context) (*Auth, error) { errors := make([]error, 0) x := &Auth{} m, ok := compiler.UnpackMap(in) @@ -99,7 +99,7 @@ func NewAuth(in interface{}, context *compiler.Context) (*Auth, error) { } // NewDocument creates an object of type Document if possible, returning an error if not. -func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { +func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { errors := make([]error, 0) x := &Document{} m, ok := compiler.UnpackMap(in) @@ -408,7 +408,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { } // NewIcons creates an object of type Icons if possible, returning an error if not. -func NewIcons(in interface{}, context *compiler.Context) (*Icons, error) { +func NewIcons(in *yaml.Node, context *compiler.Context) (*Icons, error) { errors := make([]error, 0) x := &Icons{} m, ok := compiler.UnpackMap(in) @@ -452,7 +452,7 @@ func NewIcons(in interface{}, context *compiler.Context) (*Icons, error) { } // NewMediaUpload creates an object of type MediaUpload if possible, returning an error if not. -func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, error) { +func NewMediaUpload(in *yaml.Node, context *compiler.Context) (*MediaUpload, error) { errors := make([]error, 0) x := &MediaUpload{} m, ok := compiler.UnpackMap(in) @@ -510,7 +510,7 @@ func NewMediaUpload(in interface{}, context *compiler.Context) (*MediaUpload, er } // NewMethod creates an object of type Method if possible, returning an error if not. -func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { +func NewMethod(in *yaml.Node, context *compiler.Context) (*Method, error) { errors := make([]error, 0) x := &Method{} m, ok := compiler.UnpackMap(in) @@ -678,7 +678,7 @@ func NewMethod(in interface{}, context *compiler.Context) (*Method, error) { } // NewMethods creates an object of type Methods if possible, returning an error if not. -func NewMethods(in interface{}, context *compiler.Context) (*Methods, error) { +func NewMethods(in *yaml.Node, context *compiler.Context) (*Methods, error) { errors := make([]error, 0) x := &Methods{} m, ok := compiler.UnpackMap(in) @@ -708,7 +708,7 @@ func NewMethods(in interface{}, context *compiler.Context) (*Methods, error) { } // NewNamedMethod creates an object of type NamedMethod if possible, returning an error if not. -func NewNamedMethod(in interface{}, context *compiler.Context) (*NamedMethod, error) { +func NewNamedMethod(in *yaml.Node, context *compiler.Context) (*NamedMethod, error) { errors := make([]error, 0) x := &NamedMethod{} m, ok := compiler.UnpackMap(in) @@ -746,7 +746,7 @@ func NewNamedMethod(in interface{}, context *compiler.Context) (*NamedMethod, er } // NewNamedParameter creates an object of type NamedParameter if possible, returning an error if not. -func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParameter, error) { +func NewNamedParameter(in *yaml.Node, context *compiler.Context) (*NamedParameter, error) { errors := make([]error, 0) x := &NamedParameter{} m, ok := compiler.UnpackMap(in) @@ -784,7 +784,7 @@ func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParamet } // NewNamedResource creates an object of type NamedResource if possible, returning an error if not. -func NewNamedResource(in interface{}, context *compiler.Context) (*NamedResource, error) { +func NewNamedResource(in *yaml.Node, context *compiler.Context) (*NamedResource, error) { errors := make([]error, 0) x := &NamedResource{} m, ok := compiler.UnpackMap(in) @@ -822,7 +822,7 @@ func NewNamedResource(in interface{}, context *compiler.Context) (*NamedResource } // NewNamedSchema creates an object of type NamedSchema if possible, returning an error if not. -func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, error) { +func NewNamedSchema(in *yaml.Node, context *compiler.Context) (*NamedSchema, error) { errors := make([]error, 0) x := &NamedSchema{} m, ok := compiler.UnpackMap(in) @@ -860,7 +860,7 @@ func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, er } // NewNamedScope creates an object of type NamedScope if possible, returning an error if not. -func NewNamedScope(in interface{}, context *compiler.Context) (*NamedScope, error) { +func NewNamedScope(in *yaml.Node, context *compiler.Context) (*NamedScope, error) { errors := make([]error, 0) x := &NamedScope{} m, ok := compiler.UnpackMap(in) @@ -898,7 +898,7 @@ func NewNamedScope(in interface{}, context *compiler.Context) (*NamedScope, erro } // NewOauth2 creates an object of type Oauth2 if possible, returning an error if not. -func NewOauth2(in interface{}, context *compiler.Context) (*Oauth2, error) { +func NewOauth2(in *yaml.Node, context *compiler.Context) (*Oauth2, error) { errors := make([]error, 0) x := &Oauth2{} m, ok := compiler.UnpackMap(in) @@ -927,7 +927,7 @@ func NewOauth2(in interface{}, context *compiler.Context) (*Oauth2, error) { } // NewParameter creates an object of type Parameter if possible, returning an error if not. -func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) { +func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) { errors := make([]error, 0) x := &Parameter{} m, ok := compiler.UnpackMap(in) @@ -1113,7 +1113,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) } // NewParameters creates an object of type Parameters if possible, returning an error if not. -func NewParameters(in interface{}, context *compiler.Context) (*Parameters, error) { +func NewParameters(in *yaml.Node, context *compiler.Context) (*Parameters, error) { errors := make([]error, 0) x := &Parameters{} m, ok := compiler.UnpackMap(in) @@ -1143,7 +1143,7 @@ func NewParameters(in interface{}, context *compiler.Context) (*Parameters, erro } // NewProtocols creates an object of type Protocols if possible, returning an error if not. -func NewProtocols(in interface{}, context *compiler.Context) (*Protocols, error) { +func NewProtocols(in *yaml.Node, context *compiler.Context) (*Protocols, error) { errors := make([]error, 0) x := &Protocols{} m, ok := compiler.UnpackMap(in) @@ -1181,7 +1181,7 @@ func NewProtocols(in interface{}, context *compiler.Context) (*Protocols, error) } // NewRequest creates an object of type Request if possible, returning an error if not. -func NewRequest(in interface{}, context *compiler.Context) (*Request, error) { +func NewRequest(in *yaml.Node, context *compiler.Context) (*Request, error) { errors := make([]error, 0) x := &Request{} m, ok := compiler.UnpackMap(in) @@ -1219,7 +1219,7 @@ func NewRequest(in interface{}, context *compiler.Context) (*Request, error) { } // NewResource creates an object of type Resource if possible, returning an error if not. -func NewResource(in interface{}, context *compiler.Context) (*Resource, error) { +func NewResource(in *yaml.Node, context *compiler.Context) (*Resource, error) { errors := make([]error, 0) x := &Resource{} m, ok := compiler.UnpackMap(in) @@ -1257,7 +1257,7 @@ func NewResource(in interface{}, context *compiler.Context) (*Resource, error) { } // NewResources creates an object of type Resources if possible, returning an error if not. -func NewResources(in interface{}, context *compiler.Context) (*Resources, error) { +func NewResources(in *yaml.Node, context *compiler.Context) (*Resources, error) { errors := make([]error, 0) x := &Resources{} m, ok := compiler.UnpackMap(in) @@ -1287,7 +1287,7 @@ func NewResources(in interface{}, context *compiler.Context) (*Resources, error) } // NewResponse creates an object of type Response if possible, returning an error if not. -func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { +func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { errors := make([]error, 0) x := &Response{} m, ok := compiler.UnpackMap(in) @@ -1316,7 +1316,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { } // NewResumable creates an object of type Resumable if possible, returning an error if not. -func NewResumable(in interface{}, context *compiler.Context) (*Resumable, error) { +func NewResumable(in *yaml.Node, context *compiler.Context) (*Resumable, error) { errors := make([]error, 0) x := &Resumable{} m, ok := compiler.UnpackMap(in) @@ -1354,7 +1354,7 @@ func NewResumable(in interface{}, context *compiler.Context) (*Resumable, error) } // NewSchema creates an object of type Schema if possible, returning an error if not. -func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { +func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { errors := make([]error, 0) x := &Schema{} m, ok := compiler.UnpackMap(in) @@ -1549,7 +1549,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { } // NewSchemas creates an object of type Schemas if possible, returning an error if not. -func NewSchemas(in interface{}, context *compiler.Context) (*Schemas, error) { +func NewSchemas(in *yaml.Node, context *compiler.Context) (*Schemas, error) { errors := make([]error, 0) x := &Schemas{} m, ok := compiler.UnpackMap(in) @@ -1579,7 +1579,7 @@ func NewSchemas(in interface{}, context *compiler.Context) (*Schemas, error) { } // NewScope creates an object of type Scope if possible, returning an error if not. -func NewScope(in interface{}, context *compiler.Context) (*Scope, error) { +func NewScope(in *yaml.Node, context *compiler.Context) (*Scope, error) { errors := make([]error, 0) x := &Scope{} m, ok := compiler.UnpackMap(in) @@ -1608,7 +1608,7 @@ func NewScope(in interface{}, context *compiler.Context) (*Scope, error) { } // NewScopes creates an object of type Scopes if possible, returning an error if not. -func NewScopes(in interface{}, context *compiler.Context) (*Scopes, error) { +func NewScopes(in *yaml.Node, context *compiler.Context) (*Scopes, error) { errors := make([]error, 0) x := &Scopes{} m, ok := compiler.UnpackMap(in) @@ -1638,7 +1638,7 @@ func NewScopes(in interface{}, context *compiler.Context) (*Scopes, error) { } // NewSimple creates an object of type Simple if possible, returning an error if not. -func NewSimple(in interface{}, context *compiler.Context) (*Simple, error) { +func NewSimple(in *yaml.Node, context *compiler.Context) (*Simple, error) { errors := make([]error, 0) x := &Simple{} m, ok := compiler.UnpackMap(in) @@ -1676,36 +1676,31 @@ func NewSimple(in interface{}, context *compiler.Context) (*Simple, error) { } // NewStringArray creates an object of type StringArray if possible, returning an error if not. -func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, error) { +func NewStringArray(in *yaml.Node, context *compiler.Context) (*StringArray, error) { errors := make([]error, 0) x := &StringArray{} - a, ok := in.([]interface{}) - if !ok { - message := fmt.Sprintf("has unexpected value for StringArray: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - x.Value = make([]string, 0) - for _, s := range a { - x.Value = append(x.Value, s.(string)) - } + x.Value = make([]string, 0) + for _, node := range in.Content { + s, _ := compiler.StringForScalarNode(node) + x.Value = append(x.Value, s) } return x, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside Annotations objects. -func (m *Annotations) ResolveReferences(root string) (interface{}, error) { +func (m *Annotations) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside Any objects. -func (m *Any) ResolveReferences(root string) (interface{}, error) { +func (m *Any) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside Auth objects. -func (m *Auth) ResolveReferences(root string) (interface{}, error) { +func (m *Auth) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Oauth2 != nil { _, err := m.Oauth2.ResolveReferences(root) @@ -1717,7 +1712,7 @@ func (m *Auth) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Document objects. -func (m *Document) ResolveReferences(root string) (interface{}, error) { +func (m *Document) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Icons != nil { _, err := m.Icons.ResolveReferences(root) @@ -1759,13 +1754,13 @@ func (m *Document) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Icons objects. -func (m *Icons) ResolveReferences(root string) (interface{}, error) { +func (m *Icons) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside MediaUpload objects. -func (m *MediaUpload) ResolveReferences(root string) (interface{}, error) { +func (m *MediaUpload) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Protocols != nil { _, err := m.Protocols.ResolveReferences(root) @@ -1777,7 +1772,7 @@ func (m *MediaUpload) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Method objects. -func (m *Method) ResolveReferences(root string) (interface{}, error) { +func (m *Method) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Parameters != nil { _, err := m.Parameters.ResolveReferences(root) @@ -1807,7 +1802,7 @@ func (m *Method) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Methods objects. -func (m *Methods) ResolveReferences(root string) (interface{}, error) { +func (m *Methods) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -1821,7 +1816,7 @@ func (m *Methods) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedMethod objects. -func (m *NamedMethod) ResolveReferences(root string) (interface{}, error) { +func (m *NamedMethod) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -1833,7 +1828,7 @@ func (m *NamedMethod) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedParameter objects. -func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) { +func (m *NamedParameter) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -1845,7 +1840,7 @@ func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedResource objects. -func (m *NamedResource) ResolveReferences(root string) (interface{}, error) { +func (m *NamedResource) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -1857,7 +1852,7 @@ func (m *NamedResource) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedSchema objects. -func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) { +func (m *NamedSchema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -1869,7 +1864,7 @@ func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedScope objects. -func (m *NamedScope) ResolveReferences(root string) (interface{}, error) { +func (m *NamedScope) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -1881,7 +1876,7 @@ func (m *NamedScope) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Oauth2 objects. -func (m *Oauth2) ResolveReferences(root string) (interface{}, error) { +func (m *Oauth2) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Scopes != nil { _, err := m.Scopes.ResolveReferences(root) @@ -1893,7 +1888,7 @@ func (m *Oauth2) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Parameter objects. -func (m *Parameter) ResolveReferences(root string) (interface{}, error) { +func (m *Parameter) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.XRef != "" { info, err := compiler.ReadInfoForRef(root, m.XRef) @@ -1937,7 +1932,7 @@ func (m *Parameter) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Parameters objects. -func (m *Parameters) ResolveReferences(root string) (interface{}, error) { +func (m *Parameters) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -1951,7 +1946,7 @@ func (m *Parameters) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Protocols objects. -func (m *Protocols) ResolveReferences(root string) (interface{}, error) { +func (m *Protocols) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Simple != nil { _, err := m.Simple.ResolveReferences(root) @@ -1969,7 +1964,7 @@ func (m *Protocols) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Request objects. -func (m *Request) ResolveReferences(root string) (interface{}, error) { +func (m *Request) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.XRef != "" { info, err := compiler.ReadInfoForRef(root, m.XRef) @@ -1989,7 +1984,7 @@ func (m *Request) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Resource objects. -func (m *Resource) ResolveReferences(root string) (interface{}, error) { +func (m *Resource) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Methods != nil { _, err := m.Methods.ResolveReferences(root) @@ -2007,7 +2002,7 @@ func (m *Resource) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Resources objects. -func (m *Resources) ResolveReferences(root string) (interface{}, error) { +func (m *Resources) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -2021,7 +2016,7 @@ func (m *Resources) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Response objects. -func (m *Response) ResolveReferences(root string) (interface{}, error) { +func (m *Response) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.XRef != "" { info, err := compiler.ReadInfoForRef(root, m.XRef) @@ -2034,13 +2029,13 @@ func (m *Response) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Resumable objects. -func (m *Resumable) ResolveReferences(root string) (interface{}, error) { +func (m *Resumable) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside Schema objects. -func (m *Schema) ResolveReferences(root string) (interface{}, error) { +func (m *Schema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Properties != nil { _, err := m.Properties.ResolveReferences(root) @@ -2084,7 +2079,7 @@ func (m *Schema) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Schemas objects. -func (m *Schemas) ResolveReferences(root string) (interface{}, error) { +func (m *Schemas) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -2098,13 +2093,13 @@ func (m *Schemas) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Scope objects. -func (m *Scope) ResolveReferences(root string) (interface{}, error) { +func (m *Scope) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside Scopes objects. -func (m *Scopes) ResolveReferences(root string) (interface{}, error) { +func (m *Scopes) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -2118,13 +2113,13 @@ func (m *Scopes) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Simple objects. -func (m *Simple) ResolveReferences(root string) (interface{}, error) { +func (m *Simple) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside StringArray objects. -func (m *StringArray) ResolveReferences(root string) (interface{}, error) { +func (m *StringArray) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } diff --git a/generate-gnostic/generate-compiler.go b/generate-gnostic/generate-compiler.go index c14b0100..abf1295b 100644 --- a/generate-gnostic/generate-compiler.go +++ b/generate-gnostic/generate-compiler.go @@ -134,7 +134,7 @@ func nameForPattern(regexPatterns *patternNames, pattern string) string { func (domain *Domain) generateConstructorForType(code *printer.Code, typeName string, regexPatterns *patternNames) { code.Print("// New%s creates an object of type %s if possible, returning an error if not.", typeName, typeName) - code.Print("func New%s(in interface{}, context *compiler.Context) (*%s, error) {", typeName, typeName) + code.Print("func New%s(in *yaml.Node, context *compiler.Context) (*%s, error) {", typeName, typeName) code.Print("errors := make([]error, 0)") typeModel := domain.TypeModels[typeName] @@ -142,7 +142,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st if typeModel.IsStringArray { code.Print("x := &TypeItem{}") - code.Print("v1, _ := in.(*yaml.Node)") + code.Print("v1 := in") code.Print("switch v1.Kind {") code.Print("case yaml.ScalarNode:") code.Print(" x.Value = make([]string, 0)") @@ -195,27 +195,22 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } } else if typeModel.IsBlob { code.Print("x := &Any{}") - code.Print("bytes := compiler.Marshal(in.(*yaml.Node))") + code.Print("bytes := compiler.Marshal(in)") code.Print("x.Yaml = string(bytes)") } else if typeModel.Name == "StringArray" { code.Print("x := &StringArray{}") - code.Print("a, ok := in.([]interface{})") - code.Print("if !ok {") - code.Print(" message := fmt.Sprintf(\"has unexpected value for StringArray: %%+v (%%T)\", in, in)") - code.Print(" errors = append(errors, compiler.NewError(context, message))") - code.Print("} else {") - code.Print(" x.Value = make([]string, 0)") - code.Print(" for _, s := range a {") - code.Print(" x.Value = append(x.Value, s.(string))") - code.Print(" }") + code.Print("x.Value = make([]string, 0)") + code.Print("for _, node := range in.Content {") + code.Print(" s, _ := compiler.StringForScalarNode(node)") + code.Print(" x.Value = append(x.Value, s)") code.Print("}") } else if typeModel.Name == "Primitive" { code.Print(" x := &Primitive{}") code.Print(" matched := false") - code.Print(" switch in := in.(type) {") - code.Print(" case bool:") - code.Print(" x.Oneof = &Primitive_Boolean{Boolean: in}") - code.Print(" matched = true") + code.Print(" switch in.Tag {") + code.Print(" case \"!!bool\":") + code.Print(" v, matched := compiler.BoolForScalarNode(in)") + code.Print(" x.Oneof = &Primitive_Boolean{Boolean: v}") code.Print(" case string:") code.Print(" x.Oneof = &Primitive_String_{String_: in}") code.Print(" matched = true") @@ -242,28 +237,23 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } else if typeModel.Name == "SpecificationExtension" { code.Print(" x := &SpecificationExtension{}") code.Print(" matched := false") - code.Print(" switch in := in.(type) {") - code.Print(" case bool:") - code.Print(" x.Oneof = &SpecificationExtension_Boolean{Boolean: in}") - code.Print(" matched = true") - code.Print(" case string:") - code.Print(" x.Oneof = &SpecificationExtension_String_{String_: in}") - code.Print(" matched = true") - code.Print(" case int64:") - code.Print(" x.Oneof = &SpecificationExtension_Number{Number: float64(in)}") - code.Print(" matched = true") - code.Print(" case int32:") - code.Print(" x.Oneof = &SpecificationExtension_Number{Number: float64(in)}") - code.Print(" matched = true") - code.Print(" case int:") - code.Print(" x.Oneof = &SpecificationExtension_Number{Number: float64(in)}") - code.Print(" matched = true") - code.Print(" case float64:") - code.Print(" x.Oneof = &SpecificationExtension_Number{Number: in}") - code.Print(" matched = true") - code.Print(" case float32:") - code.Print(" x.Oneof = &SpecificationExtension_Number{Number: float64(in)}") - code.Print(" matched = true") + code.Print(" switch in.Tag {") + code.Print(" case \"!!bool\":") + code.Print(" var v bool") + code.Print(" v, matched = compiler.BoolForScalarNode(in)") + code.Print(" x.Oneof = &SpecificationExtension_Boolean{Boolean: v}") + code.Print(" case \"!!str\":") + code.Print(" var v string") + code.Print(" v, matched = compiler.StringForScalarNode(in)") + code.Print(" x.Oneof = &SpecificationExtension_String_{String_: v}") + code.Print(" case \"!!float\":") + code.Print(" var v float64") + code.Print(" v, matched = compiler.FloatForScalarNode(in)") + code.Print(" x.Oneof = &SpecificationExtension_Number{Number: v}") + code.Print(" case \"!!int\":") + code.Print(" var v int64") + code.Print(" v, matched = compiler.IntForScalarNode(in)") + code.Print(" x.Oneof = &SpecificationExtension_Number{Number: float64(v)}") code.Print(" }") code.Print(" if matched {") code.Print(" // since the oneof matched one of its possibilities, discard any matching errors") @@ -272,28 +262,23 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } else if typeModel.Name == "DefaultType" { code.Print(" x := &DefaultType{}") code.Print(" matched := false") - code.Print(" switch in := in.(type) {") - code.Print(" case bool:") - code.Print(" x.Oneof = &DefaultType_Boolean{Boolean: in}") - code.Print(" matched = true") - code.Print(" case string:") - code.Print(" x.Oneof = &DefaultType_String_{String_: in}") - code.Print(" matched = true") - code.Print(" case int64:") - code.Print(" x.Oneof = &DefaultType_Number{Number: float64(in)}") - code.Print(" matched = true") - code.Print(" case int32:") - code.Print(" x.Oneof = &DefaultType_Number{Number: float64(in)}") - code.Print(" matched = true") - code.Print(" case int:") - code.Print(" x.Oneof = &DefaultType_Number{Number: float64(in)}") - code.Print(" matched = true") - code.Print(" case float64:") - code.Print(" x.Oneof = &DefaultType_Number{Number: in}") - code.Print(" matched = true") - code.Print(" case float32:") - code.Print(" x.Oneof = &DefaultType_Number{Number: float64(in)}") - code.Print(" matched = true") + code.Print(" switch in.Tag {") + code.Print(" case \"!!bool\":") + code.Print(" var v bool") + code.Print(" v, matched = compiler.BoolForScalarNode(in)") + code.Print(" x.Oneof = &DefaultType_Boolean{Boolean: v}") + code.Print(" case \"!!str\":") + code.Print(" var v string") + code.Print(" v, matched = compiler.StringForScalarNode(in)") + code.Print(" x.Oneof = &DefaultType_String_{String_: v}") + code.Print(" case \"!!float\":") + code.Print(" var v float64") + code.Print(" v, matched = compiler.FloatForScalarNode(in)") + code.Print(" x.Oneof = &DefaultType_Number{Number: v}") + code.Print(" case \"!!int\":") + code.Print(" var v int64") + code.Print(" v, matched = compiler.IntForScalarNode(in)") + code.Print(" x.Oneof = &DefaultType_Number{Number: float64(v)}") code.Print(" }") code.Print(" if matched {") code.Print(" // since the oneof matched one of its possibilities, discard any matching errors") @@ -540,7 +525,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st } else if propertyType == "bool" { if oneOfWrapper { propertyName := "Boolean" - code.Print("boolValue, ok := in.(bool)") + code.Print("boolValue, ok := compiler.BoolForScalarNode(in)") code.Print("if ok {") code.Print(" x.Oneof = &%s_%s{%s: boolValue}", parentTypeName, propertyName, propertyName) code.Print(" matched = true") @@ -644,7 +629,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st // ResolveReferences() methods func (domain *Domain) generateResolveReferencesMethodsForType(code *printer.Code, typeName string) { code.Print("// ResolveReferences resolves references found inside %s objects.", typeName) - code.Print("func (m *%s) ResolveReferences(root string) (interface{}, error) {", typeName) + code.Print("func (m *%s) ResolveReferences(root string) (*yaml.Node, error) {", typeName) code.Print("errors := make([]error, 0)") typeModel := domain.TypeModels[typeName] diff --git a/lib/gnostic.go b/lib/gnostic.go index 2f62dc8c..5414396e 100644 --- a/lib/gnostic.go +++ b/lib/gnostic.go @@ -66,7 +66,7 @@ const ( ) // Determine the version of an OpenAPI description read from JSON or YAML. -func getOpenAPIVersionFromInfo(info interface{}) int { +func getOpenAPIVersionFromInfo(info *yaml.Node) int { m, ok := compiler.UnpackMap(info) if !ok { return SourceFormatUnknown diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index e32a2c99..8a08a616 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -30,7 +30,7 @@ func Version() string { } // NewAdditionalPropertiesItem creates an object of type AdditionalPropertiesItem if possible, returning an error if not. -func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*AdditionalPropertiesItem, error) { +func NewAdditionalPropertiesItem(in *yaml.Node, context *compiler.Context) (*AdditionalPropertiesItem, error) { errors := make([]error, 0) x := &AdditionalPropertiesItem{} matched := false @@ -49,7 +49,7 @@ func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*Ad } } // bool boolean = 2; - boolValue, ok := in.(bool) + boolValue, ok := compiler.BoolForScalarNode(in) if ok { x.Oneof = &AdditionalPropertiesItem_Boolean{Boolean: boolValue} matched = true @@ -62,16 +62,16 @@ func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*Ad } // NewAny creates an object of type Any if possible, returning an error if not. -func NewAny(in interface{}, context *compiler.Context) (*Any, error) { +func NewAny(in *yaml.Node, context *compiler.Context) (*Any, error) { errors := make([]error, 0) x := &Any{} - bytes := compiler.Marshal(in.(*yaml.Node)) + bytes := compiler.Marshal(in) x.Yaml = string(bytes) 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) { +func NewApiKeySecurity(in *yaml.Node, context *compiler.Context) (*ApiKeySecurity, error) { errors := make([]error, 0) x := &ApiKeySecurity{} m, ok := compiler.UnpackMap(in) @@ -176,7 +176,7 @@ func NewApiKeySecurity(in interface{}, context *compiler.Context) (*ApiKeySecuri } // NewBasicAuthenticationSecurity creates an object of type BasicAuthenticationSecurity if possible, returning an error if not. -func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) (*BasicAuthenticationSecurity, error) { +func NewBasicAuthenticationSecurity(in *yaml.Node, context *compiler.Context) (*BasicAuthenticationSecurity, error) { errors := make([]error, 0) x := &BasicAuthenticationSecurity{} m, ok := compiler.UnpackMap(in) @@ -257,7 +257,7 @@ func NewBasicAuthenticationSecurity(in interface{}, context *compiler.Context) ( } // NewBodyParameter creates an object of type BodyParameter if possible, returning an error if not. -func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter, error) { +func NewBodyParameter(in *yaml.Node, context *compiler.Context) (*BodyParameter, error) { errors := make([]error, 0) x := &BodyParameter{} m, ok := compiler.UnpackMap(in) @@ -365,7 +365,7 @@ func NewBodyParameter(in interface{}, context *compiler.Context) (*BodyParameter } // NewContact creates an object of type Contact if possible, returning an error if not. -func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { +func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { errors := make([]error, 0) x := &Contact{} m, ok := compiler.UnpackMap(in) @@ -443,7 +443,7 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { } // NewDefault creates an object of type Default if possible, returning an error if not. -func NewDefault(in interface{}, context *compiler.Context) (*Default, error) { +func NewDefault(in *yaml.Node, context *compiler.Context) (*Default, error) { errors := make([]error, 0) x := &Default{} m, ok := compiler.UnpackMap(in) @@ -485,7 +485,7 @@ func NewDefault(in interface{}, context *compiler.Context) (*Default, error) { } // NewDefinitions creates an object of type Definitions if possible, returning an error if not. -func NewDefinitions(in interface{}, context *compiler.Context) (*Definitions, error) { +func NewDefinitions(in *yaml.Node, context *compiler.Context) (*Definitions, error) { errors := make([]error, 0) x := &Definitions{} m, ok := compiler.UnpackMap(in) @@ -515,7 +515,7 @@ func NewDefinitions(in interface{}, context *compiler.Context) (*Definitions, er } // NewDocument creates an object of type Document if possible, returning an error if not. -func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { +func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { errors := make([]error, 0) x := &Document{} m, ok := compiler.UnpackMap(in) @@ -739,7 +739,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { } // NewExamples creates an object of type Examples if possible, returning an error if not. -func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) { +func NewExamples(in *yaml.Node, context *compiler.Context) (*Examples, error) { errors := make([]error, 0) x := &Examples{} m, ok := compiler.UnpackMap(in) @@ -781,7 +781,7 @@ func NewExamples(in interface{}, context *compiler.Context) (*Examples, error) { } // NewExternalDocs creates an object of type ExternalDocs if possible, returning an error if not. -func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, error) { +func NewExternalDocs(in *yaml.Node, context *compiler.Context) (*ExternalDocs, error) { errors := make([]error, 0) x := &ExternalDocs{} m, ok := compiler.UnpackMap(in) @@ -856,7 +856,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, } // NewFileSchema creates an object of type FileSchema if possible, returning an error if not. -func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, error) { +func NewFileSchema(in *yaml.Node, context *compiler.Context) (*FileSchema, error) { errors := make([]error, 0) x := &FileSchema{} m, ok := compiler.UnpackMap(in) @@ -1002,7 +1002,7 @@ func NewFileSchema(in interface{}, context *compiler.Context) (*FileSchema, erro } // NewFormDataParameterSubSchema creates an object of type FormDataParameterSubSchema if possible, returning an error if not. -func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (*FormDataParameterSubSchema, error) { +func NewFormDataParameterSubSchema(in *yaml.Node, context *compiler.Context) (*FormDataParameterSubSchema, error) { errors := make([]error, 0) x := &FormDataParameterSubSchema{} m, ok := compiler.UnpackMap(in) @@ -1290,7 +1290,7 @@ func NewFormDataParameterSubSchema(in interface{}, context *compiler.Context) (* } // NewHeader creates an object of type Header if possible, returning an error if not. -func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { +func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { errors := make([]error, 0) x := &Header{} m, ok := compiler.UnpackMap(in) @@ -1542,7 +1542,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { } // NewHeaderParameterSubSchema creates an object of type HeaderParameterSubSchema if possible, returning an error if not. -func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*HeaderParameterSubSchema, error) { +func NewHeaderParameterSubSchema(in *yaml.Node, context *compiler.Context) (*HeaderParameterSubSchema, error) { errors := make([]error, 0) x := &HeaderParameterSubSchema{} m, ok := compiler.UnpackMap(in) @@ -1821,7 +1821,7 @@ func NewHeaderParameterSubSchema(in interface{}, context *compiler.Context) (*He } // NewHeaders creates an object of type Headers if possible, returning an error if not. -func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) { +func NewHeaders(in *yaml.Node, context *compiler.Context) (*Headers, error) { errors := make([]error, 0) x := &Headers{} m, ok := compiler.UnpackMap(in) @@ -1851,7 +1851,7 @@ func NewHeaders(in interface{}, context *compiler.Context) (*Headers, error) { } // NewInfo creates an object of type Info if possible, returning an error if not. -func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { +func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { errors := make([]error, 0) x := &Info{} m, ok := compiler.UnpackMap(in) @@ -1962,7 +1962,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { } // NewItemsItem creates an object of type ItemsItem if possible, returning an error if not. -func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) { +func NewItemsItem(in *yaml.Node, context *compiler.Context) (*ItemsItem, error) { errors := make([]error, 0) x := &ItemsItem{} m, ok := compiler.UnpackMap(in) @@ -1981,7 +1981,7 @@ func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) } // NewJsonReference creates an object of type JsonReference if possible, returning an error if not. -func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference, error) { +func NewJsonReference(in *yaml.Node, context *compiler.Context) (*JsonReference, error) { errors := make([]error, 0) x := &JsonReference{} m, ok := compiler.UnpackMap(in) @@ -2018,7 +2018,7 @@ func NewJsonReference(in interface{}, context *compiler.Context) (*JsonReference } // NewLicense creates an object of type License if possible, returning an error if not. -func NewLicense(in interface{}, context *compiler.Context) (*License, error) { +func NewLicense(in *yaml.Node, context *compiler.Context) (*License, error) { errors := make([]error, 0) x := &License{} m, ok := compiler.UnpackMap(in) @@ -2093,7 +2093,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { } // NewNamedAny creates an object of type NamedAny if possible, returning an error if not. -func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { +func NewNamedAny(in *yaml.Node, context *compiler.Context) (*NamedAny, error) { errors := make([]error, 0) x := &NamedAny{} m, ok := compiler.UnpackMap(in) @@ -2131,7 +2131,7 @@ func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { } // NewNamedHeader creates an object of type NamedHeader if possible, returning an error if not. -func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, error) { +func NewNamedHeader(in *yaml.Node, context *compiler.Context) (*NamedHeader, error) { errors := make([]error, 0) x := &NamedHeader{} m, ok := compiler.UnpackMap(in) @@ -2169,7 +2169,7 @@ func NewNamedHeader(in interface{}, context *compiler.Context) (*NamedHeader, er } // NewNamedParameter creates an object of type NamedParameter if possible, returning an error if not. -func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParameter, error) { +func NewNamedParameter(in *yaml.Node, context *compiler.Context) (*NamedParameter, error) { errors := make([]error, 0) x := &NamedParameter{} m, ok := compiler.UnpackMap(in) @@ -2207,7 +2207,7 @@ func NewNamedParameter(in interface{}, context *compiler.Context) (*NamedParamet } // NewNamedPathItem creates an object of type NamedPathItem if possible, returning an error if not. -func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem, error) { +func NewNamedPathItem(in *yaml.Node, context *compiler.Context) (*NamedPathItem, error) { errors := make([]error, 0) x := &NamedPathItem{} m, ok := compiler.UnpackMap(in) @@ -2245,7 +2245,7 @@ func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem } // NewNamedResponse creates an object of type NamedResponse if possible, returning an error if not. -func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse, error) { +func NewNamedResponse(in *yaml.Node, context *compiler.Context) (*NamedResponse, error) { errors := make([]error, 0) x := &NamedResponse{} m, ok := compiler.UnpackMap(in) @@ -2283,7 +2283,7 @@ func NewNamedResponse(in interface{}, context *compiler.Context) (*NamedResponse } // NewNamedResponseValue creates an object of type NamedResponseValue if possible, returning an error if not. -func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedResponseValue, error) { +func NewNamedResponseValue(in *yaml.Node, context *compiler.Context) (*NamedResponseValue, error) { errors := make([]error, 0) x := &NamedResponseValue{} m, ok := compiler.UnpackMap(in) @@ -2321,7 +2321,7 @@ func NewNamedResponseValue(in interface{}, context *compiler.Context) (*NamedRes } // NewNamedSchema creates an object of type NamedSchema if possible, returning an error if not. -func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, error) { +func NewNamedSchema(in *yaml.Node, context *compiler.Context) (*NamedSchema, error) { errors := make([]error, 0) x := &NamedSchema{} m, ok := compiler.UnpackMap(in) @@ -2359,7 +2359,7 @@ func NewNamedSchema(in interface{}, context *compiler.Context) (*NamedSchema, er } // NewNamedSecurityDefinitionsItem creates an object of type NamedSecurityDefinitionsItem if possible, returning an error if not. -func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*NamedSecurityDefinitionsItem, error) { +func NewNamedSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*NamedSecurityDefinitionsItem, error) { errors := make([]error, 0) x := &NamedSecurityDefinitionsItem{} m, ok := compiler.UnpackMap(in) @@ -2397,7 +2397,7 @@ func NewNamedSecurityDefinitionsItem(in interface{}, context *compiler.Context) } // NewNamedString creates an object of type NamedString if possible, returning an error if not. -func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, error) { +func NewNamedString(in *yaml.Node, context *compiler.Context) (*NamedString, error) { errors := make([]error, 0) x := &NamedString{} m, ok := compiler.UnpackMap(in) @@ -2435,7 +2435,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er } // NewNamedStringArray creates an object of type NamedStringArray if possible, returning an error if not. -func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStringArray, error) { +func NewNamedStringArray(in *yaml.Node, context *compiler.Context) (*NamedStringArray, error) { errors := make([]error, 0) x := &NamedStringArray{} m, ok := compiler.UnpackMap(in) @@ -2473,7 +2473,7 @@ func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStrin } // NewNonBodyParameter creates an object of type NonBodyParameter if possible, returning an error if not. -func NewNonBodyParameter(in interface{}, context *compiler.Context) (*NonBodyParameter, error) { +func NewNonBodyParameter(in *yaml.Node, context *compiler.Context) (*NonBodyParameter, error) { errors := make([]error, 0) x := &NonBodyParameter{} matched := false @@ -2541,7 +2541,7 @@ func NewNonBodyParameter(in interface{}, context *compiler.Context) (*NonBodyPar } // NewOauth2AccessCodeSecurity creates an object of type Oauth2AccessCodeSecurity if possible, returning an error if not. -func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oauth2AccessCodeSecurity, error) { +func NewOauth2AccessCodeSecurity(in *yaml.Node, context *compiler.Context) (*Oauth2AccessCodeSecurity, error) { errors := make([]error, 0) x := &Oauth2AccessCodeSecurity{} m, ok := compiler.UnpackMap(in) @@ -2664,7 +2664,7 @@ func NewOauth2AccessCodeSecurity(in interface{}, context *compiler.Context) (*Oa } // NewOauth2ApplicationSecurity creates an object of type Oauth2ApplicationSecurity if possible, returning an error if not. -func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*Oauth2ApplicationSecurity, error) { +func NewOauth2ApplicationSecurity(in *yaml.Node, context *compiler.Context) (*Oauth2ApplicationSecurity, error) { errors := make([]error, 0) x := &Oauth2ApplicationSecurity{} m, ok := compiler.UnpackMap(in) @@ -2778,7 +2778,7 @@ func NewOauth2ApplicationSecurity(in interface{}, context *compiler.Context) (*O } // NewOauth2ImplicitSecurity creates an object of type Oauth2ImplicitSecurity if possible, returning an error if not. -func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oauth2ImplicitSecurity, error) { +func NewOauth2ImplicitSecurity(in *yaml.Node, context *compiler.Context) (*Oauth2ImplicitSecurity, error) { errors := make([]error, 0) x := &Oauth2ImplicitSecurity{} m, ok := compiler.UnpackMap(in) @@ -2892,7 +2892,7 @@ func NewOauth2ImplicitSecurity(in interface{}, context *compiler.Context) (*Oaut } // NewOauth2PasswordSecurity creates an object of type Oauth2PasswordSecurity if possible, returning an error if not. -func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oauth2PasswordSecurity, error) { +func NewOauth2PasswordSecurity(in *yaml.Node, context *compiler.Context) (*Oauth2PasswordSecurity, error) { errors := make([]error, 0) x := &Oauth2PasswordSecurity{} m, ok := compiler.UnpackMap(in) @@ -3006,7 +3006,7 @@ func NewOauth2PasswordSecurity(in interface{}, context *compiler.Context) (*Oaut } // NewOauth2Scopes creates an object of type Oauth2Scopes if possible, returning an error if not. -func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, error) { +func NewOauth2Scopes(in *yaml.Node, context *compiler.Context) (*Oauth2Scopes, error) { errors := make([]error, 0) x := &Oauth2Scopes{} m, ok := compiler.UnpackMap(in) @@ -3032,7 +3032,7 @@ func NewOauth2Scopes(in interface{}, context *compiler.Context) (*Oauth2Scopes, } // NewOperation creates an object of type Operation if possible, returning an error if not. -func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) { +func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) { errors := make([]error, 0) x := &Operation{} m, ok := compiler.UnpackMap(in) @@ -3225,7 +3225,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) } // NewParameter creates an object of type Parameter if possible, returning an error if not. -func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) { +func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) { errors := make([]error, 0) x := &Parameter{} matched := false @@ -3265,7 +3265,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) } // NewParameterDefinitions creates an object of type ParameterDefinitions if possible, returning an error if not. -func NewParameterDefinitions(in interface{}, context *compiler.Context) (*ParameterDefinitions, error) { +func NewParameterDefinitions(in *yaml.Node, context *compiler.Context) (*ParameterDefinitions, error) { errors := make([]error, 0) x := &ParameterDefinitions{} m, ok := compiler.UnpackMap(in) @@ -3295,7 +3295,7 @@ func NewParameterDefinitions(in interface{}, context *compiler.Context) (*Parame } // NewParametersItem creates an object of type ParametersItem if possible, returning an error if not. -func NewParametersItem(in interface{}, context *compiler.Context) (*ParametersItem, error) { +func NewParametersItem(in *yaml.Node, context *compiler.Context) (*ParametersItem, error) { errors := make([]error, 0) x := &ParametersItem{} matched := false @@ -3335,7 +3335,7 @@ func NewParametersItem(in interface{}, context *compiler.Context) (*ParametersIt } // NewPathItem creates an object of type PathItem if possible, returning an error if not. -func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { +func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { errors := make([]error, 0) x := &PathItem{} m, ok := compiler.UnpackMap(in) @@ -3474,7 +3474,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { } // NewPathParameterSubSchema creates an object of type PathParameterSubSchema if possible, returning an error if not. -func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*PathParameterSubSchema, error) { +func NewPathParameterSubSchema(in *yaml.Node, context *compiler.Context) (*PathParameterSubSchema, error) { errors := make([]error, 0) x := &PathParameterSubSchema{} m, ok := compiler.UnpackMap(in) @@ -3759,7 +3759,7 @@ func NewPathParameterSubSchema(in interface{}, context *compiler.Context) (*Path } // NewPaths creates an object of type Paths if possible, returning an error if not. -func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { +func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { errors := make([]error, 0) x := &Paths{} m, ok := compiler.UnpackMap(in) @@ -3829,7 +3829,7 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { } // NewPrimitivesItems creates an object of type PrimitivesItems if possible, returning an error if not. -func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesItems, error) { +func NewPrimitivesItems(in *yaml.Node, context *compiler.Context) (*PrimitivesItems, error) { errors := make([]error, 0) x := &PrimitivesItems{} m, ok := compiler.UnpackMap(in) @@ -4066,7 +4066,7 @@ func NewPrimitivesItems(in interface{}, context *compiler.Context) (*PrimitivesI } // NewProperties creates an object of type Properties if possible, returning an error if not. -func NewProperties(in interface{}, context *compiler.Context) (*Properties, error) { +func NewProperties(in *yaml.Node, context *compiler.Context) (*Properties, error) { errors := make([]error, 0) x := &Properties{} m, ok := compiler.UnpackMap(in) @@ -4096,7 +4096,7 @@ func NewProperties(in interface{}, context *compiler.Context) (*Properties, erro } // NewQueryParameterSubSchema creates an object of type QueryParameterSubSchema if possible, returning an error if not. -func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*QueryParameterSubSchema, error) { +func NewQueryParameterSubSchema(in *yaml.Node, context *compiler.Context) (*QueryParameterSubSchema, error) { errors := make([]error, 0) x := &QueryParameterSubSchema{} m, ok := compiler.UnpackMap(in) @@ -4384,7 +4384,7 @@ func NewQueryParameterSubSchema(in interface{}, context *compiler.Context) (*Que } // NewResponse creates an object of type Response if possible, returning an error if not. -func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { +func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { errors := make([]error, 0) x := &Response{} m, ok := compiler.UnpackMap(in) @@ -4477,7 +4477,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { } // NewResponseDefinitions creates an object of type ResponseDefinitions if possible, returning an error if not. -func NewResponseDefinitions(in interface{}, context *compiler.Context) (*ResponseDefinitions, error) { +func NewResponseDefinitions(in *yaml.Node, context *compiler.Context) (*ResponseDefinitions, error) { errors := make([]error, 0) x := &ResponseDefinitions{} m, ok := compiler.UnpackMap(in) @@ -4507,7 +4507,7 @@ func NewResponseDefinitions(in interface{}, context *compiler.Context) (*Respons } // NewResponseValue creates an object of type ResponseValue if possible, returning an error if not. -func NewResponseValue(in interface{}, context *compiler.Context) (*ResponseValue, error) { +func NewResponseValue(in *yaml.Node, context *compiler.Context) (*ResponseValue, error) { errors := make([]error, 0) x := &ResponseValue{} matched := false @@ -4547,7 +4547,7 @@ func NewResponseValue(in interface{}, context *compiler.Context) (*ResponseValue } // NewResponses creates an object of type Responses if possible, returning an error if not. -func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) { +func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) { errors := make([]error, 0) x := &Responses{} m, ok := compiler.UnpackMap(in) @@ -4617,7 +4617,7 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) } // NewSchema creates an object of type Schema if possible, returning an error if not. -func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { +func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { errors := make([]error, 0) x := &Schema{} m, ok := compiler.UnpackMap(in) @@ -4972,7 +4972,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { } // NewSchemaItem creates an object of type SchemaItem if possible, returning an error if not. -func NewSchemaItem(in interface{}, context *compiler.Context) (*SchemaItem, error) { +func NewSchemaItem(in *yaml.Node, context *compiler.Context) (*SchemaItem, error) { errors := make([]error, 0) x := &SchemaItem{} matched := false @@ -5012,7 +5012,7 @@ func NewSchemaItem(in interface{}, context *compiler.Context) (*SchemaItem, erro } // NewSecurityDefinitions creates an object of type SecurityDefinitions if possible, returning an error if not. -func NewSecurityDefinitions(in interface{}, context *compiler.Context) (*SecurityDefinitions, error) { +func NewSecurityDefinitions(in *yaml.Node, context *compiler.Context) (*SecurityDefinitions, error) { errors := make([]error, 0) x := &SecurityDefinitions{} m, ok := compiler.UnpackMap(in) @@ -5042,7 +5042,7 @@ func NewSecurityDefinitions(in interface{}, context *compiler.Context) (*Securit } // NewSecurityDefinitionsItem creates an object of type SecurityDefinitionsItem if possible, returning an error if not. -func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*SecurityDefinitionsItem, error) { +func NewSecurityDefinitionsItem(in *yaml.Node, context *compiler.Context) (*SecurityDefinitionsItem, error) { errors := make([]error, 0) x := &SecurityDefinitionsItem{} matched := false @@ -5138,7 +5138,7 @@ func NewSecurityDefinitionsItem(in interface{}, context *compiler.Context) (*Sec } // NewSecurityRequirement creates an object of type SecurityRequirement if possible, returning an error if not. -func NewSecurityRequirement(in interface{}, context *compiler.Context) (*SecurityRequirement, error) { +func NewSecurityRequirement(in *yaml.Node, context *compiler.Context) (*SecurityRequirement, error) { errors := make([]error, 0) x := &SecurityRequirement{} m, ok := compiler.UnpackMap(in) @@ -5168,24 +5168,19 @@ func NewSecurityRequirement(in interface{}, context *compiler.Context) (*Securit } // NewStringArray creates an object of type StringArray if possible, returning an error if not. -func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, error) { +func NewStringArray(in *yaml.Node, context *compiler.Context) (*StringArray, error) { errors := make([]error, 0) x := &StringArray{} - a, ok := in.([]interface{}) - if !ok { - message := fmt.Sprintf("has unexpected value for StringArray: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - x.Value = make([]string, 0) - for _, s := range a { - x.Value = append(x.Value, s.(string)) - } + x.Value = make([]string, 0) + for _, node := range in.Content { + s, _ := compiler.StringForScalarNode(node) + x.Value = append(x.Value, s) } 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) { +func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { errors := make([]error, 0) x := &Tag{} m, ok := compiler.UnpackMap(in) @@ -5269,10 +5264,10 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { } // NewTypeItem creates an object of type TypeItem if possible, returning an error if not. -func NewTypeItem(in interface{}, context *compiler.Context) (*TypeItem, error) { +func NewTypeItem(in *yaml.Node, context *compiler.Context) (*TypeItem, error) { errors := make([]error, 0) x := &TypeItem{} - v1, _ := in.(*yaml.Node) + v1 := in switch v1.Kind { case yaml.ScalarNode: x.Value = make([]string, 0) @@ -5297,7 +5292,7 @@ func NewTypeItem(in interface{}, context *compiler.Context) (*TypeItem, error) { } // NewVendorExtension creates an object of type VendorExtension if possible, returning an error if not. -func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExtension, error) { +func NewVendorExtension(in *yaml.Node, context *compiler.Context) (*VendorExtension, error) { errors := make([]error, 0) x := &VendorExtension{} m, ok := compiler.UnpackMap(in) @@ -5339,7 +5334,7 @@ func NewVendorExtension(in interface{}, context *compiler.Context) (*VendorExten } // NewXml creates an object of type Xml if possible, returning an error if not. -func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { +func NewXml(in *yaml.Node, context *compiler.Context) (*Xml, error) { errors := make([]error, 0) x := &Xml{} m, ok := compiler.UnpackMap(in) @@ -5435,7 +5430,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { } // ResolveReferences resolves references found inside AdditionalPropertiesItem objects. -func (m *AdditionalPropertiesItem) ResolveReferences(root string) (interface{}, error) { +func (m *AdditionalPropertiesItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*AdditionalPropertiesItem_Schema) @@ -5450,13 +5445,13 @@ func (m *AdditionalPropertiesItem) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside Any objects. -func (m *Any) ResolveReferences(root string) (interface{}, error) { +func (m *Any) ResolveReferences(root string) (*yaml.Node, 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) { +func (m *ApiKeySecurity) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { if item != nil { @@ -5470,7 +5465,7 @@ func (m *ApiKeySecurity) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside BasicAuthenticationSecurity objects. -func (m *BasicAuthenticationSecurity) ResolveReferences(root string) (interface{}, error) { +func (m *BasicAuthenticationSecurity) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { if item != nil { @@ -5484,7 +5479,7 @@ func (m *BasicAuthenticationSecurity) ResolveReferences(root string) (interface{ } // ResolveReferences resolves references found inside BodyParameter objects. -func (m *BodyParameter) ResolveReferences(root string) (interface{}, error) { +func (m *BodyParameter) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Schema != nil { _, err := m.Schema.ResolveReferences(root) @@ -5504,7 +5499,7 @@ func (m *BodyParameter) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Contact objects. -func (m *Contact) ResolveReferences(root string) (interface{}, error) { +func (m *Contact) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { if item != nil { @@ -5518,7 +5513,7 @@ func (m *Contact) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Default objects. -func (m *Default) ResolveReferences(root string) (interface{}, error) { +func (m *Default) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5532,7 +5527,7 @@ func (m *Default) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Definitions objects. -func (m *Definitions) ResolveReferences(root string) (interface{}, error) { +func (m *Definitions) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5546,7 +5541,7 @@ func (m *Definitions) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Document objects. -func (m *Document) ResolveReferences(root string) (interface{}, error) { +func (m *Document) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Info != nil { _, err := m.Info.ResolveReferences(root) @@ -5618,7 +5613,7 @@ func (m *Document) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Examples objects. -func (m *Examples) ResolveReferences(root string) (interface{}, error) { +func (m *Examples) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5632,7 +5627,7 @@ func (m *Examples) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ExternalDocs objects. -func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) { +func (m *ExternalDocs) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { if item != nil { @@ -5646,7 +5641,7 @@ func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside FileSchema objects. -func (m *FileSchema) ResolveReferences(root string) (interface{}, error) { +func (m *FileSchema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Default != nil { _, err := m.Default.ResolveReferences(root) @@ -5678,7 +5673,7 @@ func (m *FileSchema) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside FormDataParameterSubSchema objects. -func (m *FormDataParameterSubSchema) ResolveReferences(root string) (interface{}, error) { +func (m *FormDataParameterSubSchema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Items != nil { _, err := m.Items.ResolveReferences(root) @@ -5712,7 +5707,7 @@ func (m *FormDataParameterSubSchema) ResolveReferences(root string) (interface{} } // ResolveReferences resolves references found inside Header objects. -func (m *Header) ResolveReferences(root string) (interface{}, error) { +func (m *Header) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Items != nil { _, err := m.Items.ResolveReferences(root) @@ -5746,7 +5741,7 @@ func (m *Header) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside HeaderParameterSubSchema objects. -func (m *HeaderParameterSubSchema) ResolveReferences(root string) (interface{}, error) { +func (m *HeaderParameterSubSchema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Items != nil { _, err := m.Items.ResolveReferences(root) @@ -5780,7 +5775,7 @@ func (m *HeaderParameterSubSchema) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside Headers objects. -func (m *Headers) ResolveReferences(root string) (interface{}, error) { +func (m *Headers) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5794,7 +5789,7 @@ func (m *Headers) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Info objects. -func (m *Info) ResolveReferences(root string) (interface{}, error) { +func (m *Info) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Contact != nil { _, err := m.Contact.ResolveReferences(root) @@ -5820,7 +5815,7 @@ func (m *Info) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ItemsItem objects. -func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) { +func (m *ItemsItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.Schema { if item != nil { @@ -5834,7 +5829,7 @@ func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside JsonReference objects. -func (m *JsonReference) ResolveReferences(root string) (interface{}, error) { +func (m *JsonReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.XRef != "" { info, err := compiler.ReadInfoForRef(root, m.XRef) @@ -5854,7 +5849,7 @@ func (m *JsonReference) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside License objects. -func (m *License) ResolveReferences(root string) (interface{}, error) { +func (m *License) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { if item != nil { @@ -5868,7 +5863,7 @@ func (m *License) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedAny objects. -func (m *NamedAny) ResolveReferences(root string) (interface{}, error) { +func (m *NamedAny) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5880,7 +5875,7 @@ func (m *NamedAny) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedHeader objects. -func (m *NamedHeader) ResolveReferences(root string) (interface{}, error) { +func (m *NamedHeader) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5892,7 +5887,7 @@ func (m *NamedHeader) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedParameter objects. -func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) { +func (m *NamedParameter) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5904,7 +5899,7 @@ func (m *NamedParameter) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedPathItem objects. -func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) { +func (m *NamedPathItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5916,7 +5911,7 @@ func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedResponse objects. -func (m *NamedResponse) ResolveReferences(root string) (interface{}, error) { +func (m *NamedResponse) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5928,7 +5923,7 @@ func (m *NamedResponse) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedResponseValue objects. -func (m *NamedResponseValue) ResolveReferences(root string) (interface{}, error) { +func (m *NamedResponseValue) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5940,7 +5935,7 @@ func (m *NamedResponseValue) ResolveReferences(root string) (interface{}, error) } // ResolveReferences resolves references found inside NamedSchema objects. -func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) { +func (m *NamedSchema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5952,7 +5947,7 @@ func (m *NamedSchema) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedSecurityDefinitionsItem objects. -func (m *NamedSecurityDefinitionsItem) ResolveReferences(root string) (interface{}, error) { +func (m *NamedSecurityDefinitionsItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5964,13 +5959,13 @@ func (m *NamedSecurityDefinitionsItem) ResolveReferences(root string) (interface } // ResolveReferences resolves references found inside NamedString objects. -func (m *NamedString) ResolveReferences(root string) (interface{}, error) { +func (m *NamedString) ResolveReferences(root string) (*yaml.Node, 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) { +func (m *NamedStringArray) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5982,7 +5977,7 @@ func (m *NamedStringArray) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NonBodyParameter objects. -func (m *NonBodyParameter) ResolveReferences(root string) (interface{}, error) { +func (m *NonBodyParameter) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*NonBodyParameter_HeaderParameterSubSchema) @@ -6024,7 +6019,7 @@ func (m *NonBodyParameter) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Oauth2AccessCodeSecurity objects. -func (m *Oauth2AccessCodeSecurity) ResolveReferences(root string) (interface{}, error) { +func (m *Oauth2AccessCodeSecurity) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Scopes != nil { _, err := m.Scopes.ResolveReferences(root) @@ -6044,7 +6039,7 @@ func (m *Oauth2AccessCodeSecurity) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside Oauth2ApplicationSecurity objects. -func (m *Oauth2ApplicationSecurity) ResolveReferences(root string) (interface{}, error) { +func (m *Oauth2ApplicationSecurity) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Scopes != nil { _, err := m.Scopes.ResolveReferences(root) @@ -6064,7 +6059,7 @@ func (m *Oauth2ApplicationSecurity) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside Oauth2ImplicitSecurity objects. -func (m *Oauth2ImplicitSecurity) ResolveReferences(root string) (interface{}, error) { +func (m *Oauth2ImplicitSecurity) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Scopes != nil { _, err := m.Scopes.ResolveReferences(root) @@ -6084,7 +6079,7 @@ func (m *Oauth2ImplicitSecurity) ResolveReferences(root string) (interface{}, er } // ResolveReferences resolves references found inside Oauth2PasswordSecurity objects. -func (m *Oauth2PasswordSecurity) ResolveReferences(root string) (interface{}, error) { +func (m *Oauth2PasswordSecurity) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Scopes != nil { _, err := m.Scopes.ResolveReferences(root) @@ -6104,7 +6099,7 @@ func (m *Oauth2PasswordSecurity) ResolveReferences(root string) (interface{}, er } // ResolveReferences resolves references found inside Oauth2Scopes objects. -func (m *Oauth2Scopes) ResolveReferences(root string) (interface{}, error) { +func (m *Oauth2Scopes) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6118,7 +6113,7 @@ func (m *Oauth2Scopes) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Operation objects. -func (m *Operation) ResolveReferences(root string) (interface{}, error) { +func (m *Operation) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.ExternalDocs != nil { _, err := m.ExternalDocs.ResolveReferences(root) @@ -6160,7 +6155,7 @@ func (m *Operation) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Parameter objects. -func (m *Parameter) ResolveReferences(root string) (interface{}, error) { +func (m *Parameter) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*Parameter_BodyParameter) @@ -6184,7 +6179,7 @@ func (m *Parameter) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ParameterDefinitions objects. -func (m *ParameterDefinitions) ResolveReferences(root string) (interface{}, error) { +func (m *ParameterDefinitions) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6198,7 +6193,7 @@ func (m *ParameterDefinitions) ResolveReferences(root string) (interface{}, erro } // ResolveReferences resolves references found inside ParametersItem objects. -func (m *ParametersItem) ResolveReferences(root string) (interface{}, error) { +func (m *ParametersItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*ParametersItem_Parameter) @@ -6230,7 +6225,7 @@ func (m *ParametersItem) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside PathItem objects. -func (m *PathItem) ResolveReferences(root string) (interface{}, error) { +func (m *PathItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.XRef != "" { info, err := compiler.ReadInfoForRef(root, m.XRef) @@ -6308,7 +6303,7 @@ func (m *PathItem) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside PathParameterSubSchema objects. -func (m *PathParameterSubSchema) ResolveReferences(root string) (interface{}, error) { +func (m *PathParameterSubSchema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Items != nil { _, err := m.Items.ResolveReferences(root) @@ -6342,7 +6337,7 @@ func (m *PathParameterSubSchema) ResolveReferences(root string) (interface{}, er } // ResolveReferences resolves references found inside Paths objects. -func (m *Paths) ResolveReferences(root string) (interface{}, error) { +func (m *Paths) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { if item != nil { @@ -6364,7 +6359,7 @@ func (m *Paths) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside PrimitivesItems objects. -func (m *PrimitivesItems) ResolveReferences(root string) (interface{}, error) { +func (m *PrimitivesItems) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Items != nil { _, err := m.Items.ResolveReferences(root) @@ -6398,7 +6393,7 @@ func (m *PrimitivesItems) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Properties objects. -func (m *Properties) ResolveReferences(root string) (interface{}, error) { +func (m *Properties) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6412,7 +6407,7 @@ func (m *Properties) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside QueryParameterSubSchema objects. -func (m *QueryParameterSubSchema) ResolveReferences(root string) (interface{}, error) { +func (m *QueryParameterSubSchema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Items != nil { _, err := m.Items.ResolveReferences(root) @@ -6446,7 +6441,7 @@ func (m *QueryParameterSubSchema) ResolveReferences(root string) (interface{}, e } // ResolveReferences resolves references found inside Response objects. -func (m *Response) ResolveReferences(root string) (interface{}, error) { +func (m *Response) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Schema != nil { _, err := m.Schema.ResolveReferences(root) @@ -6478,7 +6473,7 @@ func (m *Response) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ResponseDefinitions objects. -func (m *ResponseDefinitions) ResolveReferences(root string) (interface{}, error) { +func (m *ResponseDefinitions) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6492,7 +6487,7 @@ func (m *ResponseDefinitions) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside ResponseValue objects. -func (m *ResponseValue) ResolveReferences(root string) (interface{}, error) { +func (m *ResponseValue) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*ResponseValue_Response) @@ -6524,7 +6519,7 @@ func (m *ResponseValue) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Responses objects. -func (m *Responses) ResolveReferences(root string) (interface{}, error) { +func (m *Responses) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.ResponseCode { if item != nil { @@ -6546,7 +6541,7 @@ func (m *Responses) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Schema objects. -func (m *Schema) ResolveReferences(root string) (interface{}, error) { +func (m *Schema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.XRef != "" { info, err := compiler.ReadInfoForRef(root, m.XRef) @@ -6638,7 +6633,7 @@ func (m *Schema) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside SchemaItem objects. -func (m *SchemaItem) ResolveReferences(root string) (interface{}, error) { +func (m *SchemaItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*SchemaItem_Schema) @@ -6662,7 +6657,7 @@ func (m *SchemaItem) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside SecurityDefinitions objects. -func (m *SecurityDefinitions) ResolveReferences(root string) (interface{}, error) { +func (m *SecurityDefinitions) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6676,7 +6671,7 @@ func (m *SecurityDefinitions) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside SecurityDefinitionsItem objects. -func (m *SecurityDefinitionsItem) ResolveReferences(root string) (interface{}, error) { +func (m *SecurityDefinitionsItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*SecurityDefinitionsItem_BasicAuthenticationSecurity) @@ -6736,7 +6731,7 @@ func (m *SecurityDefinitionsItem) ResolveReferences(root string) (interface{}, e } // ResolveReferences resolves references found inside SecurityRequirement objects. -func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error) { +func (m *SecurityRequirement) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6750,13 +6745,13 @@ func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside StringArray objects. -func (m *StringArray) ResolveReferences(root string) (interface{}, error) { +func (m *StringArray) ResolveReferences(root string) (*yaml.Node, 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) { +func (m *Tag) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.ExternalDocs != nil { _, err := m.ExternalDocs.ResolveReferences(root) @@ -6776,13 +6771,13 @@ func (m *Tag) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside TypeItem objects. -func (m *TypeItem) ResolveReferences(root string) (interface{}, error) { +func (m *TypeItem) ResolveReferences(root string) (*yaml.Node, 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) { +func (m *VendorExtension) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6796,7 +6791,7 @@ func (m *VendorExtension) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Xml objects. -func (m *Xml) ResolveReferences(root string) (interface{}, error) { +func (m *Xml) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.VendorExtension { if item != nil { diff --git a/openapiv3/OpenAPIv3.go b/openapiv3/OpenAPIv3.go index aeca1d9d..359b2a3e 100644 --- a/openapiv3/OpenAPIv3.go +++ b/openapiv3/OpenAPIv3.go @@ -30,7 +30,7 @@ func Version() string { } // NewAdditionalPropertiesItem creates an object of type AdditionalPropertiesItem if possible, returning an error if not. -func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*AdditionalPropertiesItem, error) { +func NewAdditionalPropertiesItem(in *yaml.Node, context *compiler.Context) (*AdditionalPropertiesItem, error) { errors := make([]error, 0) x := &AdditionalPropertiesItem{} matched := false @@ -49,7 +49,7 @@ func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*Ad } } // bool boolean = 2; - boolValue, ok := in.(bool) + boolValue, ok := compiler.BoolForScalarNode(in) if ok { x.Oneof = &AdditionalPropertiesItem_Boolean{Boolean: boolValue} matched = true @@ -62,16 +62,16 @@ func NewAdditionalPropertiesItem(in interface{}, context *compiler.Context) (*Ad } // NewAny creates an object of type Any if possible, returning an error if not. -func NewAny(in interface{}, context *compiler.Context) (*Any, error) { +func NewAny(in *yaml.Node, context *compiler.Context) (*Any, error) { errors := make([]error, 0) x := &Any{} - bytes := compiler.Marshal(in.(*yaml.Node)) + bytes := compiler.Marshal(in) x.Yaml = string(bytes) return x, compiler.NewErrorGroupOrNil(errors) } // NewAnyOrExpression creates an object of type AnyOrExpression if possible, returning an error if not. -func NewAnyOrExpression(in interface{}, context *compiler.Context) (*AnyOrExpression, error) { +func NewAnyOrExpression(in *yaml.Node, context *compiler.Context) (*AnyOrExpression, error) { errors := make([]error, 0) x := &AnyOrExpression{} matched := false @@ -111,7 +111,7 @@ func NewAnyOrExpression(in interface{}, context *compiler.Context) (*AnyOrExpres } // NewCallback creates an object of type Callback if possible, returning an error if not. -func NewCallback(in interface{}, context *compiler.Context) (*Callback, error) { +func NewCallback(in *yaml.Node, context *compiler.Context) (*Callback, error) { errors := make([]error, 0) x := &Callback{} m, ok := compiler.UnpackMap(in) @@ -181,7 +181,7 @@ func NewCallback(in interface{}, context *compiler.Context) (*Callback, error) { } // NewCallbackOrReference creates an object of type CallbackOrReference if possible, returning an error if not. -func NewCallbackOrReference(in interface{}, context *compiler.Context) (*CallbackOrReference, error) { +func NewCallbackOrReference(in *yaml.Node, context *compiler.Context) (*CallbackOrReference, error) { errors := make([]error, 0) x := &CallbackOrReference{} matched := false @@ -221,7 +221,7 @@ func NewCallbackOrReference(in interface{}, context *compiler.Context) (*Callbac } // NewCallbacksOrReferences creates an object of type CallbacksOrReferences if possible, returning an error if not. -func NewCallbacksOrReferences(in interface{}, context *compiler.Context) (*CallbacksOrReferences, error) { +func NewCallbacksOrReferences(in *yaml.Node, context *compiler.Context) (*CallbacksOrReferences, error) { errors := make([]error, 0) x := &CallbacksOrReferences{} m, ok := compiler.UnpackMap(in) @@ -251,7 +251,7 @@ func NewCallbacksOrReferences(in interface{}, context *compiler.Context) (*Callb } // NewComponents creates an object of type Components if possible, returning an error if not. -func NewComponents(in interface{}, context *compiler.Context) (*Components, error) { +func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error) { errors := make([]error, 0) x := &Components{} m, ok := compiler.UnpackMap(in) @@ -383,7 +383,7 @@ func NewComponents(in interface{}, context *compiler.Context) (*Components, erro } // NewContact creates an object of type Contact if possible, returning an error if not. -func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { +func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { errors := make([]error, 0) x := &Contact{} m, ok := compiler.UnpackMap(in) @@ -461,32 +461,27 @@ func NewContact(in interface{}, context *compiler.Context) (*Contact, error) { } // NewDefaultType creates an object of type DefaultType if possible, returning an error if not. -func NewDefaultType(in interface{}, context *compiler.Context) (*DefaultType, error) { +func NewDefaultType(in *yaml.Node, context *compiler.Context) (*DefaultType, error) { errors := make([]error, 0) x := &DefaultType{} matched := false - switch in := in.(type) { - case bool: - x.Oneof = &DefaultType_Boolean{Boolean: in} - matched = true - case string: - x.Oneof = &DefaultType_String_{String_: in} - matched = true - case int64: - x.Oneof = &DefaultType_Number{Number: float64(in)} - matched = true - case int32: - x.Oneof = &DefaultType_Number{Number: float64(in)} - matched = true - case int: - x.Oneof = &DefaultType_Number{Number: float64(in)} - matched = true - case float64: - x.Oneof = &DefaultType_Number{Number: in} - matched = true - case float32: - x.Oneof = &DefaultType_Number{Number: float64(in)} - matched = true + switch in.Tag { + case "!!bool": + var v bool + v, matched = compiler.BoolForScalarNode(in) + x.Oneof = &DefaultType_Boolean{Boolean: v} + case "!!str": + var v string + v, matched = compiler.StringForScalarNode(in) + x.Oneof = &DefaultType_String_{String_: v} + case "!!float": + var v float64 + v, matched = compiler.FloatForScalarNode(in) + x.Oneof = &DefaultType_Number{Number: v} + case "!!int": + var v int64 + v, matched = compiler.IntForScalarNode(in) + x.Oneof = &DefaultType_Number{Number: float64(v)} } if matched { // since the oneof matched one of its possibilities, discard any matching errors @@ -496,7 +491,7 @@ func NewDefaultType(in interface{}, context *compiler.Context) (*DefaultType, er } // NewDiscriminator creates an object of type Discriminator if possible, returning an error if not. -func NewDiscriminator(in interface{}, context *compiler.Context) (*Discriminator, error) { +func NewDiscriminator(in *yaml.Node, context *compiler.Context) (*Discriminator, error) { errors := make([]error, 0) x := &Discriminator{} m, ok := compiler.UnpackMap(in) @@ -571,7 +566,7 @@ func NewDiscriminator(in interface{}, context *compiler.Context) (*Discriminator } // NewDocument creates an object of type Document if possible, returning an error if not. -func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { +func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { errors := make([]error, 0) x := &Document{} m, ok := compiler.UnpackMap(in) @@ -721,7 +716,7 @@ func NewDocument(in interface{}, context *compiler.Context) (*Document, error) { } // NewEncoding creates an object of type Encoding if possible, returning an error if not. -func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { +func NewEncoding(in *yaml.Node, context *compiler.Context) (*Encoding, error) { errors := make([]error, 0) x := &Encoding{} m, ok := compiler.UnpackMap(in) @@ -817,7 +812,7 @@ func NewEncoding(in interface{}, context *compiler.Context) (*Encoding, error) { } // NewEncodings creates an object of type Encodings if possible, returning an error if not. -func NewEncodings(in interface{}, context *compiler.Context) (*Encodings, error) { +func NewEncodings(in *yaml.Node, context *compiler.Context) (*Encodings, error) { errors := make([]error, 0) x := &Encodings{} m, ok := compiler.UnpackMap(in) @@ -847,7 +842,7 @@ func NewEncodings(in interface{}, context *compiler.Context) (*Encodings, error) } // NewExample creates an object of type Example if possible, returning an error if not. -func NewExample(in interface{}, context *compiler.Context) (*Example, error) { +func NewExample(in *yaml.Node, context *compiler.Context) (*Example, error) { errors := make([]error, 0) x := &Example{} m, ok := compiler.UnpackMap(in) @@ -934,7 +929,7 @@ func NewExample(in interface{}, context *compiler.Context) (*Example, error) { } // NewExampleOrReference creates an object of type ExampleOrReference if possible, returning an error if not. -func NewExampleOrReference(in interface{}, context *compiler.Context) (*ExampleOrReference, error) { +func NewExampleOrReference(in *yaml.Node, context *compiler.Context) (*ExampleOrReference, error) { errors := make([]error, 0) x := &ExampleOrReference{} matched := false @@ -974,7 +969,7 @@ func NewExampleOrReference(in interface{}, context *compiler.Context) (*ExampleO } // NewExamplesOrReferences creates an object of type ExamplesOrReferences if possible, returning an error if not. -func NewExamplesOrReferences(in interface{}, context *compiler.Context) (*ExamplesOrReferences, error) { +func NewExamplesOrReferences(in *yaml.Node, context *compiler.Context) (*ExamplesOrReferences, error) { errors := make([]error, 0) x := &ExamplesOrReferences{} m, ok := compiler.UnpackMap(in) @@ -1004,7 +999,7 @@ func NewExamplesOrReferences(in interface{}, context *compiler.Context) (*Exampl } // NewExpression creates an object of type Expression if possible, returning an error if not. -func NewExpression(in interface{}, context *compiler.Context) (*Expression, error) { +func NewExpression(in *yaml.Node, context *compiler.Context) (*Expression, error) { errors := make([]error, 0) x := &Expression{} m, ok := compiler.UnpackMap(in) @@ -1046,7 +1041,7 @@ func NewExpression(in interface{}, context *compiler.Context) (*Expression, erro } // NewExternalDocs creates an object of type ExternalDocs if possible, returning an error if not. -func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, error) { +func NewExternalDocs(in *yaml.Node, context *compiler.Context) (*ExternalDocs, error) { errors := make([]error, 0) x := &ExternalDocs{} m, ok := compiler.UnpackMap(in) @@ -1121,7 +1116,7 @@ func NewExternalDocs(in interface{}, context *compiler.Context) (*ExternalDocs, } // NewHeader creates an object of type Header if possible, returning an error if not. -func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { +func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { errors := make([]error, 0) x := &Header{} m, ok := compiler.UnpackMap(in) @@ -1271,7 +1266,7 @@ func NewHeader(in interface{}, context *compiler.Context) (*Header, error) { } // NewHeaderOrReference creates an object of type HeaderOrReference if possible, returning an error if not. -func NewHeaderOrReference(in interface{}, context *compiler.Context) (*HeaderOrReference, error) { +func NewHeaderOrReference(in *yaml.Node, context *compiler.Context) (*HeaderOrReference, error) { errors := make([]error, 0) x := &HeaderOrReference{} matched := false @@ -1311,7 +1306,7 @@ func NewHeaderOrReference(in interface{}, context *compiler.Context) (*HeaderOrR } // NewHeadersOrReferences creates an object of type HeadersOrReferences if possible, returning an error if not. -func NewHeadersOrReferences(in interface{}, context *compiler.Context) (*HeadersOrReferences, error) { +func NewHeadersOrReferences(in *yaml.Node, context *compiler.Context) (*HeadersOrReferences, error) { errors := make([]error, 0) x := &HeadersOrReferences{} m, ok := compiler.UnpackMap(in) @@ -1341,7 +1336,7 @@ func NewHeadersOrReferences(in interface{}, context *compiler.Context) (*Headers } // NewInfo creates an object of type Info if possible, returning an error if not. -func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { +func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { errors := make([]error, 0) x := &Info{} m, ok := compiler.UnpackMap(in) @@ -1461,7 +1456,7 @@ func NewInfo(in interface{}, context *compiler.Context) (*Info, error) { } // NewItemsItem creates an object of type ItemsItem if possible, returning an error if not. -func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) { +func NewItemsItem(in *yaml.Node, context *compiler.Context) (*ItemsItem, error) { errors := make([]error, 0) x := &ItemsItem{} m, ok := compiler.UnpackMap(in) @@ -1480,7 +1475,7 @@ func NewItemsItem(in interface{}, context *compiler.Context) (*ItemsItem, error) } // NewLicense creates an object of type License if possible, returning an error if not. -func NewLicense(in interface{}, context *compiler.Context) (*License, error) { +func NewLicense(in *yaml.Node, context *compiler.Context) (*License, error) { errors := make([]error, 0) x := &License{} m, ok := compiler.UnpackMap(in) @@ -1555,7 +1550,7 @@ func NewLicense(in interface{}, context *compiler.Context) (*License, error) { } // NewLink creates an object of type Link if possible, returning an error if not. -func NewLink(in interface{}, context *compiler.Context) (*Link, error) { +func NewLink(in *yaml.Node, context *compiler.Context) (*Link, error) { errors := make([]error, 0) x := &Link{} m, ok := compiler.UnpackMap(in) @@ -1660,7 +1655,7 @@ func NewLink(in interface{}, context *compiler.Context) (*Link, error) { } // NewLinkOrReference creates an object of type LinkOrReference if possible, returning an error if not. -func NewLinkOrReference(in interface{}, context *compiler.Context) (*LinkOrReference, error) { +func NewLinkOrReference(in *yaml.Node, context *compiler.Context) (*LinkOrReference, error) { errors := make([]error, 0) x := &LinkOrReference{} matched := false @@ -1700,7 +1695,7 @@ func NewLinkOrReference(in interface{}, context *compiler.Context) (*LinkOrRefer } // NewLinksOrReferences creates an object of type LinksOrReferences if possible, returning an error if not. -func NewLinksOrReferences(in interface{}, context *compiler.Context) (*LinksOrReferences, error) { +func NewLinksOrReferences(in *yaml.Node, context *compiler.Context) (*LinksOrReferences, error) { errors := make([]error, 0) x := &LinksOrReferences{} m, ok := compiler.UnpackMap(in) @@ -1730,7 +1725,7 @@ func NewLinksOrReferences(in interface{}, context *compiler.Context) (*LinksOrRe } // NewMediaType creates an object of type MediaType if possible, returning an error if not. -func NewMediaType(in interface{}, context *compiler.Context) (*MediaType, error) { +func NewMediaType(in *yaml.Node, context *compiler.Context) (*MediaType, error) { errors := make([]error, 0) x := &MediaType{} m, ok := compiler.UnpackMap(in) @@ -1817,7 +1812,7 @@ func NewMediaType(in interface{}, context *compiler.Context) (*MediaType, error) } // NewMediaTypes creates an object of type MediaTypes if possible, returning an error if not. -func NewMediaTypes(in interface{}, context *compiler.Context) (*MediaTypes, error) { +func NewMediaTypes(in *yaml.Node, context *compiler.Context) (*MediaTypes, error) { errors := make([]error, 0) x := &MediaTypes{} m, ok := compiler.UnpackMap(in) @@ -1847,7 +1842,7 @@ func NewMediaTypes(in interface{}, context *compiler.Context) (*MediaTypes, erro } // NewNamedAny creates an object of type NamedAny if possible, returning an error if not. -func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { +func NewNamedAny(in *yaml.Node, context *compiler.Context) (*NamedAny, error) { errors := make([]error, 0) x := &NamedAny{} m, ok := compiler.UnpackMap(in) @@ -1885,7 +1880,7 @@ func NewNamedAny(in interface{}, context *compiler.Context) (*NamedAny, error) { } // NewNamedCallbackOrReference creates an object of type NamedCallbackOrReference if possible, returning an error if not. -func NewNamedCallbackOrReference(in interface{}, context *compiler.Context) (*NamedCallbackOrReference, error) { +func NewNamedCallbackOrReference(in *yaml.Node, context *compiler.Context) (*NamedCallbackOrReference, error) { errors := make([]error, 0) x := &NamedCallbackOrReference{} m, ok := compiler.UnpackMap(in) @@ -1923,7 +1918,7 @@ func NewNamedCallbackOrReference(in interface{}, context *compiler.Context) (*Na } // NewNamedEncoding creates an object of type NamedEncoding if possible, returning an error if not. -func NewNamedEncoding(in interface{}, context *compiler.Context) (*NamedEncoding, error) { +func NewNamedEncoding(in *yaml.Node, context *compiler.Context) (*NamedEncoding, error) { errors := make([]error, 0) x := &NamedEncoding{} m, ok := compiler.UnpackMap(in) @@ -1961,7 +1956,7 @@ func NewNamedEncoding(in interface{}, context *compiler.Context) (*NamedEncoding } // NewNamedExampleOrReference creates an object of type NamedExampleOrReference if possible, returning an error if not. -func NewNamedExampleOrReference(in interface{}, context *compiler.Context) (*NamedExampleOrReference, error) { +func NewNamedExampleOrReference(in *yaml.Node, context *compiler.Context) (*NamedExampleOrReference, error) { errors := make([]error, 0) x := &NamedExampleOrReference{} m, ok := compiler.UnpackMap(in) @@ -1999,7 +1994,7 @@ func NewNamedExampleOrReference(in interface{}, context *compiler.Context) (*Nam } // NewNamedHeaderOrReference creates an object of type NamedHeaderOrReference if possible, returning an error if not. -func NewNamedHeaderOrReference(in interface{}, context *compiler.Context) (*NamedHeaderOrReference, error) { +func NewNamedHeaderOrReference(in *yaml.Node, context *compiler.Context) (*NamedHeaderOrReference, error) { errors := make([]error, 0) x := &NamedHeaderOrReference{} m, ok := compiler.UnpackMap(in) @@ -2037,7 +2032,7 @@ func NewNamedHeaderOrReference(in interface{}, context *compiler.Context) (*Name } // NewNamedLinkOrReference creates an object of type NamedLinkOrReference if possible, returning an error if not. -func NewNamedLinkOrReference(in interface{}, context *compiler.Context) (*NamedLinkOrReference, error) { +func NewNamedLinkOrReference(in *yaml.Node, context *compiler.Context) (*NamedLinkOrReference, error) { errors := make([]error, 0) x := &NamedLinkOrReference{} m, ok := compiler.UnpackMap(in) @@ -2075,7 +2070,7 @@ func NewNamedLinkOrReference(in interface{}, context *compiler.Context) (*NamedL } // NewNamedMediaType creates an object of type NamedMediaType if possible, returning an error if not. -func NewNamedMediaType(in interface{}, context *compiler.Context) (*NamedMediaType, error) { +func NewNamedMediaType(in *yaml.Node, context *compiler.Context) (*NamedMediaType, error) { errors := make([]error, 0) x := &NamedMediaType{} m, ok := compiler.UnpackMap(in) @@ -2113,7 +2108,7 @@ func NewNamedMediaType(in interface{}, context *compiler.Context) (*NamedMediaTy } // NewNamedParameterOrReference creates an object of type NamedParameterOrReference if possible, returning an error if not. -func NewNamedParameterOrReference(in interface{}, context *compiler.Context) (*NamedParameterOrReference, error) { +func NewNamedParameterOrReference(in *yaml.Node, context *compiler.Context) (*NamedParameterOrReference, error) { errors := make([]error, 0) x := &NamedParameterOrReference{} m, ok := compiler.UnpackMap(in) @@ -2151,7 +2146,7 @@ func NewNamedParameterOrReference(in interface{}, context *compiler.Context) (*N } // NewNamedPathItem creates an object of type NamedPathItem if possible, returning an error if not. -func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem, error) { +func NewNamedPathItem(in *yaml.Node, context *compiler.Context) (*NamedPathItem, error) { errors := make([]error, 0) x := &NamedPathItem{} m, ok := compiler.UnpackMap(in) @@ -2189,7 +2184,7 @@ func NewNamedPathItem(in interface{}, context *compiler.Context) (*NamedPathItem } // NewNamedRequestBodyOrReference creates an object of type NamedRequestBodyOrReference if possible, returning an error if not. -func NewNamedRequestBodyOrReference(in interface{}, context *compiler.Context) (*NamedRequestBodyOrReference, error) { +func NewNamedRequestBodyOrReference(in *yaml.Node, context *compiler.Context) (*NamedRequestBodyOrReference, error) { errors := make([]error, 0) x := &NamedRequestBodyOrReference{} m, ok := compiler.UnpackMap(in) @@ -2227,7 +2222,7 @@ func NewNamedRequestBodyOrReference(in interface{}, context *compiler.Context) ( } // NewNamedResponseOrReference creates an object of type NamedResponseOrReference if possible, returning an error if not. -func NewNamedResponseOrReference(in interface{}, context *compiler.Context) (*NamedResponseOrReference, error) { +func NewNamedResponseOrReference(in *yaml.Node, context *compiler.Context) (*NamedResponseOrReference, error) { errors := make([]error, 0) x := &NamedResponseOrReference{} m, ok := compiler.UnpackMap(in) @@ -2265,7 +2260,7 @@ func NewNamedResponseOrReference(in interface{}, context *compiler.Context) (*Na } // NewNamedSchemaOrReference creates an object of type NamedSchemaOrReference if possible, returning an error if not. -func NewNamedSchemaOrReference(in interface{}, context *compiler.Context) (*NamedSchemaOrReference, error) { +func NewNamedSchemaOrReference(in *yaml.Node, context *compiler.Context) (*NamedSchemaOrReference, error) { errors := make([]error, 0) x := &NamedSchemaOrReference{} m, ok := compiler.UnpackMap(in) @@ -2303,7 +2298,7 @@ func NewNamedSchemaOrReference(in interface{}, context *compiler.Context) (*Name } // NewNamedSecuritySchemeOrReference creates an object of type NamedSecuritySchemeOrReference if possible, returning an error if not. -func NewNamedSecuritySchemeOrReference(in interface{}, context *compiler.Context) (*NamedSecuritySchemeOrReference, error) { +func NewNamedSecuritySchemeOrReference(in *yaml.Node, context *compiler.Context) (*NamedSecuritySchemeOrReference, error) { errors := make([]error, 0) x := &NamedSecuritySchemeOrReference{} m, ok := compiler.UnpackMap(in) @@ -2341,7 +2336,7 @@ func NewNamedSecuritySchemeOrReference(in interface{}, context *compiler.Context } // NewNamedServerVariable creates an object of type NamedServerVariable if possible, returning an error if not. -func NewNamedServerVariable(in interface{}, context *compiler.Context) (*NamedServerVariable, error) { +func NewNamedServerVariable(in *yaml.Node, context *compiler.Context) (*NamedServerVariable, error) { errors := make([]error, 0) x := &NamedServerVariable{} m, ok := compiler.UnpackMap(in) @@ -2379,7 +2374,7 @@ func NewNamedServerVariable(in interface{}, context *compiler.Context) (*NamedSe } // NewNamedString creates an object of type NamedString if possible, returning an error if not. -func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, error) { +func NewNamedString(in *yaml.Node, context *compiler.Context) (*NamedString, error) { errors := make([]error, 0) x := &NamedString{} m, ok := compiler.UnpackMap(in) @@ -2417,7 +2412,7 @@ func NewNamedString(in interface{}, context *compiler.Context) (*NamedString, er } // NewNamedStringArray creates an object of type NamedStringArray if possible, returning an error if not. -func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStringArray, error) { +func NewNamedStringArray(in *yaml.Node, context *compiler.Context) (*NamedStringArray, error) { errors := make([]error, 0) x := &NamedStringArray{} m, ok := compiler.UnpackMap(in) @@ -2455,7 +2450,7 @@ func NewNamedStringArray(in interface{}, context *compiler.Context) (*NamedStrin } // NewOauthFlow creates an object of type OauthFlow if possible, returning an error if not. -func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) { +func NewOauthFlow(in *yaml.Node, context *compiler.Context) (*OauthFlow, error) { errors := make([]error, 0) x := &OauthFlow{} m, ok := compiler.UnpackMap(in) @@ -2542,7 +2537,7 @@ func NewOauthFlow(in interface{}, context *compiler.Context) (*OauthFlow, error) } // NewOauthFlows creates an object of type OauthFlows if possible, returning an error if not. -func NewOauthFlows(in interface{}, context *compiler.Context) (*OauthFlows, error) { +func NewOauthFlows(in *yaml.Node, context *compiler.Context) (*OauthFlows, error) { errors := make([]error, 0) x := &OauthFlows{} m, ok := compiler.UnpackMap(in) @@ -2629,7 +2624,7 @@ func NewOauthFlows(in interface{}, context *compiler.Context) (*OauthFlows, erro } // NewObject creates an object of type Object if possible, returning an error if not. -func NewObject(in interface{}, context *compiler.Context) (*Object, error) { +func NewObject(in *yaml.Node, context *compiler.Context) (*Object, error) { errors := make([]error, 0) x := &Object{} m, ok := compiler.UnpackMap(in) @@ -2671,7 +2666,7 @@ func NewObject(in interface{}, context *compiler.Context) (*Object, error) { } // NewOperation creates an object of type Operation if possible, returning an error if not. -func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) { +func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) { errors := make([]error, 0) x := &Operation{} m, ok := compiler.UnpackMap(in) @@ -2859,7 +2854,7 @@ func NewOperation(in interface{}, context *compiler.Context) (*Operation, error) } // NewParameter creates an object of type Parameter if possible, returning an error if not. -func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) { +func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) { errors := make([]error, 0) x := &Parameter{} m, ok := compiler.UnpackMap(in) @@ -3033,7 +3028,7 @@ func NewParameter(in interface{}, context *compiler.Context) (*Parameter, error) } // NewParameterOrReference creates an object of type ParameterOrReference if possible, returning an error if not. -func NewParameterOrReference(in interface{}, context *compiler.Context) (*ParameterOrReference, error) { +func NewParameterOrReference(in *yaml.Node, context *compiler.Context) (*ParameterOrReference, error) { errors := make([]error, 0) x := &ParameterOrReference{} matched := false @@ -3073,7 +3068,7 @@ func NewParameterOrReference(in interface{}, context *compiler.Context) (*Parame } // NewParametersOrReferences creates an object of type ParametersOrReferences if possible, returning an error if not. -func NewParametersOrReferences(in interface{}, context *compiler.Context) (*ParametersOrReferences, error) { +func NewParametersOrReferences(in *yaml.Node, context *compiler.Context) (*ParametersOrReferences, error) { errors := make([]error, 0) x := &ParametersOrReferences{} m, ok := compiler.UnpackMap(in) @@ -3103,7 +3098,7 @@ func NewParametersOrReferences(in interface{}, context *compiler.Context) (*Para } // NewPathItem creates an object of type PathItem if possible, returning an error if not. -func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { +func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { errors := make([]error, 0) x := &PathItem{} m, ok := compiler.UnpackMap(in) @@ -3285,7 +3280,7 @@ func NewPathItem(in interface{}, context *compiler.Context) (*PathItem, error) { } // NewPaths creates an object of type Paths if possible, returning an error if not. -func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { +func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { errors := make([]error, 0) x := &Paths{} m, ok := compiler.UnpackMap(in) @@ -3355,7 +3350,7 @@ func NewPaths(in interface{}, context *compiler.Context) (*Paths, error) { } // NewProperties creates an object of type Properties if possible, returning an error if not. -func NewProperties(in interface{}, context *compiler.Context) (*Properties, error) { +func NewProperties(in *yaml.Node, context *compiler.Context) (*Properties, error) { errors := make([]error, 0) x := &Properties{} m, ok := compiler.UnpackMap(in) @@ -3385,7 +3380,7 @@ func NewProperties(in interface{}, context *compiler.Context) (*Properties, erro } // NewReference creates an object of type Reference if possible, returning an error if not. -func NewReference(in interface{}, context *compiler.Context) (*Reference, error) { +func NewReference(in *yaml.Node, context *compiler.Context) (*Reference, error) { errors := make([]error, 0) x := &Reference{} m, ok := compiler.UnpackMap(in) @@ -3413,7 +3408,7 @@ func NewReference(in interface{}, context *compiler.Context) (*Reference, error) } // NewRequestBodiesOrReferences creates an object of type RequestBodiesOrReferences if possible, returning an error if not. -func NewRequestBodiesOrReferences(in interface{}, context *compiler.Context) (*RequestBodiesOrReferences, error) { +func NewRequestBodiesOrReferences(in *yaml.Node, context *compiler.Context) (*RequestBodiesOrReferences, error) { errors := make([]error, 0) x := &RequestBodiesOrReferences{} m, ok := compiler.UnpackMap(in) @@ -3443,7 +3438,7 @@ func NewRequestBodiesOrReferences(in interface{}, context *compiler.Context) (*R } // NewRequestBody creates an object of type RequestBody if possible, returning an error if not. -func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, error) { +func NewRequestBody(in *yaml.Node, context *compiler.Context) (*RequestBody, error) { errors := make([]error, 0) x := &RequestBody{} m, ok := compiler.UnpackMap(in) @@ -3527,7 +3522,7 @@ func NewRequestBody(in interface{}, context *compiler.Context) (*RequestBody, er } // NewRequestBodyOrReference creates an object of type RequestBodyOrReference if possible, returning an error if not. -func NewRequestBodyOrReference(in interface{}, context *compiler.Context) (*RequestBodyOrReference, error) { +func NewRequestBodyOrReference(in *yaml.Node, context *compiler.Context) (*RequestBodyOrReference, error) { errors := make([]error, 0) x := &RequestBodyOrReference{} matched := false @@ -3567,7 +3562,7 @@ func NewRequestBodyOrReference(in interface{}, context *compiler.Context) (*Requ } // NewResponse creates an object of type Response if possible, returning an error if not. -func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { +func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { errors := make([]error, 0) x := &Response{} m, ok := compiler.UnpackMap(in) @@ -3660,7 +3655,7 @@ func NewResponse(in interface{}, context *compiler.Context) (*Response, error) { } // NewResponseOrReference creates an object of type ResponseOrReference if possible, returning an error if not. -func NewResponseOrReference(in interface{}, context *compiler.Context) (*ResponseOrReference, error) { +func NewResponseOrReference(in *yaml.Node, context *compiler.Context) (*ResponseOrReference, error) { errors := make([]error, 0) x := &ResponseOrReference{} matched := false @@ -3700,7 +3695,7 @@ func NewResponseOrReference(in interface{}, context *compiler.Context) (*Respons } // NewResponses creates an object of type Responses if possible, returning an error if not. -func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) { +func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) { errors := make([]error, 0) x := &Responses{} m, ok := compiler.UnpackMap(in) @@ -3779,7 +3774,7 @@ func NewResponses(in interface{}, context *compiler.Context) (*Responses, error) } // NewResponsesOrReferences creates an object of type ResponsesOrReferences if possible, returning an error if not. -func NewResponsesOrReferences(in interface{}, context *compiler.Context) (*ResponsesOrReferences, error) { +func NewResponsesOrReferences(in *yaml.Node, context *compiler.Context) (*ResponsesOrReferences, error) { errors := make([]error, 0) x := &ResponsesOrReferences{} m, ok := compiler.UnpackMap(in) @@ -3809,7 +3804,7 @@ func NewResponsesOrReferences(in interface{}, context *compiler.Context) (*Respo } // NewSchema creates an object of type Schema if possible, returning an error if not. -func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { +func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { errors := make([]error, 0) x := &Schema{} m, ok := compiler.UnpackMap(in) @@ -4223,7 +4218,7 @@ func NewSchema(in interface{}, context *compiler.Context) (*Schema, error) { } // NewSchemaOrReference creates an object of type SchemaOrReference if possible, returning an error if not. -func NewSchemaOrReference(in interface{}, context *compiler.Context) (*SchemaOrReference, error) { +func NewSchemaOrReference(in *yaml.Node, context *compiler.Context) (*SchemaOrReference, error) { errors := make([]error, 0) x := &SchemaOrReference{} matched := false @@ -4263,7 +4258,7 @@ func NewSchemaOrReference(in interface{}, context *compiler.Context) (*SchemaOrR } // NewSchemasOrReferences creates an object of type SchemasOrReferences if possible, returning an error if not. -func NewSchemasOrReferences(in interface{}, context *compiler.Context) (*SchemasOrReferences, error) { +func NewSchemasOrReferences(in *yaml.Node, context *compiler.Context) (*SchemasOrReferences, error) { errors := make([]error, 0) x := &SchemasOrReferences{} m, ok := compiler.UnpackMap(in) @@ -4293,7 +4288,7 @@ func NewSchemasOrReferences(in interface{}, context *compiler.Context) (*Schemas } // NewSecurityRequirement creates an object of type SecurityRequirement if possible, returning an error if not. -func NewSecurityRequirement(in interface{}, context *compiler.Context) (*SecurityRequirement, error) { +func NewSecurityRequirement(in *yaml.Node, context *compiler.Context) (*SecurityRequirement, error) { errors := make([]error, 0) x := &SecurityRequirement{} m, ok := compiler.UnpackMap(in) @@ -4323,7 +4318,7 @@ func NewSecurityRequirement(in interface{}, context *compiler.Context) (*Securit } // NewSecurityScheme creates an object of type SecurityScheme if possible, returning an error if not. -func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecurityScheme, error) { +func NewSecurityScheme(in *yaml.Node, context *compiler.Context) (*SecurityScheme, error) { errors := make([]error, 0) x := &SecurityScheme{} m, ok := compiler.UnpackMap(in) @@ -4452,7 +4447,7 @@ func NewSecurityScheme(in interface{}, context *compiler.Context) (*SecuritySche } // NewSecuritySchemeOrReference creates an object of type SecuritySchemeOrReference if possible, returning an error if not. -func NewSecuritySchemeOrReference(in interface{}, context *compiler.Context) (*SecuritySchemeOrReference, error) { +func NewSecuritySchemeOrReference(in *yaml.Node, context *compiler.Context) (*SecuritySchemeOrReference, error) { errors := make([]error, 0) x := &SecuritySchemeOrReference{} matched := false @@ -4492,7 +4487,7 @@ func NewSecuritySchemeOrReference(in interface{}, context *compiler.Context) (*S } // NewSecuritySchemesOrReferences creates an object of type SecuritySchemesOrReferences if possible, returning an error if not. -func NewSecuritySchemesOrReferences(in interface{}, context *compiler.Context) (*SecuritySchemesOrReferences, error) { +func NewSecuritySchemesOrReferences(in *yaml.Node, context *compiler.Context) (*SecuritySchemesOrReferences, error) { errors := make([]error, 0) x := &SecuritySchemesOrReferences{} m, ok := compiler.UnpackMap(in) @@ -4522,7 +4517,7 @@ func NewSecuritySchemesOrReferences(in interface{}, context *compiler.Context) ( } // NewServer creates an object of type Server if possible, returning an error if not. -func NewServer(in interface{}, context *compiler.Context) (*Server, error) { +func NewServer(in *yaml.Node, context *compiler.Context) (*Server, error) { errors := make([]error, 0) x := &Server{} m, ok := compiler.UnpackMap(in) @@ -4606,7 +4601,7 @@ func NewServer(in interface{}, context *compiler.Context) (*Server, error) { } // NewServerVariable creates an object of type ServerVariable if possible, returning an error if not. -func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariable, error) { +func NewServerVariable(in *yaml.Node, context *compiler.Context) (*ServerVariable, error) { errors := make([]error, 0) x := &ServerVariable{} m, ok := compiler.UnpackMap(in) @@ -4692,7 +4687,7 @@ func NewServerVariable(in interface{}, context *compiler.Context) (*ServerVariab } // NewServerVariables creates an object of type ServerVariables if possible, returning an error if not. -func NewServerVariables(in interface{}, context *compiler.Context) (*ServerVariables, error) { +func NewServerVariables(in *yaml.Node, context *compiler.Context) (*ServerVariables, error) { errors := make([]error, 0) x := &ServerVariables{} m, ok := compiler.UnpackMap(in) @@ -4722,32 +4717,27 @@ func NewServerVariables(in interface{}, context *compiler.Context) (*ServerVaria } // NewSpecificationExtension creates an object of type SpecificationExtension if possible, returning an error if not. -func NewSpecificationExtension(in interface{}, context *compiler.Context) (*SpecificationExtension, error) { +func NewSpecificationExtension(in *yaml.Node, context *compiler.Context) (*SpecificationExtension, error) { errors := make([]error, 0) x := &SpecificationExtension{} matched := false - switch in := in.(type) { - case bool: - x.Oneof = &SpecificationExtension_Boolean{Boolean: in} - matched = true - case string: - x.Oneof = &SpecificationExtension_String_{String_: in} - matched = true - case int64: - x.Oneof = &SpecificationExtension_Number{Number: float64(in)} - matched = true - case int32: - x.Oneof = &SpecificationExtension_Number{Number: float64(in)} - matched = true - case int: - x.Oneof = &SpecificationExtension_Number{Number: float64(in)} - matched = true - case float64: - x.Oneof = &SpecificationExtension_Number{Number: in} - matched = true - case float32: - x.Oneof = &SpecificationExtension_Number{Number: float64(in)} - matched = true + switch in.Tag { + case "!!bool": + var v bool + v, matched = compiler.BoolForScalarNode(in) + x.Oneof = &SpecificationExtension_Boolean{Boolean: v} + case "!!str": + var v string + v, matched = compiler.StringForScalarNode(in) + x.Oneof = &SpecificationExtension_String_{String_: v} + case "!!float": + var v float64 + v, matched = compiler.FloatForScalarNode(in) + x.Oneof = &SpecificationExtension_Number{Number: v} + case "!!int": + var v int64 + v, matched = compiler.IntForScalarNode(in) + x.Oneof = &SpecificationExtension_Number{Number: float64(v)} } if matched { // since the oneof matched one of its possibilities, discard any matching errors @@ -4757,24 +4747,19 @@ func NewSpecificationExtension(in interface{}, context *compiler.Context) (*Spec } // NewStringArray creates an object of type StringArray if possible, returning an error if not. -func NewStringArray(in interface{}, context *compiler.Context) (*StringArray, error) { +func NewStringArray(in *yaml.Node, context *compiler.Context) (*StringArray, error) { errors := make([]error, 0) x := &StringArray{} - a, ok := in.([]interface{}) - if !ok { - message := fmt.Sprintf("has unexpected value for StringArray: %+v (%T)", in, in) - errors = append(errors, compiler.NewError(context, message)) - } else { - x.Value = make([]string, 0) - for _, s := range a { - x.Value = append(x.Value, s.(string)) - } + x.Value = make([]string, 0) + for _, node := range in.Content { + s, _ := compiler.StringForScalarNode(node) + x.Value = append(x.Value, s) } return x, compiler.NewErrorGroupOrNil(errors) } // NewStrings creates an object of type Strings if possible, returning an error if not. -func NewStrings(in interface{}, context *compiler.Context) (*Strings, error) { +func NewStrings(in *yaml.Node, context *compiler.Context) (*Strings, error) { errors := make([]error, 0) x := &Strings{} m, ok := compiler.UnpackMap(in) @@ -4800,7 +4785,7 @@ func NewStrings(in interface{}, context *compiler.Context) (*Strings, error) { } // NewTag creates an object of type Tag if possible, returning an error if not. -func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { +func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { errors := make([]error, 0) x := &Tag{} m, ok := compiler.UnpackMap(in) @@ -4884,7 +4869,7 @@ func NewTag(in interface{}, context *compiler.Context) (*Tag, error) { } // NewXml creates an object of type Xml if possible, returning an error if not. -func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { +func NewXml(in *yaml.Node, context *compiler.Context) (*Xml, error) { errors := make([]error, 0) x := &Xml{} m, ok := compiler.UnpackMap(in) @@ -4980,7 +4965,7 @@ func NewXml(in interface{}, context *compiler.Context) (*Xml, error) { } // ResolveReferences resolves references found inside AdditionalPropertiesItem objects. -func (m *AdditionalPropertiesItem) ResolveReferences(root string) (interface{}, error) { +func (m *AdditionalPropertiesItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*AdditionalPropertiesItem_SchemaOrReference) @@ -4995,13 +4980,13 @@ func (m *AdditionalPropertiesItem) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside Any objects. -func (m *Any) ResolveReferences(root string) (interface{}, error) { +func (m *Any) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside AnyOrExpression objects. -func (m *AnyOrExpression) ResolveReferences(root string) (interface{}, error) { +func (m *AnyOrExpression) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*AnyOrExpression_Any) @@ -5025,7 +5010,7 @@ func (m *AnyOrExpression) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Callback objects. -func (m *Callback) ResolveReferences(root string) (interface{}, error) { +func (m *Callback) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.Path { if item != nil { @@ -5047,7 +5032,7 @@ func (m *Callback) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside CallbackOrReference objects. -func (m *CallbackOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *CallbackOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*CallbackOrReference_Callback) @@ -5071,7 +5056,7 @@ func (m *CallbackOrReference) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside CallbacksOrReferences objects. -func (m *CallbacksOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *CallbacksOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5085,7 +5070,7 @@ func (m *CallbacksOrReferences) ResolveReferences(root string) (interface{}, err } // ResolveReferences resolves references found inside Components objects. -func (m *Components) ResolveReferences(root string) (interface{}, error) { +func (m *Components) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Schemas != nil { _, err := m.Schemas.ResolveReferences(root) @@ -5153,7 +5138,7 @@ func (m *Components) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Contact objects. -func (m *Contact) ResolveReferences(root string) (interface{}, error) { +func (m *Contact) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.SpecificationExtension { if item != nil { @@ -5167,13 +5152,13 @@ func (m *Contact) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside DefaultType objects. -func (m *DefaultType) ResolveReferences(root string) (interface{}, error) { +func (m *DefaultType) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside Discriminator objects. -func (m *Discriminator) ResolveReferences(root string) (interface{}, error) { +func (m *Discriminator) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Mapping != nil { _, err := m.Mapping.ResolveReferences(root) @@ -5193,7 +5178,7 @@ func (m *Discriminator) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Document objects. -func (m *Document) ResolveReferences(root string) (interface{}, error) { +func (m *Document) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Info != nil { _, err := m.Info.ResolveReferences(root) @@ -5255,7 +5240,7 @@ func (m *Document) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Encoding objects. -func (m *Encoding) ResolveReferences(root string) (interface{}, error) { +func (m *Encoding) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Headers != nil { _, err := m.Headers.ResolveReferences(root) @@ -5275,7 +5260,7 @@ func (m *Encoding) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Encodings objects. -func (m *Encodings) ResolveReferences(root string) (interface{}, error) { +func (m *Encodings) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5289,7 +5274,7 @@ func (m *Encodings) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Example objects. -func (m *Example) ResolveReferences(root string) (interface{}, error) { +func (m *Example) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5309,7 +5294,7 @@ func (m *Example) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ExampleOrReference objects. -func (m *ExampleOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *ExampleOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*ExampleOrReference_Example) @@ -5333,7 +5318,7 @@ func (m *ExampleOrReference) ResolveReferences(root string) (interface{}, error) } // ResolveReferences resolves references found inside ExamplesOrReferences objects. -func (m *ExamplesOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *ExamplesOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5347,7 +5332,7 @@ func (m *ExamplesOrReferences) ResolveReferences(root string) (interface{}, erro } // ResolveReferences resolves references found inside Expression objects. -func (m *Expression) ResolveReferences(root string) (interface{}, error) { +func (m *Expression) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5361,7 +5346,7 @@ func (m *Expression) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ExternalDocs objects. -func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) { +func (m *ExternalDocs) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.SpecificationExtension { if item != nil { @@ -5375,7 +5360,7 @@ func (m *ExternalDocs) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Header objects. -func (m *Header) ResolveReferences(root string) (interface{}, error) { +func (m *Header) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Schema != nil { _, err := m.Schema.ResolveReferences(root) @@ -5413,7 +5398,7 @@ func (m *Header) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside HeaderOrReference objects. -func (m *HeaderOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *HeaderOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*HeaderOrReference_Header) @@ -5437,7 +5422,7 @@ func (m *HeaderOrReference) ResolveReferences(root string) (interface{}, error) } // ResolveReferences resolves references found inside HeadersOrReferences objects. -func (m *HeadersOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *HeadersOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5451,7 +5436,7 @@ func (m *HeadersOrReferences) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside Info objects. -func (m *Info) ResolveReferences(root string) (interface{}, error) { +func (m *Info) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Contact != nil { _, err := m.Contact.ResolveReferences(root) @@ -5477,7 +5462,7 @@ func (m *Info) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ItemsItem objects. -func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) { +func (m *ItemsItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.SchemaOrReference { if item != nil { @@ -5491,7 +5476,7 @@ func (m *ItemsItem) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside License objects. -func (m *License) ResolveReferences(root string) (interface{}, error) { +func (m *License) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.SpecificationExtension { if item != nil { @@ -5505,7 +5490,7 @@ func (m *License) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Link objects. -func (m *Link) ResolveReferences(root string) (interface{}, error) { +func (m *Link) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Parameters != nil { _, err := m.Parameters.ResolveReferences(root) @@ -5537,7 +5522,7 @@ func (m *Link) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside LinkOrReference objects. -func (m *LinkOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *LinkOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*LinkOrReference_Link) @@ -5561,7 +5546,7 @@ func (m *LinkOrReference) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside LinksOrReferences objects. -func (m *LinksOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *LinksOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5575,7 +5560,7 @@ func (m *LinksOrReferences) ResolveReferences(root string) (interface{}, error) } // ResolveReferences resolves references found inside MediaType objects. -func (m *MediaType) ResolveReferences(root string) (interface{}, error) { +func (m *MediaType) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Schema != nil { _, err := m.Schema.ResolveReferences(root) @@ -5613,7 +5598,7 @@ func (m *MediaType) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside MediaTypes objects. -func (m *MediaTypes) ResolveReferences(root string) (interface{}, error) { +func (m *MediaTypes) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5627,7 +5612,7 @@ func (m *MediaTypes) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedAny objects. -func (m *NamedAny) ResolveReferences(root string) (interface{}, error) { +func (m *NamedAny) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5639,7 +5624,7 @@ func (m *NamedAny) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedCallbackOrReference objects. -func (m *NamedCallbackOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedCallbackOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5651,7 +5636,7 @@ func (m *NamedCallbackOrReference) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside NamedEncoding objects. -func (m *NamedEncoding) ResolveReferences(root string) (interface{}, error) { +func (m *NamedEncoding) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5663,7 +5648,7 @@ func (m *NamedEncoding) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedExampleOrReference objects. -func (m *NamedExampleOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedExampleOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5675,7 +5660,7 @@ func (m *NamedExampleOrReference) ResolveReferences(root string) (interface{}, e } // ResolveReferences resolves references found inside NamedHeaderOrReference objects. -func (m *NamedHeaderOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedHeaderOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5687,7 +5672,7 @@ func (m *NamedHeaderOrReference) ResolveReferences(root string) (interface{}, er } // ResolveReferences resolves references found inside NamedLinkOrReference objects. -func (m *NamedLinkOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedLinkOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5699,7 +5684,7 @@ func (m *NamedLinkOrReference) ResolveReferences(root string) (interface{}, erro } // ResolveReferences resolves references found inside NamedMediaType objects. -func (m *NamedMediaType) ResolveReferences(root string) (interface{}, error) { +func (m *NamedMediaType) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5711,7 +5696,7 @@ func (m *NamedMediaType) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedParameterOrReference objects. -func (m *NamedParameterOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedParameterOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5723,7 +5708,7 @@ func (m *NamedParameterOrReference) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside NamedPathItem objects. -func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) { +func (m *NamedPathItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5735,7 +5720,7 @@ func (m *NamedPathItem) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside NamedRequestBodyOrReference objects. -func (m *NamedRequestBodyOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedRequestBodyOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5747,7 +5732,7 @@ func (m *NamedRequestBodyOrReference) ResolveReferences(root string) (interface{ } // ResolveReferences resolves references found inside NamedResponseOrReference objects. -func (m *NamedResponseOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedResponseOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5759,7 +5744,7 @@ func (m *NamedResponseOrReference) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside NamedSchemaOrReference objects. -func (m *NamedSchemaOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedSchemaOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5771,7 +5756,7 @@ func (m *NamedSchemaOrReference) ResolveReferences(root string) (interface{}, er } // ResolveReferences resolves references found inside NamedSecuritySchemeOrReference objects. -func (m *NamedSecuritySchemeOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *NamedSecuritySchemeOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5783,7 +5768,7 @@ func (m *NamedSecuritySchemeOrReference) ResolveReferences(root string) (interfa } // ResolveReferences resolves references found inside NamedServerVariable objects. -func (m *NamedServerVariable) ResolveReferences(root string) (interface{}, error) { +func (m *NamedServerVariable) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5795,13 +5780,13 @@ func (m *NamedServerVariable) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside NamedString objects. -func (m *NamedString) ResolveReferences(root string) (interface{}, error) { +func (m *NamedString) ResolveReferences(root string) (*yaml.Node, 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) { +func (m *NamedStringArray) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Value != nil { _, err := m.Value.ResolveReferences(root) @@ -5813,7 +5798,7 @@ func (m *NamedStringArray) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside OauthFlow objects. -func (m *OauthFlow) ResolveReferences(root string) (interface{}, error) { +func (m *OauthFlow) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Scopes != nil { _, err := m.Scopes.ResolveReferences(root) @@ -5833,7 +5818,7 @@ func (m *OauthFlow) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside OauthFlows objects. -func (m *OauthFlows) ResolveReferences(root string) (interface{}, error) { +func (m *OauthFlows) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Implicit != nil { _, err := m.Implicit.ResolveReferences(root) @@ -5871,7 +5856,7 @@ func (m *OauthFlows) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Object objects. -func (m *Object) ResolveReferences(root string) (interface{}, error) { +func (m *Object) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -5885,7 +5870,7 @@ func (m *Object) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Operation objects. -func (m *Operation) ResolveReferences(root string) (interface{}, error) { +func (m *Operation) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.ExternalDocs != nil { _, err := m.ExternalDocs.ResolveReferences(root) @@ -5947,7 +5932,7 @@ func (m *Operation) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Parameter objects. -func (m *Parameter) ResolveReferences(root string) (interface{}, error) { +func (m *Parameter) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Schema != nil { _, err := m.Schema.ResolveReferences(root) @@ -5985,7 +5970,7 @@ func (m *Parameter) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ParameterOrReference objects. -func (m *ParameterOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *ParameterOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*ParameterOrReference_Parameter) @@ -6009,7 +5994,7 @@ func (m *ParameterOrReference) ResolveReferences(root string) (interface{}, erro } // ResolveReferences resolves references found inside ParametersOrReferences objects. -func (m *ParametersOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *ParametersOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6023,7 +6008,7 @@ func (m *ParametersOrReferences) ResolveReferences(root string) (interface{}, er } // ResolveReferences resolves references found inside PathItem objects. -func (m *PathItem) ResolveReferences(root string) (interface{}, error) { +func (m *PathItem) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.XRef != "" { info, err := compiler.ReadInfoForRef(root, m.XRef) @@ -6115,7 +6100,7 @@ func (m *PathItem) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Paths objects. -func (m *Paths) ResolveReferences(root string) (interface{}, error) { +func (m *Paths) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.Path { if item != nil { @@ -6137,7 +6122,7 @@ func (m *Paths) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Properties objects. -func (m *Properties) ResolveReferences(root string) (interface{}, error) { +func (m *Properties) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6151,7 +6136,7 @@ func (m *Properties) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Reference objects. -func (m *Reference) ResolveReferences(root string) (interface{}, error) { +func (m *Reference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.XRef != "" { info, err := compiler.ReadInfoForRef(root, m.XRef) @@ -6164,7 +6149,7 @@ func (m *Reference) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside RequestBodiesOrReferences objects. -func (m *RequestBodiesOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *RequestBodiesOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6178,7 +6163,7 @@ func (m *RequestBodiesOrReferences) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside RequestBody objects. -func (m *RequestBody) ResolveReferences(root string) (interface{}, error) { +func (m *RequestBody) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Content != nil { _, err := m.Content.ResolveReferences(root) @@ -6198,7 +6183,7 @@ func (m *RequestBody) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside RequestBodyOrReference objects. -func (m *RequestBodyOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *RequestBodyOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*RequestBodyOrReference_RequestBody) @@ -6222,7 +6207,7 @@ func (m *RequestBodyOrReference) ResolveReferences(root string) (interface{}, er } // ResolveReferences resolves references found inside Response objects. -func (m *Response) ResolveReferences(root string) (interface{}, error) { +func (m *Response) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Headers != nil { _, err := m.Headers.ResolveReferences(root) @@ -6254,7 +6239,7 @@ func (m *Response) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ResponseOrReference objects. -func (m *ResponseOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *ResponseOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*ResponseOrReference_Response) @@ -6278,7 +6263,7 @@ func (m *ResponseOrReference) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside Responses objects. -func (m *Responses) ResolveReferences(root string) (interface{}, error) { +func (m *Responses) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Default != nil { _, err := m.Default.ResolveReferences(root) @@ -6306,7 +6291,7 @@ func (m *Responses) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ResponsesOrReferences objects. -func (m *ResponsesOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *ResponsesOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6320,7 +6305,7 @@ func (m *ResponsesOrReferences) ResolveReferences(root string) (interface{}, err } // ResolveReferences resolves references found inside Schema objects. -func (m *Schema) ResolveReferences(root string) (interface{}, error) { +func (m *Schema) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Discriminator != nil { _, err := m.Discriminator.ResolveReferences(root) @@ -6420,7 +6405,7 @@ func (m *Schema) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside SchemaOrReference objects. -func (m *SchemaOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *SchemaOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*SchemaOrReference_Schema) @@ -6444,7 +6429,7 @@ func (m *SchemaOrReference) ResolveReferences(root string) (interface{}, error) } // ResolveReferences resolves references found inside SchemasOrReferences objects. -func (m *SchemasOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *SchemasOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6458,7 +6443,7 @@ func (m *SchemasOrReferences) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside SecurityRequirement objects. -func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error) { +func (m *SecurityRequirement) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6472,7 +6457,7 @@ func (m *SecurityRequirement) ResolveReferences(root string) (interface{}, error } // ResolveReferences resolves references found inside SecurityScheme objects. -func (m *SecurityScheme) ResolveReferences(root string) (interface{}, error) { +func (m *SecurityScheme) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Flows != nil { _, err := m.Flows.ResolveReferences(root) @@ -6492,7 +6477,7 @@ func (m *SecurityScheme) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside SecuritySchemeOrReference objects. -func (m *SecuritySchemeOrReference) ResolveReferences(root string) (interface{}, error) { +func (m *SecuritySchemeOrReference) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) { p, ok := m.Oneof.(*SecuritySchemeOrReference_SecurityScheme) @@ -6516,7 +6501,7 @@ func (m *SecuritySchemeOrReference) ResolveReferences(root string) (interface{}, } // ResolveReferences resolves references found inside SecuritySchemesOrReferences objects. -func (m *SecuritySchemesOrReferences) ResolveReferences(root string) (interface{}, error) { +func (m *SecuritySchemesOrReferences) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6530,7 +6515,7 @@ func (m *SecuritySchemesOrReferences) ResolveReferences(root string) (interface{ } // ResolveReferences resolves references found inside Server objects. -func (m *Server) ResolveReferences(root string) (interface{}, error) { +func (m *Server) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.Variables != nil { _, err := m.Variables.ResolveReferences(root) @@ -6550,7 +6535,7 @@ func (m *Server) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ServerVariable objects. -func (m *ServerVariable) ResolveReferences(root string) (interface{}, error) { +func (m *ServerVariable) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.SpecificationExtension { if item != nil { @@ -6564,7 +6549,7 @@ func (m *ServerVariable) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside ServerVariables objects. -func (m *ServerVariables) ResolveReferences(root string) (interface{}, error) { +func (m *ServerVariables) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6578,19 +6563,19 @@ func (m *ServerVariables) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside SpecificationExtension objects. -func (m *SpecificationExtension) ResolveReferences(root string) (interface{}, error) { +func (m *SpecificationExtension) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside StringArray objects. -func (m *StringArray) ResolveReferences(root string) (interface{}, error) { +func (m *StringArray) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) return nil, compiler.NewErrorGroupOrNil(errors) } // ResolveReferences resolves references found inside Strings objects. -func (m *Strings) ResolveReferences(root string) (interface{}, error) { +func (m *Strings) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.AdditionalProperties { if item != nil { @@ -6604,7 +6589,7 @@ func (m *Strings) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Tag objects. -func (m *Tag) ResolveReferences(root string) (interface{}, error) { +func (m *Tag) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) if m.ExternalDocs != nil { _, err := m.ExternalDocs.ResolveReferences(root) @@ -6624,7 +6609,7 @@ func (m *Tag) ResolveReferences(root string) (interface{}, error) { } // ResolveReferences resolves references found inside Xml objects. -func (m *Xml) ResolveReferences(root string) (interface{}, error) { +func (m *Xml) ResolveReferences(root string) (*yaml.Node, error) { errors := make([]error, 0) for _, item := range m.SpecificationExtension { if item != nil { From 1c4d15c2e7e243487faeaa90ce044def86a308ac Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Sat, 11 Jul 2020 20:13:09 -0700 Subject: [PATCH 09/13] minor renaming --- compiler/extension-handler.go | 4 +- generate-gnostic/generate-compiler.go | 3 +- openapiv2/OpenAPIv2.go | 60 +++++++++++++-------------- openapiv3/OpenAPIv3.go | 60 +++++++++++++-------------- 4 files changed, 63 insertions(+), 64 deletions(-) diff --git a/compiler/extension-handler.go b/compiler/extension-handler.go index dcb7e138..9d95c007 100644 --- a/compiler/extension-handler.go +++ b/compiler/extension-handler.go @@ -33,8 +33,8 @@ type ExtensionHandler struct { Name string } -// HandleExtension calls a binary extension handler. -func HandleExtension(context *Context, in *yaml.Node, extensionName string) (bool, *any.Any, error) { +// CallExtension calls a binary extension handler. +func CallExtension(context *Context, in *yaml.Node, extensionName string) (bool, *any.Any, error) { handled := false var errFromPlugin error var outFromPlugin *any.Any diff --git a/generate-gnostic/generate-compiler.go b/generate-gnostic/generate-compiler.go index abf1295b..a7f12e78 100644 --- a/generate-gnostic/generate-compiler.go +++ b/generate-gnostic/generate-compiler.go @@ -568,7 +568,7 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print("pair.Value, _ = compiler.StringForScalarNode(v)") } else if mapTypeName == "Any" { code.Print("result := &Any{}") - code.Print("handled, resultFromExt, err := compiler.HandleExtension(context, v, k)") + code.Print("handled, resultFromExt, err := compiler.CallExtension(context, v, k)") code.Print("if handled {") code.Print(" if err != nil {") code.Print(" errors = append(errors, err)") @@ -584,7 +584,6 @@ func (domain *Domain) generateConstructorForType(code *printer.Code, typeName st code.Print(" errors = append(errors, err)") code.Print(" }") code.Print("}") - } else { code.Print("var err error") code.Print("pair.Value, err = New%s(v, compiler.NewContext(k, context))", mapTypeName) diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index 8a08a616..279431cc 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -151,7 +151,7 @@ func NewApiKeySecurity(in *yaml.Node, context *compiler.Context) (*ApiKeySecurit pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -232,7 +232,7 @@ func NewBasicAuthenticationSecurity(in *yaml.Node, context *compiler.Context) (* pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -340,7 +340,7 @@ func NewBodyParameter(in *yaml.Node, context *compiler.Context) (*BodyParameter, pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -418,7 +418,7 @@ func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -461,7 +461,7 @@ func NewDefault(in *yaml.Node, context *compiler.Context) (*Default, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -714,7 +714,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -757,7 +757,7 @@ func NewExamples(in *yaml.Node, context *compiler.Context) (*Examples, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -831,7 +831,7 @@ func NewExternalDocs(in *yaml.Node, context *compiler.Context) (*ExternalDocs, e pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -977,7 +977,7 @@ func NewFileSchema(in *yaml.Node, context *compiler.Context) (*FileSchema, error pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1265,7 +1265,7 @@ func NewFormDataParameterSubSchema(in *yaml.Node, context *compiler.Context) (*F pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1517,7 +1517,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1796,7 +1796,7 @@ func NewHeaderParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Hea pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1937,7 +1937,7 @@ func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2068,7 +2068,7 @@ func NewLicense(in *yaml.Node, context *compiler.Context) (*License, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2639,7 +2639,7 @@ func NewOauth2AccessCodeSecurity(in *yaml.Node, context *compiler.Context) (*Oau pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2753,7 +2753,7 @@ func NewOauth2ApplicationSecurity(in *yaml.Node, context *compiler.Context) (*Oa pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2867,7 +2867,7 @@ func NewOauth2ImplicitSecurity(in *yaml.Node, context *compiler.Context) (*Oauth pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2981,7 +2981,7 @@ func NewOauth2PasswordSecurity(in *yaml.Node, context *compiler.Context) (*Oauth pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3200,7 +3200,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3449,7 +3449,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3734,7 +3734,7 @@ func NewPathParameterSubSchema(in *yaml.Node, context *compiler.Context) (*PathP pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3785,7 +3785,7 @@ func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4041,7 +4041,7 @@ func NewPrimitivesItems(in *yaml.Node, context *compiler.Context) (*PrimitivesIt pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4359,7 +4359,7 @@ func NewQueryParameterSubSchema(in *yaml.Node, context *compiler.Context) (*Quer pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4452,7 +4452,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4592,7 +4592,7 @@ func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4947,7 +4947,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -5239,7 +5239,7 @@ func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -5310,7 +5310,7 @@ func NewVendorExtension(in *yaml.Node, context *compiler.Context) (*VendorExtens pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -5405,7 +5405,7 @@ func NewXml(in *yaml.Node, context *compiler.Context) (*Xml, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) diff --git a/openapiv3/OpenAPIv3.go b/openapiv3/OpenAPIv3.go index 359b2a3e..80a20c12 100644 --- a/openapiv3/OpenAPIv3.go +++ b/openapiv3/OpenAPIv3.go @@ -156,7 +156,7 @@ func NewCallback(in *yaml.Node, context *compiler.Context) (*Callback, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -358,7 +358,7 @@ func NewComponents(in *yaml.Node, context *compiler.Context) (*Components, error pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -436,7 +436,7 @@ func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -541,7 +541,7 @@ func NewDiscriminator(in *yaml.Node, context *compiler.Context) (*Discriminator, pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -691,7 +691,7 @@ func NewDocument(in *yaml.Node, context *compiler.Context) (*Document, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -787,7 +787,7 @@ func NewEncoding(in *yaml.Node, context *compiler.Context) (*Encoding, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -904,7 +904,7 @@ func NewExample(in *yaml.Node, context *compiler.Context) (*Example, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1017,7 +1017,7 @@ func NewExpression(in *yaml.Node, context *compiler.Context) (*Expression, error pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1091,7 +1091,7 @@ func NewExternalDocs(in *yaml.Node, context *compiler.Context) (*ExternalDocs, e pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1241,7 +1241,7 @@ func NewHeader(in *yaml.Node, context *compiler.Context) (*Header, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1431,7 +1431,7 @@ func NewInfo(in *yaml.Node, context *compiler.Context) (*Info, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1525,7 +1525,7 @@ func NewLicense(in *yaml.Node, context *compiler.Context) (*License, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1630,7 +1630,7 @@ func NewLink(in *yaml.Node, context *compiler.Context) (*Link, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -1787,7 +1787,7 @@ func NewMediaType(in *yaml.Node, context *compiler.Context) (*MediaType, error) pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2512,7 +2512,7 @@ func NewOauthFlow(in *yaml.Node, context *compiler.Context) (*OauthFlow, error) pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2599,7 +2599,7 @@ func NewOauthFlows(in *yaml.Node, context *compiler.Context) (*OauthFlows, error pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2642,7 +2642,7 @@ func NewObject(in *yaml.Node, context *compiler.Context) (*Object, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -2829,7 +2829,7 @@ func NewOperation(in *yaml.Node, context *compiler.Context) (*Operation, error) pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3003,7 +3003,7 @@ func NewParameter(in *yaml.Node, context *compiler.Context) (*Parameter, error) pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3255,7 +3255,7 @@ func NewPathItem(in *yaml.Node, context *compiler.Context) (*PathItem, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3325,7 +3325,7 @@ func NewPaths(in *yaml.Node, context *compiler.Context) (*Paths, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3497,7 +3497,7 @@ func NewRequestBody(in *yaml.Node, context *compiler.Context) (*RequestBody, err pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3630,7 +3630,7 @@ func NewResponse(in *yaml.Node, context *compiler.Context) (*Response, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -3749,7 +3749,7 @@ func NewResponses(in *yaml.Node, context *compiler.Context) (*Responses, error) pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4193,7 +4193,7 @@ func NewSchema(in *yaml.Node, context *compiler.Context) (*Schema, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4422,7 +4422,7 @@ func NewSecurityScheme(in *yaml.Node, context *compiler.Context) (*SecuritySchem pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4576,7 +4576,7 @@ func NewServer(in *yaml.Node, context *compiler.Context) (*Server, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4662,7 +4662,7 @@ func NewServerVariable(in *yaml.Node, context *compiler.Context) (*ServerVariabl pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4844,7 +4844,7 @@ func NewTag(in *yaml.Node, context *compiler.Context) (*Tag, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) @@ -4940,7 +4940,7 @@ func NewXml(in *yaml.Node, context *compiler.Context) (*Xml, error) { pair := &NamedAny{} pair.Name = k result := &Any{} - handled, resultFromExt, err := compiler.HandleExtension(context, v, k) + handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { if err != nil { errors = append(errors, err) From 18593993192d6780f45a84462f3f028c975fedae Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Sun, 12 Jul 2020 17:28:20 -0700 Subject: [PATCH 10/13] Update company name. --- COMPILE-PROTOS.sh | 2 +- apps/disco/main.go | 2 +- apps/petstore-builder/main.go | 2 +- apps/petstore-builder/petstore-v2.go | 2 +- apps/petstore-builder/petstore-v3.go | 2 +- apps/report-messages/main.go | 2 +- apps/report/main.go | 2 +- compiler/context.go | 2 +- compiler/error.go | 2 +- compiler/extension-handler.go | 2 +- compiler/helpers.go | 2 +- compiler/main.go | 2 +- compiler/reader.go | 2 +- compiler/reader_test.go | 2 +- conversions/openapiv2.go | 2 +- conversions/openapiv3.go | 2 +- discovery/document.go | 2 +- discovery/list.go | 2 +- extensions/extension.pb.go | 2 +- extensions/extension.proto | 2 +- extensions/extensions.go | 2 +- extensions/extensions_test.go | 2 +- generate-gnostic/domain.go | 2 +- generate-gnostic/generate-extension.go | 2 +- generate-gnostic/generate-proto.go | 2 +- generate-gnostic/helpers.go | 2 +- generate-gnostic/main.go | 2 +- generate-gnostic/types.go | 2 +- gnostic.go | 2 +- gnostic_test.go | 2 +- jsonschema/display.go | 2 +- jsonschema/models.go | 2 +- jsonschema/operations.go | 2 +- jsonschema/reader.go | 2 +- jsonschema/writer.go | 2 +- jsonwriter/writer.go | 2 +- lib/gnostic.go | 2 +- linters/go/gnostic-lint-descriptions/linter_v3.go | 2 +- linters/go/gnostic-lint-descriptions/main.go | 2 +- linters/go/gnostic-lint-paths/main.go | 2 +- metrics/vocabulary/vocabulary_test.go | 2 +- openapiv2/OpenAPIv2.go | 6 ++++-- openapiv3/schema-generator/main.go | 2 +- plugins/gnostic-analyze/main.go | 2 +- plugins/gnostic-analyze/statistics/statsv2.go | 2 +- plugins/gnostic-analyze/statistics/statsv3.go | 2 +- plugins/gnostic-analyze/summarize/main.go | 2 +- plugins/gnostic-complexity/complexity_test.go | 2 +- plugins/gnostic-plugin-request/main.go | 2 +- plugins/gnostic-process-plugin-response/main.go | 2 +- plugins/gnostic-summary/main.go | 2 +- plugins/gnostic-vocabulary/vocabulary_test.go | 2 +- plugins/plugin.pb.go | 2 +- plugins/plugin.proto | 2 +- plugins/plugins_test.go | 2 +- printer/code.go | 2 +- surface/field.go | 2 +- surface/model.go | 2 +- surface/model_openapiv2.go | 2 +- surface/model_openapiv3.go | 2 +- surface/surface.pb.go | 2 +- surface/surface.proto | 2 +- surface/type.go | 2 +- tools/format-schema/main.go | 2 +- tools/j2y2j/main.go | 2 +- 65 files changed, 68 insertions(+), 66 deletions(-) diff --git a/COMPILE-PROTOS.sh b/COMPILE-PROTOS.sh index 1d77fa6d..60639d6b 100755 --- a/COMPILE-PROTOS.sh +++ b/COMPILE-PROTOS.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2016 Google Inc. All Rights Reserved. +# Copyright 2016 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/apps/disco/main.go b/apps/disco/main.go index 4b122cb7..59bc19bc 100644 --- a/apps/disco/main.go +++ b/apps/disco/main.go @@ -1,4 +1,4 @@ -// Copyright 2019 Google Inc. All Rights Reserved. +// Copyright 2019 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/apps/petstore-builder/main.go b/apps/petstore-builder/main.go index 8a3eb8cd..6ab6c278 100644 --- a/apps/petstore-builder/main.go +++ b/apps/petstore-builder/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/apps/petstore-builder/petstore-v2.go b/apps/petstore-builder/petstore-v2.go index c90c09da..83457fa3 100644 --- a/apps/petstore-builder/petstore-v2.go +++ b/apps/petstore-builder/petstore-v2.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/apps/petstore-builder/petstore-v3.go b/apps/petstore-builder/petstore-v3.go index d3a64a3e..240a3435 100644 --- a/apps/petstore-builder/petstore-v3.go +++ b/apps/petstore-builder/petstore-v3.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/apps/report-messages/main.go b/apps/report-messages/main.go index b11e50b1..74c43f06 100644 --- a/apps/report-messages/main.go +++ b/apps/report-messages/main.go @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2018 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/apps/report/main.go b/apps/report/main.go index ca92ca5d..c259d843 100644 --- a/apps/report/main.go +++ b/apps/report/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/compiler/context.go b/compiler/context.go index a64c1b75..1250a6c5 100644 --- a/compiler/context.go +++ b/compiler/context.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/compiler/error.go b/compiler/error.go index d8672c10..7db23997 100644 --- a/compiler/error.go +++ b/compiler/error.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/compiler/extension-handler.go b/compiler/extension-handler.go index 9d95c007..5e734cdc 100644 --- a/compiler/extension-handler.go +++ b/compiler/extension-handler.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/compiler/helpers.go b/compiler/helpers.go index 5e62bc57..155f3755 100644 --- a/compiler/helpers.go +++ b/compiler/helpers.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/compiler/main.go b/compiler/main.go index 9713a21c..ce9fcc45 100644 --- a/compiler/main.go +++ b/compiler/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/compiler/reader.go b/compiler/reader.go index e1d8eddd..be0e8b40 100644 --- a/compiler/reader.go +++ b/compiler/reader.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/compiler/reader_test.go b/compiler/reader_test.go index d85749b4..325aab47 100644 --- a/compiler/reader_test.go +++ b/compiler/reader_test.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/conversions/openapiv2.go b/conversions/openapiv2.go index de5c0975..70365536 100644 --- a/conversions/openapiv2.go +++ b/conversions/openapiv2.go @@ -1,4 +1,4 @@ -// Copyright 2019 Google Inc. All Rights Reserved. +// Copyright 2019 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/conversions/openapiv3.go b/conversions/openapiv3.go index 5a5b95f7..ab0a7eaf 100644 --- a/conversions/openapiv3.go +++ b/conversions/openapiv3.go @@ -1,4 +1,4 @@ -// Copyright 2019 Google Inc. All Rights Reserved. +// Copyright 2019 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/discovery/document.go b/discovery/document.go index d9eb251d..fbdf3ed4 100644 --- a/discovery/document.go +++ b/discovery/document.go @@ -1,4 +1,4 @@ -// Copyright 2019 Google Inc. All Rights Reserved. +// Copyright 2019 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/discovery/list.go b/discovery/list.go index 20bcc7b0..ebe01991 100644 --- a/discovery/list.go +++ b/discovery/list.go @@ -1,4 +1,4 @@ -// Copyright 2019 Google Inc. All Rights Reserved. +// Copyright 2019 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/extensions/extension.pb.go b/extensions/extension.pb.go index b3e633b3..ef2492eb 100644 --- a/extensions/extension.pb.go +++ b/extensions/extension.pb.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/extensions/extension.proto b/extensions/extension.proto index 142f34f8..5ee29038 100644 --- a/extensions/extension.proto +++ b/extensions/extension.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/extensions/extensions.go b/extensions/extensions.go index 94a8e62a..89973840 100644 --- a/extensions/extensions.go +++ b/extensions/extensions.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/extensions/extensions_test.go b/extensions/extensions_test.go index 4543229c..0b43a0dc 100644 --- a/extensions/extensions_test.go +++ b/extensions/extensions_test.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/generate-gnostic/domain.go b/generate-gnostic/domain.go index 327b927a..1487dec9 100644 --- a/generate-gnostic/domain.go +++ b/generate-gnostic/domain.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/generate-gnostic/generate-extension.go b/generate-gnostic/generate-extension.go index 9e7eb9c3..c9af15ea 100644 --- a/generate-gnostic/generate-extension.go +++ b/generate-gnostic/generate-extension.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/generate-gnostic/generate-proto.go b/generate-gnostic/generate-proto.go index 4741af6a..fd1c042a 100644 --- a/generate-gnostic/generate-proto.go +++ b/generate-gnostic/generate-proto.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/generate-gnostic/helpers.go b/generate-gnostic/helpers.go index 221af2a4..5bd42968 100644 --- a/generate-gnostic/helpers.go +++ b/generate-gnostic/helpers.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/generate-gnostic/main.go b/generate-gnostic/main.go index 7a13be40..84d61731 100644 --- a/generate-gnostic/main.go +++ b/generate-gnostic/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/generate-gnostic/types.go b/generate-gnostic/types.go index 5148d829..917296cc 100644 --- a/generate-gnostic/types.go +++ b/generate-gnostic/types.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/gnostic.go b/gnostic.go index cbdb30a8..24a2760c 100644 --- a/gnostic.go +++ b/gnostic.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/gnostic_test.go b/gnostic_test.go index 349bd19c..c670ab67 100644 --- a/gnostic_test.go +++ b/gnostic_test.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/jsonschema/display.go b/jsonschema/display.go index 9b5c5611..028a760a 100644 --- a/jsonschema/display.go +++ b/jsonschema/display.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/jsonschema/models.go b/jsonschema/models.go index 65dffbff..4781bdc5 100644 --- a/jsonschema/models.go +++ b/jsonschema/models.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/jsonschema/operations.go b/jsonschema/operations.go index 0ce2271e..ba8dd4a9 100644 --- a/jsonschema/operations.go +++ b/jsonschema/operations.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/jsonschema/reader.go b/jsonschema/reader.go index 89015ca1..b8583d46 100644 --- a/jsonschema/reader.go +++ b/jsonschema/reader.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/jsonschema/writer.go b/jsonschema/writer.go index 0f9d4510..340dc5f9 100644 --- a/jsonschema/writer.go +++ b/jsonschema/writer.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/jsonwriter/writer.go b/jsonwriter/writer.go index a7f35e30..12b3b3c6 100644 --- a/jsonwriter/writer.go +++ b/jsonwriter/writer.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/lib/gnostic.go b/lib/gnostic.go index 5414396e..9d24a932 100644 --- a/lib/gnostic.go +++ b/lib/gnostic.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/linters/go/gnostic-lint-descriptions/linter_v3.go b/linters/go/gnostic-lint-descriptions/linter_v3.go index 8c38053d..7b9894d1 100644 --- a/linters/go/gnostic-lint-descriptions/linter_v3.go +++ b/linters/go/gnostic-lint-descriptions/linter_v3.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/linters/go/gnostic-lint-descriptions/main.go b/linters/go/gnostic-lint-descriptions/main.go index b09c9c82..a3416721 100644 --- a/linters/go/gnostic-lint-descriptions/main.go +++ b/linters/go/gnostic-lint-descriptions/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/linters/go/gnostic-lint-paths/main.go b/linters/go/gnostic-lint-paths/main.go index 2a611756..81934453 100644 --- a/linters/go/gnostic-lint-paths/main.go +++ b/linters/go/gnostic-lint-paths/main.go @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2018 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/metrics/vocabulary/vocabulary_test.go b/metrics/vocabulary/vocabulary_test.go index e7aa4be9..36751fb6 100644 --- a/metrics/vocabulary/vocabulary_test.go +++ b/metrics/vocabulary/vocabulary_test.go @@ -1,4 +1,4 @@ -// Copyright 2020 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index 279431cc..ad678a85 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -18,10 +18,11 @@ package openapi_v2 import ( "fmt" - "github.com/googleapis/gnostic/compiler" - "gopkg.in/yaml.v3" "regexp" "strings" + + "github.com/googleapis/gnostic/compiler" + "gopkg.in/yaml.v3" ) // Version returns the package name (and OpenAPI version). @@ -417,6 +418,7 @@ func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k + pair.Value = compiler.HandleExtension() result := &Any{} handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { diff --git a/openapiv3/schema-generator/main.go b/openapiv3/schema-generator/main.go index b06ef46c..ca3366cd 100644 --- a/openapiv3/schema-generator/main.go +++ b/openapiv3/schema-generator/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-analyze/main.go b/plugins/gnostic-analyze/main.go index 5c5cfed0..0d4babac 100644 --- a/plugins/gnostic-analyze/main.go +++ b/plugins/gnostic-analyze/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-analyze/statistics/statsv2.go b/plugins/gnostic-analyze/statistics/statsv2.go index 3107907c..b7199308 100644 --- a/plugins/gnostic-analyze/statistics/statsv2.go +++ b/plugins/gnostic-analyze/statistics/statsv2.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-analyze/statistics/statsv3.go b/plugins/gnostic-analyze/statistics/statsv3.go index c8efef5c..7bd4ba0d 100644 --- a/plugins/gnostic-analyze/statistics/statsv3.go +++ b/plugins/gnostic-analyze/statistics/statsv3.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-analyze/summarize/main.go b/plugins/gnostic-analyze/summarize/main.go index 69adad9e..c0119ce7 100644 --- a/plugins/gnostic-analyze/summarize/main.go +++ b/plugins/gnostic-analyze/summarize/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-complexity/complexity_test.go b/plugins/gnostic-complexity/complexity_test.go index 6aab969c..116702b1 100644 --- a/plugins/gnostic-complexity/complexity_test.go +++ b/plugins/gnostic-complexity/complexity_test.go @@ -1,4 +1,4 @@ -// Copyright 2020 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-plugin-request/main.go b/plugins/gnostic-plugin-request/main.go index 8d98ecf1..f85f012c 100644 --- a/plugins/gnostic-plugin-request/main.go +++ b/plugins/gnostic-plugin-request/main.go @@ -1,4 +1,4 @@ -// Copyright 2020 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-process-plugin-response/main.go b/plugins/gnostic-process-plugin-response/main.go index 1660ea49..3332128b 100644 --- a/plugins/gnostic-process-plugin-response/main.go +++ b/plugins/gnostic-process-plugin-response/main.go @@ -1,4 +1,4 @@ -// Copyright 2020 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-summary/main.go b/plugins/gnostic-summary/main.go index 07e246c6..9a63a736 100644 --- a/plugins/gnostic-summary/main.go +++ b/plugins/gnostic-summary/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/gnostic-vocabulary/vocabulary_test.go b/plugins/gnostic-vocabulary/vocabulary_test.go index c2a9a2fc..0cffab92 100644 --- a/plugins/gnostic-vocabulary/vocabulary_test.go +++ b/plugins/gnostic-vocabulary/vocabulary_test.go @@ -1,4 +1,4 @@ -// Copyright 2020 Google Inc. All Rights Reserved. +// Copyright 2020 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/plugin.pb.go b/plugins/plugin.pb.go index e86297d4..e8d8d172 100644 --- a/plugins/plugin.pb.go +++ b/plugins/plugin.pb.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/plugin.proto b/plugins/plugin.proto index 0658445b..f7ab94c9 100644 --- a/plugins/plugin.proto +++ b/plugins/plugin.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/plugins/plugins_test.go b/plugins/plugins_test.go index 275089d4..d3de3764 100644 --- a/plugins/plugins_test.go +++ b/plugins/plugins_test.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/printer/code.go b/printer/code.go index f8fd3db4..e64c581d 100644 --- a/printer/code.go +++ b/printer/code.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/surface/field.go b/surface/field.go index da540a5f..f5f676d6 100644 --- a/surface/field.go +++ b/surface/field.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/surface/model.go b/surface/model.go index 54d3e655..0e1b0d8d 100644 --- a/surface/model.go +++ b/surface/model.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/surface/model_openapiv2.go b/surface/model_openapiv2.go index 104c54bb..772c1e54 100644 --- a/surface/model_openapiv2.go +++ b/surface/model_openapiv2.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/surface/model_openapiv3.go b/surface/model_openapiv3.go index c0cf77f8..86282028 100644 --- a/surface/model_openapiv3.go +++ b/surface/model_openapiv3.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/surface/surface.pb.go b/surface/surface.pb.go index 170de99f..e568ef47 100644 --- a/surface/surface.pb.go +++ b/surface/surface.pb.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/surface/surface.proto b/surface/surface.proto index 9d82208a..e8bec205 100644 --- a/surface/surface.proto +++ b/surface/surface.proto @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/surface/type.go b/surface/type.go index 60f3e882..bb4bdb00 100644 --- a/surface/type.go +++ b/surface/type.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/tools/format-schema/main.go b/tools/format-schema/main.go index 85edbd79..1feb7134 100644 --- a/tools/format-schema/main.go +++ b/tools/format-schema/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/tools/j2y2j/main.go b/tools/j2y2j/main.go index ac8cdfbf..ae8eecb0 100644 --- a/tools/j2y2j/main.go +++ b/tools/j2y2j/main.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From c203b00013b0f3d397b2aff1818a0474a47a338a Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Mon, 13 Jul 2020 13:20:45 -0700 Subject: [PATCH 11/13] regenerate OpenAPIv2.go to remove experimental code (accidentally added) --- openapiv2/OpenAPIv2.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openapiv2/OpenAPIv2.go b/openapiv2/OpenAPIv2.go index ad678a85..279431cc 100644 --- a/openapiv2/OpenAPIv2.go +++ b/openapiv2/OpenAPIv2.go @@ -18,11 +18,10 @@ package openapi_v2 import ( "fmt" - "regexp" - "strings" - "github.com/googleapis/gnostic/compiler" "gopkg.in/yaml.v3" + "regexp" + "strings" ) // Version returns the package name (and OpenAPI version). @@ -418,7 +417,6 @@ func NewContact(in *yaml.Node, context *compiler.Context) (*Contact, error) { if strings.HasPrefix(k, "x-") { pair := &NamedAny{} pair.Name = k - pair.Value = compiler.HandleExtension() result := &Any{} handled, resultFromExt, err := compiler.CallExtension(context, v, k) if handled { From f825536ac70879c1d1f3c3e05e07d8e936849a42 Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Tue, 14 Jul 2020 10:24:32 -0700 Subject: [PATCH 12/13] fix openapiv3.proto to maintain Info field order, go mod tidy, regen go.sum --- discovery/discovery.pb.go | 2 +- extensions/extension.pb.go | 2 +- metrics/complexity.pb.go | 2 +- metrics/vocabulary.pb.go | 2 +- openapiv2/OpenAPIv2.pb.go | 2 +- openapiv3/OpenAPIv3.pb.go | 32 ++++++++++++++++---------------- openapiv3/OpenAPIv3.proto | 4 ++-- plugins/plugin.pb.go | 2 +- surface/surface.pb.go | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/discovery/discovery.pb.go b/discovery/discovery.pb.go index f76d235a..b56535cb 100644 --- a/discovery/discovery.pb.go +++ b/discovery/discovery.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.0 +// protoc v3.12.3 // source: discovery/discovery.proto package discovery_v1 diff --git a/extensions/extension.pb.go b/extensions/extension.pb.go index ef2492eb..eba0c6e5 100644 --- a/extensions/extension.pb.go +++ b/extensions/extension.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.0 +// protoc v3.12.3 // source: extensions/extension.proto package openapiextension_v1 diff --git a/metrics/complexity.pb.go b/metrics/complexity.pb.go index bf715707..6f4b18c4 100644 --- a/metrics/complexity.pb.go +++ b/metrics/complexity.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.0 +// protoc v3.12.3 // source: metrics/complexity.proto package gnostic_metrics_v1 diff --git a/metrics/vocabulary.pb.go b/metrics/vocabulary.pb.go index 6ea247a7..ffb2ece8 100644 --- a/metrics/vocabulary.pb.go +++ b/metrics/vocabulary.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.0 +// protoc v3.12.3 // source: metrics/vocabulary.proto package gnostic_metrics_v1 diff --git a/openapiv2/OpenAPIv2.pb.go b/openapiv2/OpenAPIv2.pb.go index a9e551e2..559ddea1 100644 --- a/openapiv2/OpenAPIv2.pb.go +++ b/openapiv2/OpenAPIv2.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.0 +// protoc v3.12.3 // source: openapiv2/OpenAPIv2.proto package openapi_v2 diff --git a/openapiv3/OpenAPIv3.pb.go b/openapiv3/OpenAPIv3.pb.go index 0dfc9909..1eb11f3f 100644 --- a/openapiv3/OpenAPIv3.pb.go +++ b/openapiv3/OpenAPIv3.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.0 +// protoc v3.12.3 // source: openapiv3/OpenAPIv3.proto package openapi_v3 @@ -1628,8 +1628,8 @@ type Info struct { Contact *Contact `protobuf:"bytes,4,opt,name=contact,proto3" json:"contact,omitempty"` License *License `protobuf:"bytes,5,opt,name=license,proto3" json:"license,omitempty"` Version string `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"` - Summary string `protobuf:"bytes,7,opt,name=summary,proto3" json:"summary,omitempty"` - SpecificationExtension []*NamedAny `protobuf:"bytes,8,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` + SpecificationExtension []*NamedAny `protobuf:"bytes,7,rep,name=specification_extension,json=specificationExtension,proto3" json:"specification_extension,omitempty"` + Summary string `protobuf:"bytes,8,opt,name=summary,proto3" json:"summary,omitempty"` } func (x *Info) Reset() { @@ -1706,18 +1706,18 @@ func (x *Info) GetVersion() string { return "" } -func (x *Info) GetSummary() string { +func (x *Info) GetSpecificationExtension() []*NamedAny { if x != nil { - return x.Summary + return x.SpecificationExtension } - return "" + return nil } -func (x *Info) GetSpecificationExtension() []*NamedAny { +func (x *Info) GetSummary() string { if x != nil { - return x.SpecificationExtension + return x.Summary } - return nil + return "" } type ItemsItem struct { @@ -6076,13 +6076,13 @@ var file_openapiv3_OpenAPIv3_proto_rawDesc = []byte{ 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x18, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, - 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, - 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, - 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, - 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x5a, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, + 0x4d, 0x0a, 0x17, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, 0x4e, 0x61, + 0x6d, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x52, 0x16, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, + 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x5a, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x4d, 0x0a, 0x13, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x33, 0x2e, diff --git a/openapiv3/OpenAPIv3.proto b/openapiv3/OpenAPIv3.proto index 734a7c3b..2138abf0 100644 --- a/openapiv3/OpenAPIv3.proto +++ b/openapiv3/OpenAPIv3.proto @@ -208,8 +208,8 @@ message Info { Contact contact = 4; License license = 5; string version = 6; - string summary = 7; - repeated NamedAny specification_extension = 8; + repeated NamedAny specification_extension = 7; + string summary = 8; } message ItemsItem { diff --git a/plugins/plugin.pb.go b/plugins/plugin.pb.go index e8d8d172..83b89ad5 100644 --- a/plugins/plugin.pb.go +++ b/plugins/plugin.pb.go @@ -23,7 +23,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.0 +// protoc v3.12.3 // source: plugins/plugin.proto package gnostic_plugin_v1 diff --git a/surface/surface.pb.go b/surface/surface.pb.go index e568ef47..13370603 100644 --- a/surface/surface.pb.go +++ b/surface/surface.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.23.0 -// protoc v3.12.0 +// protoc v3.12.3 // source: surface/surface.proto package surface_v1 From e62e68050cfa34279b480fe0d0717b806a7b4d64 Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Tue, 14 Jul 2020 12:58:06 -0700 Subject: [PATCH 13/13] Add new ParseDocument() functions to directly read OpenAPI v2 and v3 docs from bytes. --- openapiv2/document.go | 26 +++++++++++++++++++++ openapiv2/openapiv2_test.go | 45 +++++++++++++++++++++++++++++++++++++ openapiv3/document.go | 26 +++++++++++++++++++++ openapiv3/openapiv3_test.go | 45 +++++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 openapiv2/document.go create mode 100644 openapiv2/openapiv2_test.go create mode 100644 openapiv3/document.go create mode 100644 openapiv3/openapiv3_test.go diff --git a/openapiv2/document.go b/openapiv2/document.go new file mode 100644 index 00000000..ddeed5c8 --- /dev/null +++ b/openapiv2/document.go @@ -0,0 +1,26 @@ +// Copyright 2020 Google LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package openapi_v2 + +import "github.com/googleapis/gnostic/compiler" + +// ParseDocument reads an OpenAPI v2 description from a YAML/JSON representation. +func ParseDocument(b []byte) (*Document, error) { + info, err := compiler.ReadInfoFromBytes("", b) + if err != nil { + return nil, err + } + return NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, nil)) +} diff --git a/openapiv2/openapiv2_test.go b/openapiv2/openapiv2_test.go new file mode 100644 index 00000000..7b7297a9 --- /dev/null +++ b/openapiv2/openapiv2_test.go @@ -0,0 +1,45 @@ +// Copyright 2020 Google LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package openapi_v2 + +import ( + "io/ioutil" + "testing" + + "github.com/googleapis/gnostic/compiler" +) + +func TestParseDocument(t *testing.T) { + filename := "../examples/v2.0/yaml/petstore.yaml" + b, err := ioutil.ReadFile(filename) + if err != nil { + t.Logf("unable to read file %s", filename) + t.FailNow() + } + info, err := compiler.ReadInfoFromBytes("", b) + if err != nil { + t.Logf("unable to parse file %s", filename) + t.FailNow() + } + d, err := NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, nil)) + if err != nil { + t.Logf("%s", err.Error()) + t.FailNow() + } + title := "Swagger Petstore" + if d.Info.Title != title { + t.Errorf("unexpected value for Title: %s (expected %s)", d.Info.Title, title) + } +} diff --git a/openapiv3/document.go b/openapiv3/document.go new file mode 100644 index 00000000..4d08e508 --- /dev/null +++ b/openapiv3/document.go @@ -0,0 +1,26 @@ +// Copyright 2020 Google LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package openapi_v3 + +import "github.com/googleapis/gnostic/compiler" + +// ParseDocument reads an OpenAPI v3 description from a YAML/JSON representation. +func ParseDocument(b []byte) (*Document, error) { + info, err := compiler.ReadInfoFromBytes("", b) + if err != nil { + return nil, err + } + return NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, nil)) +} diff --git a/openapiv3/openapiv3_test.go b/openapiv3/openapiv3_test.go new file mode 100644 index 00000000..f1a95a3a --- /dev/null +++ b/openapiv3/openapiv3_test.go @@ -0,0 +1,45 @@ +// Copyright 2020 Google LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package openapi_v3 + +import ( + "io/ioutil" + "testing" + + "github.com/googleapis/gnostic/compiler" +) + +func TestParseDocument(t *testing.T) { + filename := "../examples/v3.0/yaml/petstore.yaml" + b, err := ioutil.ReadFile(filename) + if err != nil { + t.Logf("unable to read file %s", filename) + t.FailNow() + } + info, err := compiler.ReadInfoFromBytes("", b) + if err != nil { + t.Logf("unable to parse file %s", filename) + t.FailNow() + } + d, err := NewDocument(info.Content[0], compiler.NewContextWithExtensions("$root", nil, nil)) + if err != nil { + t.Logf("%s", err.Error()) + t.FailNow() + } + title := "OpenAPI Petstore" + if d.Info.Title != title { + t.Errorf("unexpected value for Title: %s (expected %s)", d.Info.Title, title) + } +}