2021-11-19 19:05:52 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
|
|
|
import * as smartswagger from '../ts/index';
|
|
|
|
|
2021-11-20 19:32:16 +00:00
|
|
|
import * as smartexpress from '@pushrocks/smartexpress';
|
|
|
|
|
|
|
|
let testSmartswaggerInstance: smartswagger.Smartswagger;
|
|
|
|
let testExpressServer: smartexpress.Server;
|
|
|
|
|
2021-11-19 19:05:52 +00:00
|
|
|
tap.test('first test', async () => {
|
2021-11-20 21:38:37 +00:00
|
|
|
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',
|
|
|
|
''
|
|
|
|
);
|
2021-11-20 19:32:16 +00:00
|
|
|
|
2021-11-22 09:24:09 +00:00
|
|
|
await testSmartswaggerInstance.mergeComponentToRoutes({excludeGlobArray: [], includeGlobArray: []}, {
|
|
|
|
"securitySchemes": {
|
|
|
|
"token": {
|
|
|
|
"type": "http",
|
|
|
|
"scheme": "bearer",
|
|
|
|
"bearerFormat": "JWT"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-11-20 19:32:16 +00:00
|
|
|
// express stuff
|
|
|
|
testExpressServer = new smartexpress.Server({
|
|
|
|
cors: true,
|
|
|
|
});
|
2021-11-20 21:38:37 +00:00
|
|
|
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())
|
|
|
|
);
|
2021-11-20 19:32:16 +00:00
|
|
|
await testExpressServer.start(3000);
|
2021-11-19 19:05:52 +00:00
|
|
|
});
|
|
|
|
|
2021-11-20 19:32:16 +00:00
|
|
|
tap.test('should run for a few seconds', async (toolsArg) => {
|
|
|
|
await toolsArg.delayFor(5000);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('should end smartswagger', async () => {
|
|
|
|
await testExpressServer.stop();
|
2021-11-20 21:38:37 +00:00
|
|
|
});
|
2021-11-20 19:32:16 +00:00
|
|
|
|
2021-11-19 19:05:52 +00:00
|
|
|
tap.start();
|