@appsemble/utils
Version:
Utility functions used in Appsemble internally
52 lines (50 loc) • 1.6 kB
JavaScript
import { components } from './components/index.js';
import { paths } from './paths/index.js';
import { tags } from './tags/index.js';
export * as schemas from './components/schemas/index.js';
/**
* Get the OpenAPI document for the Appsemble REST API.
*
* @param version The Appsemble version
* @param argv The parsed command line arguments.
* @returns The OpenAPI document for Appsemble.
*/
export function api(version, { port = 9999, ssl, host = `${ssl ? 'https' : 'http'}://localhost:${port}` } = {}) {
let hostToBeLogged = host;
if (port) {
const splitHost = hostToBeLogged.split(':');
if (Number.isNaN(Number(splitHost.at(-1))) === false) {
splitHost[splitHost.length - 1] = String(port);
hostToBeLogged = splitHost.join(':');
}
else {
splitHost.push(String(port));
hostToBeLogged = splitHost.join(':');
}
}
return {
openapi: '3.0.2',
components,
externalDocs: {
description: 'Appsemble developer documentation',
url: `${hostToBeLogged}/docs`,
},
info: {
title: 'Appsemble',
description: `Welcome to the Appsemble API.
The app studio can be found on
> ${hostToBeLogged}
The OpenAPI explorer can be found on
> ${hostToBeLogged}/api-explorer
`,
license: {
name: 'LGPL',
url: 'https://gitlab.com/appsemble/appsemble/blob/main/LICENSE.md',
},
version,
},
paths,
tags,
};
}
//# sourceMappingURL=index.js.map