Skip to content

Commit 9b67c42

Browse files
authored
SWI-6181 Update User Agent Header (#49)
* SWI-6181 Update User Agent Header * revert oopsie in tests * update deploy wf * uncomment * no wf dispatch * dont cat
1 parent 573544f commit 9b67c42

File tree

5 files changed

+129
-1
lines changed

5 files changed

+129
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ jobs:
4949
node-version: 22
5050
registry-url: "https://registry.npmjs.org"
5151

52+
- name: Generate SDK with Updated Version
53+
uses: Bandwidth/[email protected]
54+
with:
55+
openapi-generator-version: 7.9.0
56+
language: typescript-axios
57+
additional-properties: --additional-properties=npmVersion=$PACKAGE_VERSION
58+
5259
- name: Install Packages and Test
5360
run: |
5461
yarn

base.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import globalAxios from 'axios';
2121

2222
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
2323

24+
globalAxios.defaults.headers.common['User-Agent'] = "OpenAPI-Generator/1.0.0-dev/typescript-axios";
25+
2426
/**
2527
*
2628
* @export

custom_templates/baseApi.mustache

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
{{>licenseInfo}}
4+
5+
import type { Configuration } from './configuration';
6+
// Some imports not used depending on template conditions
7+
// @ts-ignore
8+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
9+
import globalAxios from 'axios';
10+
11+
export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");
12+
13+
globalAxios.defaults.headers.common['User-Agent'] = "OpenAPI-Generator{{#npmVersion}}/{{npmVersion}}{{/npmVersion}}/typescript-axios";
14+
15+
/**
16+
*
17+
* @export
18+
*/
19+
export const COLLECTION_FORMATS = {
20+
csv: ",",
21+
ssv: " ",
22+
tsv: "\t",
23+
pipes: "|",
24+
};
25+
26+
/**
27+
*
28+
* @export
29+
* @interface RequestArgs
30+
*/
31+
export interface RequestArgs {
32+
url: string;
33+
options: RawAxiosRequestConfig;
34+
}
35+
36+
/**
37+
*
38+
* @export
39+
* @class BaseAPI
40+
*/
41+
export class BaseAPI {
42+
protected configuration: Configuration | undefined;
43+
44+
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
45+
if (configuration) {
46+
this.configuration = configuration;
47+
this.basePath = configuration.basePath ?? basePath;
48+
}
49+
}
50+
};
51+
52+
/**
53+
*
54+
* @export
55+
* @class RequiredError
56+
* @extends {Error}
57+
*/
58+
export class RequiredError extends Error {
59+
constructor(public field: string, msg?: string) {
60+
super(msg);
61+
this.name = "RequiredError"
62+
}
63+
}
64+
65+
interface ServerMap {
66+
[key: string]: {
67+
url: string,
68+
description: string,
69+
}[];
70+
}
71+
72+
/**
73+
*
74+
* @export
75+
*/
76+
export const operationServerMap: ServerMap = {
77+
{{#apiInfo}}
78+
{{#apis}}
79+
{{#operations}}
80+
{{#operation}}
81+
{{#servers}}
82+
{{#-first}}
83+
"{{{classname}}}.{{{nickname}}}": [
84+
{{/-first}}
85+
{
86+
url: "{{{url}}}",
87+
description: "{{{description}}}{{^description}}No description provided{{/description}}",
88+
{{#variables}}
89+
{{#-first}}
90+
variables: {
91+
{{/-first}}
92+
{{{name}}}: {
93+
description: "{{{description}}}{{^description}}No description provided{{/description}}",
94+
default_value: "{{{defaultValue}}}",
95+
{{#enumValues}}
96+
{{#-first}}
97+
enum_values: [
98+
{{/-first}}
99+
"{{{.}}}"{{^-last}},{{/-last}}
100+
{{#-last}}
101+
]
102+
{{/-last}}
103+
{{/enumValues}}
104+
}{{^-last}},{{/-last}}
105+
{{#-last}}
106+
}
107+
{{/-last}}
108+
{{/variables}}
109+
}{{^-last}},{{/-last}}
110+
{{#-last}}
111+
],
112+
{{/-last}}
113+
{{/servers}}
114+
{{/operation}}
115+
{{/operations}}
116+
{{/apis}}
117+
{{/apiInfo}}
118+
}

openapi-config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
npmName: bandwidth-sdk
2+
npmVersion: 1.0.0-dev
23
withSeparateModelsAndApi: true
34
modelPackage: models
45
apiPackage: api

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bandwidth-sdk",
3-
"version": "1.0.0",
3+
"version": "1.0.0-dev",
44
"description": "OpenAPI client for bandwidth-sdk",
55
"author": "OpenAPI-Generator Contributors",
66
"repository": {

0 commit comments

Comments
 (0)