smartswagger/scripts/startdemoserver.ts

23 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-11-19 19:05:52 +00:00
import * as smartexpress from '@pushrocks/smartexpress';
import * as smartswagger from '../ts';
const run = async () => {
const smartswaggerInstance = await smartswagger.Smartswagger.createFromUrl('https://my.sevdesk.de/OpenAPI/ReceiptAPI/openApi.json');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/ContactAPI/openApi.json', '');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InvoiceAPI/openApi.json', '');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/OrderAPI/openApi.json', '');
await smartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InventoryAPI/openApi.json', '');
// express stuff
const expressServer = new smartexpress.Server({
cors: true,
});
expressServer.addRoute('/apiui', new smartexpress.Handler('ALL', smartswaggerInstance.getSlashApiUiMiddleware()));
expressServer.addRoute('/apiredoc', new smartexpress.Handler('ALL', smartswaggerInstance.getSlashRedocMiddleware()))
expressServer.addRoute('/apischema', new smartexpress.Handler('ALL', smartswaggerInstance.getSlashApiSchemaMiddleware()));
await expressServer.start(3000);
}
run();