Socket
Socket
Sign inDemoInstall

@nestjs/swagger

Package Overview
Dependencies
Maintainers
2
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/swagger - npm Package Compare versions

Comparing version 7.0.4 to 7.0.5

6

dist/plugin/utils/plugin-utils.d.ts

@@ -13,3 +13,8 @@ import * as ts from 'typescript';

typeReference: string;
typeName: string;
importPath: string;
} | {
typeReference: string;
importPath: string;
typeName?: undefined;
};

@@ -24,1 +29,2 @@ export declare function insertAt(string: string, index: number, substring: string): string;

};
export declare function convertPath(windowsPath: string): string;

26

dist/plugin/utils/plugin-utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractTypeArgumentIfArray = exports.isAutoGeneratedTypeUnion = exports.isAutoGeneratedEnumUnion = exports.isDynamicallyAdded = exports.insertAt = exports.replaceImportPath = exports.hasPropertyKey = exports.isPromiseOrObservable = exports.getTypeReferenceAsString = exports.getDecoratorOrUndefinedByNames = void 0;
exports.convertPath = exports.extractTypeArgumentIfArray = exports.isAutoGeneratedTypeUnion = exports.isAutoGeneratedEnumUnion = exports.isDynamicallyAdded = exports.insertAt = exports.replaceImportPath = exports.hasPropertyKey = exports.isPromiseOrObservable = exports.getTypeReferenceAsString = exports.getDecoratorOrUndefinedByNames = void 0;
const lodash_1 = require("lodash");

@@ -120,3 +120,3 @@ const path_1 = require("path");

? options.pathToSource
: path_1.posix.dirname(fileName);
: path_1.posix.dirname(convertPath(fileName));
let relativePath = path_1.posix.relative(from, importPath);

@@ -140,6 +140,12 @@ relativePath = relativePath[0] !== '.' ? './' + relativePath : relativePath;

typeReference = typeReference.replace(importPath, relativePath);
if (options.readonly) {
const { typeName, typeImportStatement } = convertToAsyncImport(typeReference);
return {
typeReference: typeImportStatement,
typeName,
importPath: relativePath
};
}
return {
typeReference: options.readonly
? convertToAsyncImport(typeReference)
: typeReference.replace('import', 'require'),
typeReference: typeReference.replace('import', 'require'),
importPath: relativePath

@@ -155,6 +161,9 @@ };

const importPos = typeReference.indexOf(match[0]);
typeReference = typeReference.replace(match[1], `then((f) => f.${match[1]})`);
return insertAt(typeReference, importPos, 'await ');
typeReference = typeReference.replace(`.${match[1]}`, '');
return {
typeImportStatement: insertAt(typeReference, importPos, 'await '),
typeName: match[1]
};
}
return typeReference;
return { typeImportStatement: typeReference };
}

@@ -243,1 +252,2 @@ function insertAt(string, index, substring) {

}
exports.convertPath = convertPath;

@@ -22,3 +22,4 @@ import * as ts from 'typescript';

private typeReferenceStringToIdentifier;
private wrapTypeInArray;
}
export {};

@@ -105,6 +105,10 @@ "use strict";

const apiOperationDecorator = (0, plugin_utils_1.getDecoratorOrUndefinedByNames)([decorators_1.ApiOperation.name], decorators, factory);
const apiOperationExpr = apiOperationDecorator &&
(0, lodash_1.head)((0, ast_utils_1.getDecoratorArguments)(apiOperationDecorator));
const apiOperationExprProperties = apiOperationExpr &&
apiOperationExpr.properties;
let apiOperationExistingProps = undefined;
if (apiOperationDecorator && !options.readonly) {
const apiOperationExpr = (0, lodash_1.head)((0, ast_utils_1.getDecoratorArguments)(apiOperationDecorator));
if (apiOperationExpr) {
apiOperationExistingProps =
apiOperationExpr.properties;
}
}
const extractedComments = (0, ast_utils_1.getMainCommentOfNode)(node, sourceFile);

