Skip to content

Commit

Permalink
Recognize popular UUID types (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Jun 25, 2024
1 parent b8c2e24 commit f54ba6b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,17 @@ func (r *Reflector) applySubSchemas(v reflect.Value, rc *ReflectContext, schema
}

func (r *Reflector) isWellKnownType(t reflect.Type, schema *Schema) bool {
ts := refl.GoType(t)

switch ts {
case "github.com/google/uuid.UUID", "github.com/gofrs/uuid.UUID", "github.com/gofrs/uuid/v5::uuid.UUID":
schema.AddType(String)
schema.WithFormat("uuid")
schema.WithExamples("248df4b7-aa70-47b8-a036-33ac447e668d")

return true
}

if t == typeOfByteSlice {
schema.AddType(String)
schema.WithFormat("base64")
Expand Down

0 comments on commit f54ba6b

Please sign in to comment.