Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWI-6181 Update User Agent Header #49

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ jobs:
node-version: 22
registry-url: "https://registry.npmjs.org"

- name: Generate SDK with Updated Version
uses: Bandwidth/[email protected]
with:
openapi-generator-version: 7.9.0
language: typescript-axios
additional-properties: --additional-properties=npmVersion=$PACKAGE_VERSION

- name: Install Packages and Test
run: |
yarn
Expand Down
2 changes: 2 additions & 0 deletions base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import globalAxios from 'axios';

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

globalAxios.defaults.headers.common['User-Agent'] = "OpenAPI-Generator/1.0.0-dev/typescript-axios";

/**
*
* @export
Expand Down
118 changes: 118 additions & 0 deletions custom_templates/baseApi.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/* tslint:disable */
/* eslint-disable */
{{>licenseInfo}}

import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';

export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");

globalAxios.defaults.headers.common['User-Agent'] = "OpenAPI-Generator{{#npmVersion}}/{{npmVersion}}{{/npmVersion}}/typescript-axios";

/**
*
* @export
*/
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};

/**
*
* @export
* @interface RequestArgs
*/
export interface RequestArgs {
url: string;
options: RawAxiosRequestConfig;
}

/**
*
* @export
* @class BaseAPI
*/
export class BaseAPI {
protected configuration: Configuration | undefined;

constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath ?? basePath;
}
}
};

/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export class RequiredError extends Error {
constructor(public field: string, msg?: string) {
super(msg);
this.name = "RequiredError"
}
}

interface ServerMap {
[key: string]: {
url: string,
description: string,
}[];
}

/**
*
* @export
*/
export const operationServerMap: ServerMap = {
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
{{#servers}}
{{#-first}}
"{{{classname}}}.{{{nickname}}}": [
{{/-first}}
{
url: "{{{url}}}",
description: "{{{description}}}{{^description}}No description provided{{/description}}",
{{#variables}}
{{#-first}}
variables: {
{{/-first}}
{{{name}}}: {
description: "{{{description}}}{{^description}}No description provided{{/description}}",
default_value: "{{{defaultValue}}}",
{{#enumValues}}
{{#-first}}
enum_values: [
{{/-first}}
"{{{.}}}"{{^-last}},{{/-last}}
{{#-last}}
]
{{/-last}}
{{/enumValues}}
}{{^-last}},{{/-last}}
{{#-last}}
}
{{/-last}}
{{/variables}}
}{{^-last}},{{/-last}}
{{#-last}}
],
{{/-last}}
{{/servers}}
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
}
1 change: 1 addition & 0 deletions openapi-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
npmName: bandwidth-sdk
npmVersion: 1.0.0-dev
withSeparateModelsAndApi: true
modelPackage: models
apiPackage: api
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bandwidth-sdk",
"version": "1.0.0",
"version": "1.0.0-dev",
"description": "OpenAPI client for bandwidth-sdk",
"author": "OpenAPI-Generator Contributors",
"repository": {
Expand Down