findParams walks the struct type t to find all fields tagged as request parameters, building their schemas and registering them on op. It skips anonymous (embedded) fields and the Body field. Returns a findResult mapping each parameter field's index path to its paramFieldInfo, which is used later d
(registry Registry, op *Operation, t reflect.Type)
| 228 | // Returns a findResult mapping each parameter field's index path to its |
| 229 | // paramFieldInfo, which is used later during request parsing. |
| 230 | func findParams(registry Registry, op *Operation, t reflect.Type) *findResult[*paramFieldInfo] { |
| 231 | return findInType(t, nil, func(f reflect.StructField, path []int) *paramFieldInfo { |
| 232 | if f.Anonymous { |
| 233 | return nil |
| 234 | } |
| 235 | |
| 236 | pl, ok := parseParamLocation(f, registry) |
| 237 | if !ok { |
| 238 | return nil |
| 239 | } |
| 240 | |
| 241 | pfi := pl.pfi |
| 242 | pfi.Schema = SchemaFromField(registry, f, "") |
| 243 | |
| 244 | // While discouraged, make it possible to make query/header params required. |
| 245 | if _, ok = f.Tag.Lookup("required"); ok { |
| 246 | pfi.Required = boolTag(f, "required", false) |
| 247 | } |
| 248 | |
| 249 | if pfi.Type == timeType { |
| 250 | timeFormat := time.RFC3339Nano |
| 251 | if pfi.Loc == "header" { |
| 252 | timeFormat = http.TimeFormat |
| 253 | } |
| 254 | if v := f.Tag.Get("timeFormat"); v != "" { |
| 255 | timeFormat = v |
| 256 | } |
| 257 | pfi.TimeFormat = timeFormat |
| 258 | } |
| 259 | |
| 260 | if !boolTag(f, "hidden", false) && pfi.Loc != "form" { |
| 261 | documentParam(op, pl) |
| 262 | } |
| 263 | |
| 264 | return pfi |
| 265 | }, false, "Body") |
| 266 | } |
| 267 | |
| 268 | // findResolvers searches a given type for resolvers matching a specified resolverType. |
| 269 | // It returns a findResult indicating whether such resolvers were found. |
no test coverage detected
searching dependent graphs…