jsonMedia picks the JSON content of a documented response.
(content openapi3.Content)
| 214 | |
| 215 | // jsonMedia picks the JSON content of a documented response. |
| 216 | func 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 |
no test coverage detected