From a94871d726c767ca439cf647aac7a0046cac916b Mon Sep 17 00:00:00 2001 From: Kiyan Date: Fri, 2 Aug 2024 10:02:42 +0800 Subject: [PATCH] fix(schema): schema example not work in Parameter --- huma.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/huma.go b/huma.go index f3fd5622..65187c2c 100644 --- a/huma.go +++ b/huma.go @@ -167,6 +167,9 @@ func findParams(registry Registry, op *Operation, t reflect.Type) *findResult[*p if e := f.Tag.Get("example"); e != "" { example = jsonTagValue(registry, f.Type.Name(), pfi.Schema, f.Tag.Get("example")) } + if example == nil && len(pfi.Schema.Examples) > 0 { + example = pfi.Schema.Examples[0] + } // While discouraged, make it possible to make query/header params required. if r := f.Tag.Get("required"); r == "true" {