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

Maintenance: Update OpenAPI tools and parsing #165

Merged
merged 4 commits into from
Jun 16, 2022
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
2 changes: 1 addition & 1 deletion openapi/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.1
5.4.0
8 changes: 4 additions & 4 deletions openapi/apis/DefaultApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class DefaultApi extends runtime.BaseAPI {
/**
* Run optimizer with the specified parameters
*/
async optimizerapiOptimizerRunRaw(requestParameters: OptimizerapiOptimizerRunRequest): Promise<runtime.ApiResponse<Result>> {
async optimizerapiOptimizerRunRaw(requestParameters: OptimizerapiOptimizerRunRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Result>> {
if (requestParameters.experiment === null || requestParameters.experiment === undefined) {
throw new runtime.RequiredError('experiment','Required parameter requestParameters.experiment was null or undefined when calling optimizerapiOptimizerRun.');
}
Expand All @@ -55,16 +55,16 @@ export class DefaultApi extends runtime.BaseAPI {
headers: headerParameters,
query: queryParameters,
body: ExperimentToJSON(requestParameters.experiment),
});
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ResultFromJSON(jsonValue));
}

/**
* Run optimizer with the specified parameters
*/
async optimizerapiOptimizerRun(requestParameters: OptimizerapiOptimizerRunRequest): Promise<Result> {
const response = await this.optimizerapiOptimizerRunRaw(requestParameters);
async optimizerapiOptimizerRun(requestParameters: OptimizerapiOptimizerRunRequest, initOverrides?: RequestInit): Promise<Result> {
const response = await this.optimizerapiOptimizerRunRaw(requestParameters, initOverrides);
return await response.value();
}

Expand Down
2 changes: 2 additions & 0 deletions openapi/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/* tslint:disable */
/* eslint-disable */
export * from './DefaultApi';
2 changes: 2 additions & 0 deletions openapi/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* tslint:disable */
/* eslint-disable */
export * from './runtime';
export * from './apis';
export * from './models';
5 changes: 3 additions & 2 deletions openapi/models/Experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import {
ExperimentDataFromJSON,
ExperimentDataFromJSONTyped,
ExperimentDataToJSON,
} from './ExperimentData';
import {
ExperimentOptimizerConfig,
ExperimentOptimizerConfigFromJSON,
ExperimentOptimizerConfigFromJSONTyped,
ExperimentOptimizerConfigToJSON,
} from './';
} from './ExperimentOptimizerConfig';

/**
*
Expand Down Expand Up @@ -81,4 +83,3 @@ export function ExperimentToJSON(value?: Experiment | null): any {
};
}


12 changes: 6 additions & 6 deletions openapi/models/ExperimentData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

import { exists, mapValues } from '../runtime';

/**
*
* @export
Expand All @@ -21,11 +22,10 @@ import { exists, mapValues } from '../runtime';
export interface ExperimentData {
/**
*
* @type {Array}
* @type {Array<string | number>}
* @memberof ExperimentData
*/
// @ts-ignore
xi?: Array;
xi?: Array<string | number>;
/**
*
* @type {Array<number>}
Expand All @@ -44,7 +44,7 @@ export function ExperimentDataFromJSONTyped(json: any, ignoreDiscriminator: bool
}
return {

'xi': !exists(json, 'xi') ? undefined : json['xi'],
'xi': !exists(json, 'xi') ? undefined : ((json['xi'] as Array<any>)),
'yi': !exists(json, 'yi') ? undefined : json['yi'],
};
}
Expand All @@ -57,9 +57,9 @@ export function ExperimentDataToJSON(value?: ExperimentData | null): any {
return null;
}
return {
'xi': value.xi,

'xi': value.xi === undefined ? undefined : ((value.xi as Array<any>)),
'yi': value.yi,
};
}


3 changes: 1 addition & 2 deletions openapi/models/ExperimentOptimizerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
ExperimentOptimizerConfigSpaceFromJSON,
ExperimentOptimizerConfigSpaceFromJSONTyped,
ExperimentOptimizerConfigSpaceToJSON,
} from './';
} from './ExperimentOptimizerConfigSpace';

/**
*
Expand Down Expand Up @@ -101,4 +101,3 @@ export function ExperimentOptimizerConfigToJSON(value?: ExperimentOptimizerConfi
};
}


1 change: 0 additions & 1 deletion openapi/models/ExperimentOptimizerConfigSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ export function ExperimentOptimizerConfigSpaceToJSON(value?: ExperimentOptimizer
};
}


1 change: 0 additions & 1 deletion openapi/models/ModelError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ export function ModelErrorToJSON(value?: ModelError | null): any {
};
}


5 changes: 3 additions & 2 deletions openapi/models/Result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import {
ResultPlotsFromJSON,
ResultPlotsFromJSONTyped,
ResultPlotsToJSON,
} from './ResultPlots';
import {
ResultResult,
ResultResultFromJSON,
ResultResultFromJSONTyped,
ResultResultToJSON,
} from './';
} from './ResultResult';

/**
*
Expand Down Expand Up @@ -73,4 +75,3 @@ export function ResultToJSON(value?: Result | null): any {
};
}


1 change: 0 additions & 1 deletion openapi/models/ResultPlots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ export function ResultPlotsToJSON(value?: ResultPlots | null): any {
};
}


3 changes: 1 addition & 2 deletions openapi/models/ResultResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
ResultResultModelsFromJSON,
ResultResultModelsFromJSONTyped,
ResultResultModelsToJSON,
} from './';
} from './ResultResultModels';

/**
*
Expand Down Expand Up @@ -85,4 +85,3 @@ export function ResultResultToJSON(value?: ResultResult | null): any {
};
}


1 change: 0 additions & 1 deletion openapi/models/ResultResultModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ export function ResultResultModelsToJSON(value?: ResultResultModels | null): any
};
}


2 changes: 2 additions & 0 deletions openapi/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* tslint:disable */
/* eslint-disable */
export * from './Experiment';
export * from './ExperimentData';
export * from './ExperimentOptimizerConfig';
Expand Down
25 changes: 13 additions & 12 deletions openapi/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ export class BaseAPI {
return this.withMiddleware<T>(...middlewares);
}

protected async request(context: RequestOpts): Promise<Response> {
const { url, init } = this.createFetchParams(context);
protected async request(context: RequestOpts, initOverrides?: RequestInit): Promise<Response> {
const { url, init } = this.createFetchParams(context, initOverrides);
const response = await this.fetchApi(url, init);
if (response.status >= 200 && response.status < 300) {
return response;
}
throw response;
}

private createFetchParams(context: RequestOpts) {
private createFetchParams(context: RequestOpts, initOverrides?: RequestInit) {
let url = this.configuration.basePath + context.path;
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
// only add the querystring to the URL if there are query parameters.
Expand All @@ -70,7 +70,8 @@ export class BaseAPI {
method: context.method,
headers: headers,
body,
credentials: this.configuration.credentials
credentials: this.configuration.credentials,
...initOverrides
};
return { url, init };
}
Expand All @@ -85,13 +86,13 @@ export class BaseAPI {
}) || fetchParams;
}
}
let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init);
let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
fetch: this.fetchApi,
url,
init,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone(),
}) || response;
}
Expand Down Expand Up @@ -135,7 +136,7 @@ export interface ConfigurationParameters {
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
}
Expand All @@ -147,8 +148,8 @@ export class Configuration {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}

