@nestjs/swagger
Advanced tools
Comparing version 1.2.3 to 1.2.4
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const constants_1 = require("../constants"); | ||
const defaultConsumes = 'application/json'; | ||
exports.exploreGlobalApiConsumesMetadata = metatype => { | ||
const consumes = Reflect.getMetadata(constants_1.DECORATORS.API_CONSUMES, metatype); | ||
return consumes | ||
? { consumes } | ||
: { | ||
consumes: [defaultConsumes] | ||
}; | ||
return consumes ? { consumes } : undefined; | ||
}; | ||
exports.exploreApiConsumesMetadata = (instance, prototype, method) => { | ||
return (Reflect.getMetadata(constants_1.DECORATORS.API_CONSUMES, method) || [defaultConsumes]); | ||
return Reflect.getMetadata(constants_1.DECORATORS.API_CONSUMES, method); | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const constants_1 = require("../constants"); | ||
const defaultProduces = 'application/json'; | ||
exports.exploreGlobalApiProducesMetadata = metatype => { | ||
const produces = Reflect.getMetadata(constants_1.DECORATORS.API_PRODUCES, metatype); | ||
return produces | ||
? { produces } | ||
: { | ||
produces: [defaultProduces] | ||
}; | ||
return produces ? { produces } : undefined; | ||
}; | ||
exports.exploreApiProducesMetadata = (instance, prototype, method) => { | ||
return (Reflect.getMetadata(constants_1.DECORATORS.API_PRODUCES, method) || [defaultProduces]); | ||
return Reflect.getMetadata(constants_1.DECORATORS.API_PRODUCES, method); | ||
}; |
@@ -14,2 +14,3 @@ import { Controller } from '@nestjs/common/interfaces'; | ||
private mergeMetadata(globalMetadata, methodMetadata); | ||
private assignDefaultMimeType(metadata, key); | ||
} |
@@ -60,2 +60,4 @@ "use strict"; | ||
const mergedMethodMetadata = this.mergeMetadata(globalMetadata, lodash_1.omitBy(methodMetadata, lodash_1.isEmpty)); | ||
this.assignDefaultMimeType(mergedMethodMetadata, 'produces'); | ||
this.assignDefaultMimeType(mergedMethodMetadata, 'consumes'); | ||
return Object.assign({ responses: {} }, globalMetadata, mergedMethodMetadata); | ||
@@ -116,3 +118,10 @@ }); | ||
} | ||
assignDefaultMimeType(metadata, key) { | ||
if (metadata[key]) { | ||
return undefined; | ||
} | ||
const defaultMimeType = 'application/json'; | ||
metadata[key] = [defaultMimeType]; | ||
} | ||
} | ||
exports.SwaggerExplorer = SwaggerExplorer; |
@@ -14,3 +14,3 @@ "use strict"; | ||
app.use(finalPath, swaggerUi.serve, swaggerUi.setup(document, options)); | ||
app.use(finalPath + '?json', (req, res) => res.json(document)); | ||
app.use(finalPath + '-json', (req, res) => res.json(document)); | ||
} | ||
@@ -17,0 +17,0 @@ } |
{ | ||
"name": "@nestjs/swagger", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": | ||
@@ -5,0 +5,0 @@ "Nest - modern, fast, powerful node.js web framework (@swagger)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50037
0