@@ -117,5 +121,5 @@ if (!extractedComments) {

factory.createPropertyAssignment(keyToGenerate, factory.createStringLiteral(extractedComments)),
...(apiOperationExprProperties ?? factory.createNodeArray())
...(apiOperationExistingProps ?? factory.createNodeArray())
];
const hasDeprecatedKey = (0, plugin_utils_1.hasPropertyKey)('deprecated', factory.createNodeArray(apiOperationExprProperties));
const hasDeprecatedKey = (0, plugin_utils_1.hasPropertyKey)('deprecated', factory.createNodeArray(apiOperationExistingProps));
if (!hasDeprecatedKey && tags.deprecated) {

@@ -186,10 +190,10 @@ const deprecatedPropertyAssignment = factory.createPropertyAssignment('deprecated', (0, ast_utils_1.createLiteralFromAnyValue)(factory, tags.deprecated));

}
const { typeName, isArray } = (0, plugin_utils_1.getTypeReferenceAsString)(type, typeChecker);
if (!typeName) {
const typeReferenceDescriptor = (0, plugin_utils_1.getTypeReferenceAsString)(type, typeChecker);
if (!typeReferenceDescriptor.typeName) {
return undefined;
}
if (typeName.includes('node_modules')) {
if (typeReferenceDescriptor.typeName.includes('node_modules')) {
return undefined;
}
const identifier = this.typeReferenceStringToIdentifier(typeName, isArray, hostFilename, options, factory);
const identifier = this.typeReferenceStringToIdentifier(typeReferenceDescriptor, hostFilename, options, factory);
return factory.createPropertyAssignment('type', identifier);

@@ -220,8 +224,8 @@ }

normalizeImportPath(pathToSource, path) {
let relativePath = path_1.posix.relative(pathToSource, path);
let relativePath = path_1.posix.relative(pathToSource, (0, plugin_utils_1.convertPath)(path));
relativePath = relativePath[0] !== '.' ? './' + relativePath : relativePath;
return relativePath;
}
typeReferenceStringToIdentifier(_typeReference, isArray, hostFilename, options, factory) {
const { typeReference, importPath } = (0, plugin_utils_1.replaceImportPath)(_typeReference, hostFilename, options);
typeReferenceStringToIdentifier(typeReferenceDescriptor, hostFilename, options, factory) {
const { typeReference, importPath, typeName } = (0, plugin_utils_1.replaceImportPath)(typeReferenceDescriptor.typeName, hostFilename, options);
let identifier;

@@ -232,10 +236,24 @@ if (options.readonly && typeReference?.includes('import')) {

}
identifier = factory.createIdentifier(isArray ? `[t["${importPath}"]]` : `t["${importPath}"]`);
let ref = `t["${importPath}"].${typeName}`;
if (typeReferenceDescriptor.isArray) {
ref = this.wrapTypeInArray(ref, typeReferenceDescriptor.arrayDepth);
}
identifier = factory.createIdentifier(ref);
}
else {
identifier = factory.createIdentifier(isArray ? `[${typeReference}]` : typeReference);
let ref = typeReference;
if (typeReferenceDescriptor.isArray) {
ref = this.wrapTypeInArray(ref, typeReferenceDescriptor.arrayDepth);
}
identifier = factory.createIdentifier(ref);
}
return identifier;
}
wrapTypeInArray(typeRef, arrayDepth) {
for (let i = 0; i < arrayDepth; i++) {
typeRef = `[${typeRef}]`;
}
return typeRef;
}
}
exports.ControllerClassVisitor = ControllerClassVisitor;

@@ -323,3 +323,3 @@ "use strict";

normalizeImportPath(pathToSource, path) {
let relativePath = path_1.posix.relative(pathToSource, path);
let relativePath = path_1.posix.relative(pathToSource, (0, plugin_utils_1.convertPath)(path));
relativePath = relativePath[0] !== '.' ? './' + relativePath : relativePath;

@@ -329,3 +329,3 @@ return relativePath;

typeReferenceToIdentifier(typeReferenceDescriptor, hostFilename, options, factory) {
const { typeReference, importPath } = (0, plugin_utils_1.replaceImportPath)(typeReferenceDescriptor.typeName, hostFilename, options);
const { typeReference, importPath, typeName } = (0, plugin_utils_1.replaceImportPath)(typeReferenceDescriptor.typeName, hostFilename, options);
let identifier;

@@ -336,3 +336,3 @@ if (options.readonly && typeReference?.includes('import')) {

}
let ref = `t["${importPath}"]`;
let ref = `t["${importPath}"].${typeName}`;
if (typeReferenceDescriptor.isArray) {

@@ -339,0 +339,0 @@ ref = this.wrapTypeInArray(ref, typeReferenceDescriptor.arrayDepth);

{
"name": "@nestjs/swagger",
"version": "7.0.4",
"version": "7.0.5",
"description": "Nest - modern, fast, powerful node.js web framework (@swagger)",

@@ -34,4 +34,4 @@ "author": "Kamil Mysliwiec",

"devDependencies": {
"@commitlint/cli": "17.6.5",
"@commitlint/config-angular": "17.6.5",
"@commitlint/cli": "17.6.6",
"@commitlint/config-angular": "17.6.6",
"@fastify/static": "6.10.2",

@@ -38,0 +38,0 @@ "@nestjs/common": "10.0.3",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc