openapi-metadata
Version:
Auto-Generate OpenAPI specifications from Typescript decorators
28 lines (24 loc) • 838 B
JavaScript
;
const reflectMetadataMissing = require('./openapi-metadata.B1TUxh8W.cjs');
function assertReflectMetadata() {
if (typeof Reflect !== "object" || typeof Reflect.getMetadata !== "function") {
throw new reflectMetadataMissing.ReflectMetadataMissingError();
}
}
function findType({ metadataKey, prototype, propertyKey }) {
assertReflectMetadata();
const reflectedType = Reflect.getMetadata(metadataKey, prototype, propertyKey);
if (!reflectedType) {
throw new reflectMetadataMissing.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));
}
exports.findType = findType;
exports.isThunk = isThunk;