openapi-metadata
Version:
Auto-Generate OpenAPI specifications from Typescript decorators
22 lines (19 loc) • 614 B
text/typescript
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),
},
},
};
}