fix(core): update
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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, };
|
||||
|
Reference in New Issue
Block a user