Skip to content

Commit 27dee81

Browse files
committed
update templates
1 parent 72fa854 commit 27dee81

File tree

8 files changed

+389
-137
lines changed

8 files changed

+389
-137
lines changed

README.md

Lines changed: 245 additions & 6 deletions
Large diffs are not rendered by default.

common.ts

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,18 @@ import type { RequestArgs } from "./base";
1717
import type { AxiosInstance, AxiosResponse } from 'axios';
1818
import { RequiredError } from "./base";
1919

20-
/**
21-
*
22-
* @export
23-
*/
2420
export const DUMMY_BASE_URL = 'https://example.com'
2521

2622
/**
2723
*
2824
* @throws {RequiredError}
29-
* @export
3025
*/
3126
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
3227
if (paramValue === null || paramValue === undefined) {
3328
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
3429
}
3530
}
3631

37-
/**
38-
*
39-
* @export
40-
*/
4132
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
4233
if (configuration && configuration.apiKey) {
4334
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
@@ -47,20 +38,12 @@ export const setApiKeyToObject = async function (object: any, keyParamName: stri
4738
}
4839
}
4940

50-
/**
51-
*
52-
* @export
53-
*/
5441
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
5542
if (configuration && (configuration.username || configuration.password)) {
5643
object["auth"] = { username: configuration.username, password: configuration.password };
5744
}
5845
}
5946

60-
/**
61-
*
62-
* @export
63-
*/
6447
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
6548
if (configuration && configuration.accessToken) {
6649
const accessToken = typeof configuration.accessToken === 'function'
@@ -70,10 +53,6 @@ export const setBearerAuthToObject = async function (object: any, configuration?
7053
}
7154
}
7255

73-
/**
74-
*
75-
* @export
76-
*/
7756
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
7857
if (configuration && configuration.accessToken) {
7958
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
@@ -83,42 +62,35 @@ export const setOAuthToObject = async function (object: any, name: string, scope
8362
}
8463
}
8564

65+
8666
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
8767
if (parameter == null) return;
8868
if (typeof parameter === "object") {
8969
if (Array.isArray(parameter)) {
9070
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
91-
}
71+
}
9272
else {
93-
Object.keys(parameter).forEach(currentKey =>
73+
Object.keys(parameter).forEach(currentKey =>
9474
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
9575
);
9676
}
97-
}
77+
}
9878
else {
9979
if (urlSearchParams.has(key)) {
10080
urlSearchParams.append(key, parameter);
101-
}
81+
}
10282
else {
10383
urlSearchParams.set(key, parameter);
10484
}
10585
}
10686
}
10787

108-
/**
109-
*
110-
* @export
111-
*/
11288
export const setSearchParams = function (url: URL, ...objects: any[]) {
11389
const searchParams = new URLSearchParams(url.search);
11490
setFlattenedQueryParams(searchParams, objects);
11591
url.search = searchParams.toString();
11692
}
11793

118-
/**
119-
*
120-
* @export
121-
*/
12294
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
12395
const nonString = typeof value !== 'string';
12496
const needsSerialization = nonString && configuration && configuration.isJsonMime
@@ -129,18 +101,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
129101
: (value || "");
130102
}
131103

132-
/**
133-
*
134-
* @export
135-
*/
136104
export const toPathString = function (url: URL) {
137105
return url.pathname + url.search + url.hash
138106
}
139107

140-
/**
141-
*
142-
* @export
143-
*/
144108
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
145109
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
146110
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};

configuration.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* tslint:disable */
2-
/* eslint-disable */
32
/**
43
* Bandwidth
54
* Bandwidth\'s Communication APIs
@@ -12,11 +11,24 @@
1211
* Do not edit the class manually.
1312
*/
1413

