fix(core): update
This commit is contained in:
parent
762305f29c
commit
692be04ed4
65
package-lock.json
generated
65
package-lock.json
generated
@ -13,6 +13,7 @@
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/swagger-ui-express": "^4.1.3",
|
||||
"matcher": "^4.0.0",
|
||||
"node-fetch": "^2.6.6",
|
||||
"openapi-types": "^9.3.1"
|
||||
},
|
||||
@ -2467,6 +2468,32 @@
|
||||
"matcher": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/smartmatch/node_modules/escape-string-regexp": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/smartmatch/node_modules/matcher": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/matcher/-/matcher-3.0.0.tgz",
|
||||
"integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"escape-string-regexp": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/smartmime": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartmime/-/smartmime-1.0.5.tgz",
|
||||
@ -9540,23 +9567,24 @@
|
||||
}
|
||||
},
|
||||
"node_modules/matcher": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/matcher/-/matcher-3.0.0.tgz",
|
||||
"integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==",
|
||||
"dev": true,
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/matcher/-/matcher-4.0.0.tgz",
|
||||
"integrity": "sha512-S6x5wmcDmsDRRU/c2dkccDwQPXoFczc5+HpQ2lON8pnvHlnvHAHj5WlLVvw6n6vNyHuVugYrFohYxbS+pvFpKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"escape-string-regexp": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/matcher/node_modules/escape-string-regexp": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
@ -17387,6 +17415,23 @@
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"matcher": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"escape-string-regexp": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||
"dev": true
|
||||
},
|
||||
"matcher": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/matcher/-/matcher-3.0.0.tgz",
|
||||
"integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"escape-string-regexp": "^4.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartmime": {
|
||||
@ -22758,10 +22803,9 @@
|
||||
}
|
||||
},
|
||||
"matcher": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/matcher/-/matcher-3.0.0.tgz",
|
||||
"integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==",
|
||||
"dev": true,
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/matcher/-/matcher-4.0.0.tgz",
|
||||
"integrity": "sha512-S6x5wmcDmsDRRU/c2dkccDwQPXoFczc5+HpQ2lON8pnvHlnvHAHj5WlLVvw6n6vNyHuVugYrFohYxbS+pvFpKQ==",
|
||||
"requires": {
|
||||
"escape-string-regexp": "^4.0.0"
|
||||
},
|
||||
@ -22769,8 +22813,7 @@
|
||||
"escape-string-regexp": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -26,6 +26,7 @@
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/swagger-ui-express": "^4.1.3",
|
||||
"matcher": "^4.0.0",
|
||||
"node-fetch": "^2.6.6",
|
||||
"openapi-types": "^9.3.1"
|
||||
},
|
||||
|
10
test/test.ts
10
test/test.ts
@ -27,6 +27,16 @@ tap.test('first test', async () => {
|
||||
''
|
||||
);
|
||||
|
||||
await testSmartswaggerInstance.mergeComponentToRoutes({excludeGlobArray: [], includeGlobArray: []}, {
|
||||
"securitySchemes": {
|
||||
"token": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
"bearerFormat": "JWT"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// express stuff
|
||||
testExpressServer = new smartexpress.Server({
|
||||
cors: true,
|
||||
|
@ -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, };
|
||||
|
Loading…
Reference in New Issue
Block a user