UNPKG

nestjs-typebox

Version:

This library provides helper utilities for writing and validating NestJS APIs using [TypeBox](https://github.com/sinclairzx81/typebox) as an alternative to class-validator/class-transformer. Can be configured to patch @nestjs/swagger allowing OpenAPI gene

26 lines 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.patchNestJsSwagger = patchNestJsSwagger; const schema_object_factory_js_1 = require("@nestjs/swagger/dist/services/schema-object-factory.js"); const decorators_js_1 = require("./decorators.js"); function patchNestJsSwagger() { // eslint-disable-next-line @typescript-eslint/no-explicit-any if (schema_object_factory_js_1.SchemaObjectFactory.prototype.__primatePatched) return; const defaultExplore = schema_object_factory_js_1.SchemaObjectFactory.prototype.exploreModelSchema; const extendedExplore = function exploreModelSchema(type, schemas, schemaRefsStack) { if (this['isLazyTypeFunc'](type)) { const factory = type; type = factory(); } if (!(0, decorators_js_1.isSchemaValidator)(type)) { return defaultExplore.apply(this, [type, schemas, schemaRefsStack]); } schemas[type.name] = type.schema; return type.name; }; schema_object_factory_js_1.SchemaObjectFactory.prototype.exploreModelSchema = extendedExplore; // eslint-disable-next-line @typescript-eslint/no-explicit-any schema_object_factory_js_1.SchemaObjectFactory.prototype.__primatePatched = true; } //# sourceMappingURL=swagger-patch.js.map