fix(core): update

This commit is contained in:
2021-11-22 10:24:09 +01:00
parent 762305f29c
commit 692be04ed4
5 changed files with 83 additions and 18 deletions

View File

@ -147,23 +147,25 @@ export class Smartswagger {
*/
public mergeComponentToRoutes(
routeDescriptor: {
includeRegexpArray: RegExp[];
excludeRegexpArray: RegExp[];
includeGlobArray: string[];
excludeGlobArray: string[];
},
componentArg: plugins.openapiTypes.OpenAPIV3.ComponentsObject
) {
for (const pathCandidateRoute of Object.keys(this.apiDoc.paths)) {
let included: boolean = false;
let excluded: boolean = false;
for (const regExp of routeDescriptor.includeRegexpArray) {
if (regExp.test(pathCandidateRoute)) {
// We are using glob espressions here due to easier path expressions
for (const globExpression of routeDescriptor.includeGlobArray) {
if (plugins.matcher.isMatch(pathCandidateRoute, globExpression)) {
included = true;
break;
}
}
if (included) {
for (const regExp of routeDescriptor.excludeRegexpArray) {
if (regExp.test(pathCandidateRoute)) {
for (const globExpression of routeDescriptor.excludeGlobArray) {
if (plugins.matcher.isMatch(pathCandidateRoute, globExpression)) {
excluded = true;
break;
}
@ -177,8 +179,16 @@ export class Smartswagger {
return;
}
if (componentArg.securitySchemes) {
methodArg.security = methodArg.security || [];
for (const securityScheme of Object.keys(componentArg.securitySchemes)) {
methodArg.security.push({ [securityScheme]: [] })
}
}
};
instrumentMethod(pathCandidate.get);
instrumentMethod(pathCandidate.post);
instrumentMethod(pathCandidate.put);
instrumentMethod(pathCandidate.delete);
}
}
}

View File

@ -12,6 +12,7 @@ export { smartexpress, smartpromise };
// third party
import * as openapiTypes from 'openapi-types';
import swaggerParser from '@apidevtools/swagger-parser';
import matcher from 'matcher';
import nodeFetch from 'node-fetch';
export { openapiTypes, swaggerParser, nodeFetch };
export { openapiTypes, matcher, nodeFetch, swaggerParser, };