-
-
Notifications
You must be signed in to change notification settings - Fork 393
Expand file tree
/
Copy pathclient.js.js
More file actions
35 lines (32 loc) · 1.46 KB
/
Copy pathclient.js.js
File metadata and controls
35 lines (32 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { File } from '@asyncapi/generator-react-sdk';
import { getClientName, getServerUrl, getServer, getInfo, getTitle, getQueryParams } from '@asyncapi/generator-helpers';
import { FileHeaderInfo, DependencyProvider } from '@asyncapi/generator-components';
import { ClientClass } from '../components/ClientClass';
export default function ({ asyncapi, params }) {
const server = getServer(asyncapi.servers(), params.server);
const info = getInfo(asyncapi);
const title = getTitle(asyncapi);
const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
const serverUrl = getServerUrl(server);
const sendOperations = asyncapi.operations().filterBySend();
const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;
const queryParams = getQueryParams(asyncapi.channels());
const dependencies = ['const path = require(\'path\');', `const asyncapiFilepath = path.resolve(__dirname, '${asyncapiFilepath}');`];
if (queryParams) {
dependencies.push('const querystring = require(\'querystring\');');
}
return (
<File name={params.clientFileName}>
<FileHeaderInfo
info={info}
server={server}
language="javascript"
/>
<DependencyProvider
language="javascript"
additionalDependencies={dependencies}
/>
<ClientClass clientName={clientName} serverUrl={serverUrl} queryParams={queryParams} title={title} sendOperations={sendOperations} />
</File>
);
}