MCPcopy Create free account
hub / github.com/cli/cli / pickStatus

Function pickStatus

script/ghmock/schemacmd.go:359–374  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
359func 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.
377func schemaAt(ref *openapi3.SchemaRef, at string) (*openapi3.SchemaRef, error) {

Callers 1

describeRESTFunction · 0.85

Calls 2

ValueMethod · 0.80
StatusMethod · 0.65

Tested by

no test coverage detected