@nestjs/swagger
Version:
OpenAPI for NestJS: generate the API document from controllers and decorators, serve Swagger UI, and derive request types with mapped types.
20 lines (19 loc) • 674 B
JavaScript
import { DECORATORS } from '../constants.js';
export function ApiLink({ from, fromField = 'id', routeParam }) {
return (controllerPrototype, key, descriptor) => {
const { prototype } = from;
if (prototype) {
const links = [
...(Reflect.getMetadata(DECORATORS.API_LINK, prototype) ?? [])
];
links.push({
method: descriptor.value,
prototype: controllerPrototype,
field: fromField,
parameter: routeParam
});
Reflect.defineMetadata(DECORATORS.API_LINK, links, prototype);
}
return descriptor;
};
}