fix(core): update
This commit is contained in:
parent
d152920692
commit
f29623c084
@ -126,7 +126,7 @@ pages:
|
|||||||
- npmci node install lts
|
- npmci node install lts
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --prod
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
|
@ -44,4 +44,4 @@
|
|||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
]
|
]
|
||||||
}
|
}
|
41
test/test.ts
41
test/test.ts
@ -7,20 +7,43 @@ let testSmartswaggerInstance: smartswagger.Smartswagger;
|
|||||||
let testExpressServer: smartexpress.Server;
|
let testExpressServer: smartexpress.Server;
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
testSmartswaggerInstance = await smartswagger.Smartswagger.createFromUrl('https://my.sevdesk.de/OpenAPI/ReceiptAPI/openApi.json');
|
testSmartswaggerInstance = await smartswagger.Smartswagger.createFromUrl(
|
||||||
await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/ContactAPI/openApi.json', '');
|
'https://my.sevdesk.de/OpenAPI/ReceiptAPI/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(
|
||||||
await testSmartswaggerInstance.mergeDocumentFromUrl('https://my.sevdesk.de/OpenAPI/InventoryAPI/openApi.json', '');
|
'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
|
// express stuff
|
||||||
testExpressServer = new smartexpress.Server({
|
testExpressServer = new smartexpress.Server({
|
||||||
cors: true,
|
cors: true,
|
||||||
});
|
});
|
||||||
testExpressServer.addRoute('/apiui', new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashApiUiMiddleware()));
|
testExpressServer.addRoute(
|
||||||
testExpressServer.addRoute('/apiredoc', new smartexpress.Handler('ALL', testSmartswaggerInstance.getSlashRedocMiddleware()))
|
'/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);
|
await testExpressServer.start(3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -30,6 +53,6 @@ tap.test('should run for a few seconds', async (toolsArg) => {
|
|||||||
|
|
||||||
tap.test('should end smartswagger', async () => {
|
tap.test('should end smartswagger', async () => {
|
||||||
await testExpressServer.stop();
|
await testExpressServer.stop();
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start();
|
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 {
|
export class Smartswagger {
|
||||||
// STATIC
|
// STATIC
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param urlArg a url arg that contains an original swagger.json in the response
|
* @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) {
|
public static async createFromUrl(urlArg: string) {
|
||||||
const jsonResponse = await plugins.nodeFetch(urlArg, {
|
const jsonResponse = await plugins.nodeFetch(urlArg, {
|
||||||
@ -40,9 +40,7 @@ export class Smartswagger {
|
|||||||
* dereferences the document at hand
|
* dereferences the document at hand
|
||||||
*/
|
*/
|
||||||
public async deref() {
|
public async deref() {
|
||||||
this.apiDoc = (await plugins.swaggerParser.dereference(
|
this.apiDoc = (await plugins.swaggerParser.dereference(this.apiDoc)) as IExtendedApiDoc;
|
||||||
this.apiDoc
|
|
||||||
)) as IExtendedApiDoc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async addServer(serverArg: plugins.openapiTypes.OpenAPIV3.ServerObject) {
|
public async addServer(serverArg: plugins.openapiTypes.OpenAPIV3.ServerObject) {
|
||||||
@ -56,10 +54,7 @@ export class Smartswagger {
|
|||||||
* @param documentToMergeArg
|
* @param documentToMergeArg
|
||||||
* @param basePathArg
|
* @param basePathArg
|
||||||
*/
|
*/
|
||||||
public async mergeDocument(
|
public async mergeDocument(documentToMergeArg: IExtendedApiDoc, basePathArg: string) {
|
||||||
documentToMergeArg: IExtendedApiDoc,
|
|
||||||
basePathArg: string
|
|
||||||
) {
|
|
||||||
console.log(`merging document with name ${documentToMergeArg.info?.title}`);
|
console.log(`merging document with name ${documentToMergeArg.info?.title}`);
|
||||||
await this.deref();
|
await this.deref();
|
||||||
// lets get a dereferenced version of the document we want to merge
|
// lets get a dereferenced version of the document we want to merge
|
||||||
@ -86,7 +81,7 @@ export class Smartswagger {
|
|||||||
* merges a document from url
|
* 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...`)
|
console.log(`getting document at ${documentUrlArg} for merging...`);
|
||||||
const documentResponse = await plugins.nodeFetch(documentUrlArg, {
|
const documentResponse = await plugins.nodeFetch(documentUrlArg, {
|
||||||
headers: {
|
headers: {
|
||||||
'accept-encoding': 'application/json',
|
'accept-encoding': 'application/json',
|
||||||
@ -102,11 +97,11 @@ export class Smartswagger {
|
|||||||
* merge multiple documents in parallel
|
* merge multiple documents in parallel
|
||||||
* @param urlArrayArg
|
* @param urlArrayArg
|
||||||
*/
|
*/
|
||||||
public async mergeManyDocumentsFromUrl(urlArrayArg: {url: string, basePath: string}[]) {
|
public async mergeManyDocumentsFromUrl(urlArrayArg: { url: string; basePath: string }[]) {
|
||||||
const promiseArray: Promise<void>[] = [];
|
const promiseArray: Promise<void>[] = [];
|
||||||
for (const urlArg of urlArrayArg) {
|
for (const urlArg of urlArrayArg) {
|
||||||
promiseArray.push(this.mergeDocumentFromUrl(urlArg.url, urlArg.basePath));
|
promiseArray.push(this.mergeDocumentFromUrl(urlArg.url, urlArg.basePath));
|
||||||
};
|
}
|
||||||
await Promise.all(promiseArray);
|
await Promise.all(promiseArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,17 @@
|
|||||||
// node native
|
// node native
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export {
|
export { path };
|
||||||
path
|
|
||||||
}
|
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartexpress from '@pushrocks/smartexpress';
|
import * as smartexpress from '@pushrocks/smartexpress';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
export {
|
export { smartexpress, smartpromise };
|
||||||
smartexpress,
|
|
||||||
smartpromise
|
|
||||||
}
|
|
||||||
|
|
||||||
// third party
|
// third party
|
||||||
import * as openapiTypes from 'openapi-types';
|
import * as openapiTypes from 'openapi-types';
|
||||||
import swaggerParser from '@apidevtools/swagger-parser';
|
import swaggerParser from '@apidevtools/swagger-parser';
|
||||||
import nodeFetch from 'node-fetch';
|
import nodeFetch from 'node-fetch';
|
||||||
|
|
||||||
export {
|
export { openapiTypes, swaggerParser, nodeFetch };
|
||||||
openapiTypes,
|
|
||||||
swaggerParser,
|
|
||||||
nodeFetch
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user