documentParam appends pl's parameter to op.Parameters unless a parameter with the same name and location is already present, in which case it is a no-op. The schema description, if any, is promoted to the parameter level so that tools which do not read schema-level descriptions still display it.
(op *Operation, pl *paramLocation)
| 197 | // The schema description, if any, is promoted to the parameter level so that |
| 198 | // tools which do not read schema-level descriptions still display it. |
| 199 | func documentParam(op *Operation, pl *paramLocation) { |
| 200 | pfi := pl.pfi |
| 201 | for _, existing := range op.Parameters { |
| 202 | if existing.Name == pfi.Name && existing.In == pfi.Loc { |
| 203 | return |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | desc := "" |
| 208 | if pfi.Schema != nil { |
| 209 | // Some tools won't show the description if it's only on the schema. |
| 210 | desc = pfi.Schema.Description |
| 211 | } |
| 212 | |
| 213 | op.Parameters = append(op.Parameters, &Param{ |
| 214 | Name: pfi.Name, |
| 215 | Description: desc, |
| 216 | In: pfi.Loc, |
| 217 | Explode: pl.explode, |
| 218 | Required: pfi.Required, |
| 219 | Schema: pfi.Schema, |
| 220 | Style: pfi.Style, |
| 221 | }) |
| 222 | } |
| 223 | |
| 224 | // findParams walks the struct type t to find all fields tagged as request |
| 225 | // parameters, building their schemas and registering them on op. It skips |
no outgoing calls
no test coverage detected
searching dependent graphs…