UNPKG

openapi-metadata

Version:

Auto-Generate OpenAPI specifications from Typescript decorators

22 lines (19 loc) 614 B
import type { OpenAPIV3 } from "openapi-types"; import type { Context } from "../context.js"; import type { OperationResponseMetadata } from "../metadata/operation-response.js"; import { loadType } from "../loaders/type.js"; export async function generateOperationResponse( context: Context, metadata: OperationResponseMetadata, ): Promise<OpenAPIV3.ResponseObject> { const { type, schema: s, enum: e, mediaType, status, ...response } = metadata; return { description: "", ...response, content: { [mediaType]: { schema: await loadType(context, metadata), }, }, }; }