pb33f / libopenapi

libopenapi is a fully featured, high performance OpenAPI 3.1, 3.0 and Swagger parser, library, validator and toolkit for golang applications.
https://pb33f.io/libopenapi/
Other
362 stars 46 forks source link

type of enum is nil #277

Open georgesfarah opened 1 month ago

georgesfarah commented 1 month ago

Can't get types of enums, it's nil. Currently I'm using this workaround to get the types:

for pair := orderedmap.First(schema.Properties); pair != nil; pair = pair.Next() {
    Type := ""
    if pair.Value().Schema().Type != nil {
        Type = pair.Value().Schema().Type[0]
    } else if pair.Value().Schema().Enum != nil {
        valueType := reflect.TypeOf(pair.Value().Schema().Enum[0].Value)
        Type = valueType.String()
    }
}
daveshanley commented 1 month ago

Can you provide a sample specification snippet please?