Skip to content

Commit

Permalink
Add support for enum arrays. (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzHW authored May 20, 2020
1 parent 57a06a8 commit 89741bb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions surface/model_openapiv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/googleapis/gnostic/compiler"
openapiv3 "github.com/googleapis/gnostic/openapiv3"
"log"
"strings"
)

type OpenAPI3Builder struct {
Expand Down Expand Up @@ -385,13 +386,13 @@ func (b *OpenAPI3Builder) buildFromSchema(name string, schema *openapiv3.Schema)
for _, schemaOrRef := range schema.Items.SchemaOrReference {
arrayFieldInfo := b.buildFromSchemaOrReference(name, schemaOrRef)
if arrayFieldInfo != nil {
fInfo.fieldKind, fInfo.fieldType, fInfo.fieldFormat = FieldKind_ARRAY, arrayFieldInfo.fieldType, arrayFieldInfo.fieldFormat
fInfo.fieldKind, fInfo.fieldType, fInfo.fieldFormat, fInfo.enumValues = FieldKind_ARRAY, arrayFieldInfo.fieldType, arrayFieldInfo.fieldFormat, arrayFieldInfo.enumValues
return fInfo
}
}
default:
for _, enum := range schema.GetEnum() {
fInfo.enumValues = append(fInfo.enumValues, enum.Yaml)
fInfo.enumValues = append(fInfo.enumValues, strings.TrimSuffix(enum.Yaml, "\n"))
}
// We go a scalar value
fInfo.fieldKind, fInfo.fieldType, fInfo.fieldFormat = FieldKind_SCALAR, schema.Type, schema.Format
Expand Down

0 comments on commit 89741bb

Please sign in to comment.