documentedStatuses lists a response's status codes in numeric order, with "default" last.
(responses *openapi3.Responses)
| 337 | // documentedStatuses lists a response's status codes in numeric order, with |
| 338 | // "default" last. |
| 339 | func documentedStatuses(responses *openapi3.Responses) []string { |
| 340 | var statuses []string |
| 341 | if responses == nil { |
| 342 | return statuses |
| 343 | } |
| 344 | for code := range responses.Map() { |
| 345 | statuses = append(statuses, code) |
| 346 | } |
| 347 | sort.Slice(statuses, func(i, j int) bool { |
| 348 | a, b := statuses[i], statuses[j] |
| 349 | if (a == "default") != (b == "default") { |
| 350 | return b == "default" |
| 351 | } |
| 352 | return a < b |
| 353 | }) |
| 354 | return statuses |
| 355 | } |
| 356 | |
| 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. |
no test coverage detected