MCPcopy Index your code
hub / github.com/massCodeIO/massCode / pickMediaEntry

Function pickMediaEntry

src/main/http/import/openapi.ts:244–268  ·  view source on GitHub ↗
(content: UnknownRecord)

Source from the content-addressed store, hash-verified

242}
243
244function 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
270function sampleFromSchema(schema: unknown): unknown {
271 if (!isRecord(schema))

Callers 1

parseRequestBodyFunction · 0.85

Calls 1

isRecordFunction · 0.70

Tested by

no test coverage detected