(schema: JSONSchema)
| 23 | * @internal |
| 24 | */ |
| 25 | export function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject> { |
| 26 | const content: Record<string, OpenAPI.MediaTypeObject> = {} |
| 27 | |
| 28 | const [matches, restSchema] = filterSchemaBranches(schema, isFileSchema) |
| 29 | |
| 30 | for (const file of matches as FileSchema[]) { |
| 31 | content[file.contentMediaType] = { |
| 32 | schema: toOpenAPISchema(file), |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | if (restSchema !== undefined && !isAnySchema(restSchema) && !isNeverSchema(restSchema)) { |
| 37 | content['application/json'] = { |
| 38 | schema: toOpenAPISchema(restSchema), |
| 39 | } |
| 40 | |
| 41 | const isStillHasFileSchema = findDeepMatches(v => isObject(v) && isFileSchema(v), restSchema).values.length > 0 |
| 42 | |
| 43 | if (isStillHasFileSchema) { |
| 44 | content['multipart/form-data'] = { |
| 45 | schema: toOpenAPISchema(restSchema), |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return content |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * @internal |
no test coverage detected