UNPKG

openapi-metadata

Version:

Auto-Generate OpenAPI specifications from Typescript decorators

25 lines (22 loc) 796 B
import { N as NoExplicitTypeError, R as ReflectMetadataMissingError } from './openapi-metadata.BKn6E22y.mjs'; function assertReflectMetadata() { if (typeof Reflect !== "object" || typeof Reflect.getMetadata !== "function") { throw new ReflectMetadataMissingError(); } } function findType({ metadataKey, prototype, propertyKey }) { assertReflectMetadata(); const reflectedType = Reflect.getMetadata(metadataKey, prototype, propertyKey); if (!reflectedType) { throw new NoExplicitTypeError(prototype.constructor.name, propertyKey); } return reflectedType; } const IS_THUNK_REG = /^.+=>[\w\d\s\t\n\r]*/; function isThunk(value) { if (typeof value !== "function") { return false; } return Boolean(IS_THUNK_REG.exec(value)); } export { findType as f, isThunk as i };