From d11adfc70451f88d62c4ddddbab3c85104da31f7 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 19 Nov 2021 20:16:01 +0100 Subject: [PATCH] fix(core): update --- test/test.ts | 2 +- ts/smartswagger.classes.smartswagger.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/test.ts b/test/test.ts index 3545de6..b2f1049 100644 --- a/test/test.ts +++ b/test/test.ts @@ -2,7 +2,7 @@ import { expect, tap } from '@pushrocks/tapbundle'; import * as smartswagger from '../ts/index'; tap.test('first test', async () => { - console.log(smartswagger.standardExport); + console.log(smartswagger); }); tap.start(); diff --git a/ts/smartswagger.classes.smartswagger.ts b/ts/smartswagger.classes.smartswagger.ts index c7c1ffe..067a3c3 100644 --- a/ts/smartswagger.classes.smartswagger.ts +++ b/ts/smartswagger.classes.smartswagger.ts @@ -85,7 +85,7 @@ export class Smartswagger { /** * merges a document from url */ - public async mergeDocumentFromUrl(documentUrlArg: string, basePathArg: string) { + public async mergeDocumentFromUrl(documentUrlArg: string, basePathArg: string = '') { console.log(`getting document at ${documentUrlArg} for merging...`) const documentResponse = await plugins.nodeFetch(documentUrlArg, { headers: { @@ -98,6 +98,18 @@ export class Smartswagger { await this.mergeDocument(apiDoc, basePathArg); } + /** + * merge multiple documents in parallel + * @param urlArrayArg + */ + public async mergeManyDocumentsFromUrl(urlArrayArg: {url: string, basePath: string}[]) { + const promiseArray: Promise[] = []; + for (const urlArg of urlArrayArg) { + promiseArray.push(this.mergeDocumentFromUrl(urlArg.url, urlArg.basePath)); + }; + await Promise.all(promiseArray); + } + /** * merges a component to routes based on regex */