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

Function jsonMedia

script/ghmock/restcheck.go:216–231  ·  view source on GitHub ↗

jsonMedia picks the JSON content of a documented response.

(content openapi3.Content)

Source from the content-addressed store, hash-verified

214
215// jsonMedia picks the JSON content of a documented response.
216func jsonMedia(content openapi3.Content) *openapi3.MediaType {
217 if m := content.Get("application/json"); m != nil {
218 return m
219 }
220 keys := make([]string, 0, len(content))
221 for k := range content {
222 keys = append(keys, k)
223 }
224 sort.Strings(keys)
225 for _, k := range keys {
226 if strings.Contains(k, "json") {
227 return content[k]
228 }
229 }
230 return nil
231}
232
233// restProblems turns schema validation errors into short lines that use the
234// same dotted paths as ghmock set --at. An allOf failure is replaced by the

Callers 3

describeRESTFunction · 0.85
scaffoldMethod · 0.85
checkMethod · 0.85

Calls 2

ContainsMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected