MCPcopy Create free account
hub / github.com/middleapi/orpc / toOpenAPIContent

Function toOpenAPIContent

packages/openapi/src/openapi-utils.ts:25–51  ·  view source on GitHub ↗
(schema: JSONSchema)

Source from the content-addressed store, hash-verified

23 * @internal
24 */
25export 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

Callers 4

#requestMethod · 0.90
#successResponseMethod · 0.90
#errorResponseMethod · 0.90

Calls 7

filterSchemaBranchesFunction · 0.90
isAnySchemaFunction · 0.90
isNeverSchemaFunction · 0.90
findDeepMatchesFunction · 0.90
isObjectFunction · 0.90
isFileSchemaFunction · 0.90
toOpenAPISchemaFunction · 0.85

Tested by

no test coverage detected