fix(core): update
This commit is contained in:
parent
d152920692
commit
f29623c084
@ -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
|
||||
|
@ -44,4 +44,4 @@
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
||||
}
|
41
test/test.ts
41
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();
|
||||
|
@ -1 +1 @@
|
||||
export * from './smartswagger.classes.smartswagger';
|
||||
export * from './smartswagger.classes.smartswagger';
|
||||
|
@ -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<void>[] = [];
|
||||
for (const urlArg of urlArrayArg) {
|
||||
promiseArray.push(this.mergeDocumentFromUrl(urlArg.url, urlArg.basePath));
|
||||
};
|
||||
}
|
||||
await Promise.all(promiseArray);
|
||||
}
|
||||
|
||||
|
@ -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 };
|
||||
|
Loading…
Reference in New Issue
Block a user