get fetchApi(): FetchAPI {
return this.configuration.fetchApi || window.fetch.bind(window);
get fetchApi(): FetchAPI | undefined {
return this.configuration.fetchApi;
}

get middleware(): Middleware[] {
Expand All @@ -175,10 +176,10 @@ export class Configuration {
return undefined;
}

get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === 'function' ? accessToken : () => accessToken;
return typeof accessToken === 'function' ? accessToken : async () => accessToken;
}
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "5.1.1"
"version": "5.4.0"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"formatAll": "prettier --write .",
"test": "jest",
"prepare": "husky install",
"openapi": "openapi-generator-cli generate --skip-validate-spec -i https://raw.githubusercontent.com/BoostV/process-optimizer-api/v2.1.0/optimizerapi/openapi/specification.yml -g typescript-fetch -o ./openapi"
"openapi": "openapi-generator-cli generate -i https://raw.githubusercontent.com/BoostV/process-optimizer-api/v2.1.0/optimizerapi/openapi/specification.yml -g typescript-fetch -o ./openapi --additional-properties=nullSafeAdditionalProps && prettier --write ./openapi"
},
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
Expand All @@ -35,7 +35,7 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "2.4.4",
"@openapitools/openapi-generator-cli": "2.5.1",
"@swc/jest": "^0.2.20",
"@testing-library/dom": "^8.5.0",
"@testing-library/jest-dom": "^5.11.9",
Expand Down
2 changes: 1 addition & 1 deletion utility/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const calculateData = (
numericValues.find(p => p.name === it.name)
? Number(it.value)
: it.value
),
) as Array<string | number>, // This type cast is valid here because only scores can be number[] and they are filtered out
yi: run
.filter(it => enabledScoreNames.includes(it.name))
.map(it => it.value)
Expand Down
Loading