14+
interface AWSv4Configuration {
15+
options?: {
16+
region?: string
17+
service?: string
18+
}
19+
credentials?: {
20+
accessKeyId?: string
21+
secretAccessKey?: string,
22+
sessionToken?: string
23+
}
24+
}
25+
1526
export interface ConfigurationParameters {
1627
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
1728
username?: string;
1829
password?: string;
1930
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
31+
awsv4?: AWSv4Configuration;
2032
basePath?: string;
2133
serverIndex?: number;
2234
baseOptions?: any;
@@ -27,49 +39,43 @@ export class Configuration {
2739
/**
2840
* parameter for apiKey security
2941
* @param name security name
30-
* @memberof Configuration
3142
*/
3243
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
3344
/**
3445
* parameter for basic security
35-
*
36-
* @type {string}
37-
* @memberof Configuration
3846
*/
3947
username?: string;
4048
/**
4149
* parameter for basic security
42-
*
43-
* @type {string}
44-
* @memberof Configuration
4550
*/
4651
password?: string;
4752
/**
4853
* parameter for oauth2 security
4954
* @param name security name
5055
* @param scopes oauth2 scope
51-
* @memberof Configuration
5256
*/
5357
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
5458
/**
55-
* override base path
56-
*
57-
* @type {string}
59+
* parameter for aws4 signature security
60+
* @param {Object} AWS4Signature - AWS4 Signature security
61+
* @param {string} options.region - aws region
62+
* @param {string} options.service - name of the service.
63+
* @param {string} credentials.accessKeyId - aws access key id
64+
* @param {string} credentials.secretAccessKey - aws access key
65+
* @param {string} credentials.sessionToken - aws session token
5866
* @memberof Configuration
5967
*/
68+
awsv4?: AWSv4Configuration;
69+
/**
70+
* override base path
71+
*/
6072
basePath?: string;
6173
/**
6274
* override server index
63-
*
64-
* @type {number}
65-
* @memberof Configuration
6675
*/
6776
serverIndex?: number;
6877
/**
6978
* base options for axios calls
70-
*
71-
* @type {any}
72-
* @memberof Configuration
7379
*/
7480
baseOptions?: any;
7581
/**
@@ -86,14 +92,15 @@ export class Configuration {
8692
this.username = param.username;
8793
this.password = param.password;
8894
this.accessToken = param.accessToken;
95+
this.awsv4 = param.awsv4;
8996
this.basePath = param.basePath;
9097
this.serverIndex = param.serverIndex;
9198
this.baseOptions = {
9299
...param.baseOptions,
93100
headers: {
94101
...param.baseOptions?.headers,
95102
'User-Agent': "OpenAPI-Generator/1.0.0/typescript-axios"
96-
}
103+
},
97104
};
98105
this.formDataCtor = param.formDataCtor;
99106
}

custom_templates/README.mustache

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
| **OS** | **Node** |
66
|:------------:|:----------:|
7-
| Windows 2019 | 18, 20, 22 |
8-
| Windows 2022 | 18, 20, 22 |
9-
| Ubuntu 22.04 | 18, 20, 22 |
10-
| Ubuntu 24.04 | 18, 20, 22 |
7+
| Windows 2022 | 18, 20, 22, 24 |
8+
| Windows 2025 | 18, 20, 22, 24 |
9+
| Ubuntu 22.04 | 18, 20, 22, 24 |
10+
| Ubuntu 24.04 | 18, 20, 22, 24 |
1111

1212
#### Available on NPM
1313
```
@@ -46,7 +46,7 @@ Module system
4646
* CommonJS
4747
* ES6 module system
4848

49-
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
49+
It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html))
5050

5151
### Building
5252

@@ -58,7 +58,7 @@ npm run build
5858

5959
### Publishing
6060

61-
First build the package then run ```npm publish```
61+
First build the package then run `npm publish`
6262

6363
### Consuming
6464

@@ -99,3 +99,53 @@ await callsApi.createCall(BW_ACCOUNT_ID, body);
9999
```
100100

101101
More samples can be found in the [Bandwidth Samples](https://github.com/orgs/Bandwidth-Samples/repositories?q=lang%3Ajavascript&type=all) GitHub Organization.
102+
103+
### Documentation for API Endpoints
104+
105+
All URIs are relative to *{{{basePath}}}*
106+
107+
Class | Method | HTTP request | Description
108+
------------ | ------------- | ------------- | -------------
109+
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
110+
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
111+
112+
### Documentation For Models
113+
114+
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
115+
{{/model}}{{/models}}
116+
117+
<a id="documentation-for-authorization"></a>
118+
## Documentation For Authorization
119+
120+
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
121+
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
122+
{{#authMethods}}
123+
<a id="{{name}}"></a>
124+
### {{{name}}}
125+
126+
{{#isApiKey}}
127+
- **Type**: API key
128+
- **API key parameter name**: {{{keyParamName}}}
129+
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
130+
{{/isApiKey}}
131+
{{#isBasic}}
132+
{{#isBasicBasic}}
133+
- **Type**: HTTP basic authentication
134+
{{/isBasicBasic}}
135+
{{#isBasicBearer}}
136+
- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
137+
{{/isBasicBearer}}
138+
{{#isHttpSignature}}
139+
- **Type**: HTTP signature authentication
140+
{{/isHttpSignature}}
141+
{{/isBasic}}
142+
{{#isOAuth}}
143+
- **Type**: OAuth
144+
- **Flow**: {{{flow}}}
145+
- **Authorization URL**: {{{authorizationUrl}}}
146+
- **Scopes**: {{^scopes}}N/A{{/scopes}}
147+
{{#scopes}} - **{{{scope}}}**: {{{description}}}
148+
{{/scopes}}
149+
{{/isOAuth}}
150+
151+
{{/authMethods}}

0 commit comments

Comments
 (0)