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 6.2.0 to 6.2.1

dist/utils/validate-global-prefix.util.d.ts

2

dist/decorators/api-response.decorator.d.ts

@@ -11,3 +11,3 @@ import { Type } from '@nestjs/common';

schema: SchemaObject & Partial<ReferenceObject>;
status?: number;
status?: number | 'default' | '1XX' | '2XX' | '3XX' | '4XX' | '5XX';
description?: string;

@@ -14,0 +14,0 @@ }

@@ -16,2 +16,4 @@ import { SwaggerUiOptions } from './swagger-ui-options.interface';

urls?: Record<'url' | 'name', string>[];
jsonDocumentUrl?: string;
yamlDocumentUrl?: string;
}

@@ -15,4 +15,4 @@ import { ApiResponseSchemaHost } from '../decorators';

links?: import("../interfaces/open-api-spec.interface").LinksObject;
status?: number;
status?: number | "default" | "1XX" | "2XX" | "3XX" | "4XX" | "5XX";
};
}

@@ -11,2 +11,3 @@ "use strict";

const normalize_rel_path_1 = require("./utils/normalize-rel-path");
const validate_global_prefix_util_1 = require("./utils/validate-global-prefix.util");
class SwaggerModule {

@@ -33,3 +34,3 @@ static createDocument(app, config, options = {}) {

}
static serveDocuments(finalPath, urlLastSubdirectory, httpAdapter, swaggerInitJS, yamlDocument, jsonDocument, html) {
static serveDocuments(finalPath, urlLastSubdirectory, httpAdapter, swaggerInitJS, options) {
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(`${finalPath}/swagger-ui-init.js`), (req, res) => {

@@ -49,3 +50,3 @@ res.type('application/javascript');

res.type('text/html');
res.send(html);
res.send(options.html);
});

@@ -55,3 +56,3 @@ try {

res.type('text/html');
res.send(html);
res.send(options.html);
});

@@ -61,9 +62,9 @@ }

}
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(`${finalPath}-json`), (req, res) => {
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(options.jsonDocumentUrl), (req, res) => {
res.type('application/json');
res.send(jsonDocument);
res.send(options.jsonDocument);
});
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(`${finalPath}-yaml`), (req, res) => {
httpAdapter.get((0, normalize_rel_path_1.normalizeRelPath)(options.yamlDocumentUrl), (req, res) => {
res.type('text/yaml');
res.send(yamlDocument);
res.send(options.yamlDocument);
});

@@ -73,3 +74,3 @@ }

const globalPrefix = (0, get_global_prefix_1.getGlobalPrefix)(app);
const finalPath = (0, validate_path_util_1.validatePath)((options === null || options === void 0 ? void 0 : options.useGlobalPrefix) && globalPrefix && !globalPrefix.match(/^(\/?)$/)
const finalPath = (0, validate_path_util_1.validatePath)((options === null || options === void 0 ? void 0 : options.useGlobalPrefix) && (0, validate_global_prefix_util_1.validateGlobalPrefix)(globalPrefix)
? `${globalPrefix}${(0, validate_path_util_1.validatePath)(path)}`

@@ -80,2 +81,11 @@ : path);

const jsonDocument = JSON.stringify(document);
const validatedGlobalPrefix = (options === null || options === void 0 ? void 0 : options.useGlobalPrefix) && (0, validate_global_prefix_util_1.validateGlobalPrefix)(globalPrefix)
? (0, validate_path_util_1.validatePath)(globalPrefix)
: '';
const finalJSONDocumentPath = (options === null || options === void 0 ? void 0 : options.jsonDocumentUrl)
? `${validatedGlobalPrefix}${(0, validate_path_util_1.validatePath)(options.jsonDocumentUrl)}`
: `${finalPath}-json`;
const finalYAMLDocumentPath = (options === null || options === void 0 ? void 0 : options.yamlDocumentUrl)
? `${validatedGlobalPrefix}${(0, validate_path_util_1.validatePath)(options.yamlDocumentUrl)}`
: `${finalPath}-yaml`;
const baseUrlForSwaggerUI = (0, normalize_rel_path_1.normalizeRelPath)(`./${urlLastSubdirectory}/`);

@@ -85,3 +95,9 @@ const html = (0, swagger_ui_1.buildSwaggerHTML)(baseUrlForSwaggerUI, document, options);

const httpAdapter = app.getHttpAdapter();
SwaggerModule.serveDocuments(finalPath, urlLastSubdirectory, httpAdapter, swaggerInitJS, yamlDocument, jsonDocument, html);
SwaggerModule.serveDocuments(finalPath, urlLastSubdirectory, httpAdapter, swaggerInitJS, {
html,
yamlDocument,
jsonDocument,
jsonDocumentUrl: finalJSONDocumentPath,
yamlDocumentUrl: finalYAMLDocumentPath
});
SwaggerModule.serveStatic(finalPath, app);

@@ -88,0 +104,0 @@ const serveStaticSlashEndingPath = `${finalPath}/${urlLastSubdirectory}`;

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

Object.defineProperty(IntersectionClassType, 'name', {
value: `Intersection${intersectedNames}`,
value: `Intersection${intersectedNames}`
});

@@ -34,0 +34,0 @@ return IntersectionClassType;

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

@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec",

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