Skip to content

Commit bf9229c

Browse files
committed
Include description for allowed enum values for elements within a slice
1 parent 589584f commit bf9229c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/generators/openapi.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,14 @@ func (g openAPITypeWriter) generateProperty(m *types.Member, parent *types.Type)
10211021
return err
10221022
}
10231023
g.Do("SchemaProps: spec.SchemaProps{\n", nil)
1024+
t := resolveAliasAndPtrType(m.Type)
10241025
var extraComments []string
10251026
if enumType, isEnum := g.enumContext.EnumType(m.Type); isEnum {
10261027
extraComments = enumType.DescriptionLines()
1028+
} else if t.Kind == types.Slice {
1029+
if enumType, isEnum := g.enumContext.EnumType(t.Elem); isEnum {
1030+
extraComments = enumType.DescriptionLines()
1031+
}
10271032
}
10281033
g.generateDescription(append(m.CommentLines, extraComments...))
10291034
jsonTags := getJsonTags(m)
@@ -1040,7 +1045,6 @@ func (g openAPITypeWriter) generateProperty(m *types.Member, parent *types.Type)
10401045
if err != nil {
10411046
return err
10421047
}
1043-
t := resolveAliasAndPtrType(m.Type)
10441048
// If we can get a openAPI type and format for this type, we consider it to be simple property
10451049
typeString, format := openapi.OpenAPITypeFormat(t.String())
10461050
if typeString != "" {

0 commit comments

Comments
 (0)