diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc41867..a70f7eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -126,7 +126,7 @@ pages: - npmci node install lts - npmci command npm install -g @gitzone/tsdoc - npmci npm prepare - - npmci command npm install --prod + - npmci npm install - npmci command tsdoc tags: - lossless diff --git a/package.json b/package.json index 7fcaf79..5699a1c 100644 --- a/package.json +++ b/package.json @@ -44,4 +44,4 @@ "npmextra.json", "readme.md" ] -} +} \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index ab45553..478ef96 100644 --- a/test/test.ts +++ b/test/test.ts @@ -7,20 +7,43 @@ let testSmartswaggerInstance: smartswagger.Smartswagger; let testExpressServer: smartexpress.Server; tap.test('first test', async () => { - testSmartswaggerInstance = await smartswagger.Smartswagger.createFromUrl('https://my.sevdesk.de/OpenAPI/ReceiptAPI/openApi.json'); - await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/ContactAPI/openApi.json', ''); - await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InvoiceAPI/openApi.json', ''); - await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/OrderAPI/openApi.json', ''); - await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InventoryAPI/openApi.json', ''); + testSmartswaggerInstance = await smartswagger.Smartswagger.createFromUrl( + 'https://my.sevdesk.de/OpenAPI/ReceiptAPI/openApi.json' + ); + await testSmartswaggerInstance.mergeDocumentFromUrl( + 'https://my.sevdesk.de/OpenAPI/ContactAPI/openApi.json', + '' + ); + await testSmartswaggerInstance.mergeDocumentFromUrl( + 'https://my.sevdesk.de/OpenAPI/InvoiceAPI/openApi.json', + '' + ); + await testSmartswaggerInstance.mergeDocumentFromUrl( + 'https://my.sevdesk.de/OpenAPI/OrderAPI/openApi.json', + '' + ); + await testSmartswaggerInstance.mergeDocumentFromUrl( + 'https://my.sevdesk.de/OpenAPI/InventoryAPI/openApi.json', + '' + ); // express stuff testExpressServer = new smartexpress.Server({ cors: true, }); - testExpressServer.addRoute('/apiui', new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashApiUiMiddleware())); - testExpressServer.addRoute('/apiredoc', new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashRedocMiddleware())) + testExpressServer.addRoute( + '/apiui', + new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashApiUiMiddleware()) + ); + testExpressServer.addRoute( + '/apiredoc', + new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashRedocMiddleware()) + ); - testExpressServer.addRoute('/apischema', new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashApiSchemaMiddleware())); + testExpressServer.addRoute( + '/apischema', + new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashApiSchemaMiddleware()) + ); await testExpressServer.start(3000); }); @@ -30,6 +53,6 @@ tap.test('should run for a few seconds', async (toolsArg) => { tap.test('should end smartswagger', async () => { await testExpressServer.stop(); -}) +}); tap.start(); diff --git a/ts/index.ts b/ts/index.ts index ed9d893..efadb14 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1 +1 @@ -export * from './smartswagger.classes.smartswagger'; \ No newline at end of file +export * from './smartswagger.classes.smartswagger'; diff --git a/ts/smartswagger.classes.smartswagger.ts b/ts/smartswagger.classes.smartswagger.ts index 067a3c3..0479576 100644 --- a/ts/smartswagger.classes.smartswagger.ts +++ b/ts/smartswagger.classes.smartswagger.ts @@ -9,9 +9,9 @@ type IExtendedApiDoc = plugins.openapiTypes.OpenAPIV3.Document & RedocProps; export class Smartswagger { // STATIC /** - * + * * @param urlArg a url arg that contains an original swagger.json in the response - * @returns an instance of + * @returns an instance of */ public static async createFromUrl(urlArg: string) { const jsonResponse = await plugins.nodeFetch(urlArg, { @@ -40,9 +40,7 @@ export class Smartswagger { * dereferences the document at hand */ public async deref() { - this.apiDoc = (await plugins.swaggerParser.dereference( - this.apiDoc - )) as IExtendedApiDoc; + this.apiDoc = (await plugins.swaggerParser.dereference(this.apiDoc)) as IExtendedApiDoc; } public async addServer(serverArg: plugins.openapiTypes.OpenAPIV3.ServerObject) { @@ -56,10 +54,7 @@ export class Smartswagger { * @param documentToMergeArg * @param basePathArg */ - public async mergeDocument( - documentToMergeArg: IExtendedApiDoc, - basePathArg: string - ) { + public async mergeDocument(documentToMergeArg: IExtendedApiDoc, basePathArg: string) { console.log(`merging document with name ${documentToMergeArg.info?.title}`); await this.deref(); // lets get a dereferenced version of the document we want to merge @@ -86,7 +81,7 @@ export class Smartswagger { * merges a document from url */ public async mergeDocumentFromUrl(documentUrlArg: string, basePathArg: string = '') { - console.log(`getting document at ${documentUrlArg} for merging...`) + console.log(`getting document at ${documentUrlArg} for merging...`); const documentResponse = await plugins.nodeFetch(documentUrlArg, { headers: { 'accept-encoding': 'application/json', @@ -102,11 +97,11 @@ export class Smartswagger { * merge multiple documents in parallel * @param urlArrayArg */ - public async mergeManyDocumentsFromUrl(urlArrayArg: {url: string, basePath: string}[]) { + 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); } diff --git a/ts/smartswagger.plugins.ts b/ts/smartswagger.plugins.ts index df053ed..0b4345d 100644 --- a/ts/smartswagger.plugins.ts +++ b/ts/smartswagger.plugins.ts @@ -1,26 +1,17 @@ // node native import * as path from 'path'; -export { - path -} +export { path }; // @pushrocks scope import * as smartexpress from '@pushrocks/smartexpress'; import * as smartpromise from '@pushrocks/smartpromise'; -export { - smartexpress, - smartpromise -} +export { smartexpress, smartpromise }; // third party import * as openapiTypes from 'openapi-types'; import swaggerParser from '@apidevtools/swagger-parser'; import nodeFetch from 'node-fetch'; -export { - openapiTypes, - swaggerParser, - nodeFetch -} +export { openapiTypes, swaggerParser, nodeFetch };