pickStatus finds the response to describe: the one asked for, or else the first success. It returns a nil response if there's no such status.
(responses *openapi3.Responses, want int, statuses []string)
| 357 | // pickStatus finds the response to describe: the one asked for, or else the |
| 358 | // first success. It returns a nil response if there's no such status. |
| 359 | func pickStatus(responses *openapi3.Responses, want int, statuses []string) (string, *openapi3.ResponseRef) { |
| 360 | if want != 0 { |
| 361 | return strconv.Itoa(want), responses.Status(want) |
| 362 | } |
| 363 | if len(statuses) == 0 { |
| 364 | return "", nil |
| 365 | } |
| 366 | pick := statuses[0] |
| 367 | for _, s := range statuses { |
| 368 | if strings.HasPrefix(s, "2") { |
| 369 | pick = s |
| 370 | break |
| 371 | } |
| 372 | } |
| 373 | return pick, responses.Value(pick) |
| 374 | } |
| 375 | |
| 376 | // schemaAt follows a dotted path, as used by ghmock set --at, into a schema. |
| 377 | func schemaAt(ref *openapi3.SchemaRef, at string) (*openapi3.SchemaRef, error) { |
no test coverage detected