Skip to content

Commit

Permalink
Remove openapitools.json and regenerate by openapi-generator-cli 7.2.…
Browse files Browse the repository at this point in the history
…0 according to the review comment
  • Loading branch information
ShouheiNishi committed Jan 24, 2024
1 parent f742fe2 commit bfb1270
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
7 changes: 0 additions & 7 deletions frontend/openapitools.json

This file was deleted.

15 changes: 9 additions & 6 deletions frontend/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@


import type { Configuration } from './configuration';
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
import type { RequestArgs } from './base';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError } from './base';
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base';

/**
*
Expand Down Expand Up @@ -1047,7 +1047,7 @@ export const WebconsoleApiAxiosParamCreator = function (configuration?: Configur
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSubscriberGet: async (limit?: number, page?: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
apiSubscriberGet: async (limit?: number, page?: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/subscriber`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand Down Expand Up @@ -1097,9 +1097,11 @@ export const WebconsoleApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSubscriberGet(limit?: number, page?: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Subscriber>>> {
async apiSubscriberGet(limit?: number, page?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Subscriber>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.apiSubscriberGet(limit, page, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
const index = configuration?.serverIndex ?? 0;
const operationBasePath = operationServerMap['WebconsoleApi.apiSubscriberGet']?.[index]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
},
}
};
Expand Down Expand Up @@ -1141,9 +1143,10 @@ export class WebconsoleApi extends BaseAPI {
* @throws {RequiredError}
* @memberof WebconsoleApi
*/
public apiSubscriberGet(limit?: number, page?: number, options?: AxiosRequestConfig) {
public apiSubscriberGet(limit?: number, page?: number, options?: RawAxiosRequestConfig) {
return WebconsoleApiFp(this.configuration).apiSubscriberGet(limit, page, options).then((request) => request(this.axios, this.basePath));
}
}



20 changes: 17 additions & 3 deletions frontend/src/api/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';

export const BASE_PATH = "http://localhost:5000".replace(/\/+$/, "");
Expand All @@ -39,7 +39,7 @@ export const COLLECTION_FORMATS = {
*/
export interface RequestArgs {
url: string;
options: AxiosRequestConfig;
options: RawAxiosRequestConfig;
}

/**
Expand All @@ -53,7 +53,7 @@ export class BaseAPI {
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath || this.basePath;
this.basePath = configuration.basePath ?? basePath;
}
}
};
Expand All @@ -70,3 +70,17 @@ export class RequiredError extends Error {
this.name = "RequiredError"
}
}

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

/**
*
* @export
*/
export const operationServerMap: ServerMap = {
}
2 changes: 1 addition & 1 deletion frontend/src/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const toPathString = function (url: URL) {
*/
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
return axios.request<T, R>(axiosRequestArgs);
};
}
9 changes: 9 additions & 0 deletions frontend/src/api/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface ConfigurationParameters {
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
serverIndex?: number;
baseOptions?: any;
formDataCtor?: new () => any;
}
Expand Down Expand Up @@ -58,6 +59,13 @@ export class Configuration {
* @memberof Configuration
*/
basePath?: string;
/**
* override server index
*
* @type {number}
* @memberof Configuration
*/
serverIndex?: number;
/**
* base options for axios calls
*
Expand All @@ -80,6 +88,7 @@ export class Configuration {
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
Expand Down

0 comments on commit bfb1270

Please sign in to comment.