(content: UnknownRecord)
| 242 | } |
| 243 | |
| 244 | function pickMediaEntry(content: UnknownRecord): { |
| 245 | mediaType: string |
| 246 | media: UnknownRecord |
| 247 | } | null { |
| 248 | const preferredTypes = [ |
| 249 | 'application/json', |
| 250 | 'application/x-www-form-urlencoded', |
| 251 | 'multipart/form-data', |
| 252 | 'text/plain', |
| 253 | ] |
| 254 | |
| 255 | for (const mediaType of preferredTypes) { |
| 256 | if (isRecord(content[mediaType])) { |
| 257 | return { media: content[mediaType], mediaType } |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | const firstEntry = Object.entries(content).find(([, value]) => |
| 262 | isRecord(value), |
| 263 | ) |
| 264 | if (!firstEntry) |
| 265 | return null |
| 266 | |
| 267 | return { media: firstEntry[1] as UnknownRecord, mediaType: firstEntry[0] } |
| 268 | } |
| 269 | |
| 270 | function sampleFromSchema(schema: unknown): unknown { |
| 271 | if (!isRecord(schema)) |
no test coverage detected