Skip to content

Commit

Permalink
feat(openapi): upgrade to 6.3.0 phase1
Browse files Browse the repository at this point in the history
    Primary Changes
    ---------------
    1. Updated openapitoos.json for various plugins to use 6.3.0
    version of openapi generator
    2. Relevant code for each plugin was generated

    openapitools.json is updated for the following plugins to
    incorporate 1)
    ------------------------------------------------------------
    a. extensions/cactus-plugin-htlc-coordinator-besu
    b. packages/cactus-plugin-htlc-eth-besu
    c. packages/cactus-plugin-htlc-eth-besu-erc20
    d. packages/cactus-plugin-ledger-connector-besu
    e. packages/cactus-plugin-ledger-connector-quorum
    f. packages/cactus-cmd-api-server
    g. packages/cactus-core-api
    h. packages/cactus-plugin-consortium-manual
    i. packages/cactus-plugin-keychain-aws-sm
    j. packages/cactus-plugin-keychain-azure-kv
    k. packages/cactus-plugin-keychain-google-sm
    l. packages/cactus-plugin-keychain-memory
    m. packages/cactus-plugin-keychain-memory-wasm
    n. packages/cactus-plugin-keychain-vault
    o. packages/cactus-plugin-ledger-connector-corda
    p. packages/cactus-plugin-ledger-connector-ubiquity
    q. packages/cactus-plugin-ledger-connector-xdai packages/cactus-plugin-odap-hermes
    r. examples/cactus-example-carbon-accounting-business-logic-plugin

Fixes hyperledger#2298

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
  • Loading branch information
jagpreetsinghsasan authored and petermetz committed Mar 28, 2023
1 parent 61c43af commit d1389f6
Show file tree
Hide file tree
Showing 190 changed files with 5,234 additions and 3,023 deletions.
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.2.1"
"version": "6.3.0"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.1
6.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,51 @@
*/


import { Configuration } from './configuration';
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
import type { Configuration } from './configuration';
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } 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, RequestArgs, BaseAPI, RequiredError } from './base';
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError } from './base';

/**
* Stores global constants related to the authorization of the application. Specifically enumerates the claims to validate for as per RFC 7519, section 4.1. See: https://tools.ietf.org/html/rfc7519#section-4.1
* @export
* @enum {string}
*/

export enum AuthzJwtClaim {
export const AuthzJwtClaim = {
/**
* The &quot;iss&quot; (issuer) claim identifies the principal that issued the JWT. The processing of this claim is generally application specific. The &quot;iss&quot; value is a case-sensitive string containing a StringOrURI value. Use of this claim is OPTIONAL.
*/
iss = 'Hyperledger Labs - Carbon Accounting Tool'
}
iss: 'Hyperledger Labs - Carbon Accounting Tool'
} as const;

export type AuthzJwtClaim = typeof AuthzJwtClaim[keyof typeof AuthzJwtClaim];


/**
*
* @export
* @enum {string}
*/

export enum AuthzScope {
export const AuthzScope = {
/**
* Identities with the group:admin scope are administrators of the system.
*/
GroupAdmin = 'group:admin',
GroupAdmin: 'group:admin',
/**
* Identities with the group:user scope are end users of the system who only have authorization to perform a limited set of actions.
*/
GroupUser = 'group:user'
}
GroupUser: 'group:user'
} as const;

export type AuthzScope = typeof AuthzScope[keyof typeof AuthzScope];


/**
*
Expand All @@ -62,13 +70,13 @@ export interface Checkpoint {
* @type {number}
* @memberof Checkpoint
*/
fromBlock: number;
'fromBlock': number;
/**
*
* @type {string}
* @memberof Checkpoint
*/
votes: string;
'votes': string;
}
/**
*
Expand All @@ -81,13 +89,13 @@ export interface DaoTokenGetAllowanceNotFoundResponse {
* @type {boolean}
* @memberof DaoTokenGetAllowanceNotFoundResponse
*/
accountFound: boolean;
'accountFound': boolean;
/**
* Indicates whether the spender was found or not.
* @type {boolean}
* @memberof DaoTokenGetAllowanceNotFoundResponse
*/
spenderFound: boolean;
'spenderFound': boolean;
}
/**
*
Expand All @@ -100,13 +108,13 @@ export interface DaoTokenGetAllowanceRequest {
* @type {string}
* @memberof DaoTokenGetAllowanceRequest
*/
account: string;
'account': string;
/**
* The address of the account spending the funds
* @type {string}
* @memberof DaoTokenGetAllowanceRequest
*/
spender: string;
'spender': string;
}
/**
*
Expand All @@ -119,18 +127,21 @@ export interface DaoTokenGetAllowanceResponse {
* @type {number}
* @memberof DaoTokenGetAllowanceResponse
*/
allowance: number;
'allowance': number;
}
/**
*
* @export
* @enum {string}
*/

export enum EnrollAdminInfo {
SUCCESSFULLY_ENROLLED_ADMIN = 'Successfully enrolled admin user and imported it into the wallet',
ORG_ADMIN_REGISTERED = 'ORG ADMIN REGISTERED'
}
export const EnrollAdminInfo = {
SUCCESSFULLY_ENROLLED_ADMIN: 'Successfully enrolled admin user and imported it into the wallet',
ORG_ADMIN_REGISTERED: 'ORG ADMIN REGISTERED'
} as const;

export type EnrollAdminInfo = typeof EnrollAdminInfo[keyof typeof EnrollAdminInfo];


/**
*
Expand All @@ -143,7 +154,7 @@ export interface EnrollAdminV1Request {
* @type {string}
* @memberof EnrollAdminV1Request
*/
orgName: string;
'orgName': string;
}
/**
*
Expand All @@ -156,31 +167,31 @@ export interface EnrollAdminV1Response {
* @type {string}
* @memberof EnrollAdminV1Response
*/
info: string;
'info': string;
/**
*
* @type {string}
* @memberof EnrollAdminV1Response
*/
orgName: string;
'orgName': string;
/**
*
* @type {string}
* @memberof EnrollAdminV1Response
*/
msp: string;
'msp': string;
/**
*
* @type {string}
* @memberof EnrollAdminV1Response
*/
caName: string;
'caName': string;
/**
* The key under which the identity created will be persisted to the keychain for later retrieval.
* @type {string}
* @memberof EnrollAdminV1Response
*/
identityId?: string;
'identityId'?: string;
}

/**
Expand All @@ -196,7 +207,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
daoTokenGetAllowanceV1: async (daoTokenGetAllowanceRequest?: DaoTokenGetAllowanceRequest, options: any = {}): Promise<RequestArgs> => {
daoTokenGetAllowanceV1: async (daoTokenGetAllowanceRequest?: DaoTokenGetAllowanceRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/v1/plugins/@hyperledger/cactus-example-carbon-accounting-backend/dao-token/get-allowance`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand All @@ -213,7 +224,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati

localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(daoTokenGetAllowanceRequest, localVarRequestOptions, configuration)
Expand All @@ -230,7 +241,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
enrollAdminV1: async (enrollAdminV1Request?: EnrollAdminV1Request, options: any = {}): Promise<RequestArgs> => {
enrollAdminV1: async (enrollAdminV1Request?: EnrollAdminV1Request, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/v1/utilityemissionchannel/registerEnroll/admin`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand All @@ -247,7 +258,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati

localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(enrollAdminV1Request, localVarRequestOptions, configuration)
Expand All @@ -274,7 +285,7 @@ export const DefaultApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async daoTokenGetAllowanceV1(daoTokenGetAllowanceRequest?: DaoTokenGetAllowanceRequest, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DaoTokenGetAllowanceResponse>> {
async daoTokenGetAllowanceV1(daoTokenGetAllowanceRequest?: DaoTokenGetAllowanceRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DaoTokenGetAllowanceResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.daoTokenGetAllowanceV1(daoTokenGetAllowanceRequest, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
Expand All @@ -285,7 +296,7 @@ export const DefaultApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async enrollAdminV1(enrollAdminV1Request?: EnrollAdminV1Request, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<EnrollAdminV1Response>> {
async enrollAdminV1(enrollAdminV1Request?: EnrollAdminV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<EnrollAdminV1Response>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.enrollAdminV1(enrollAdminV1Request, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
Expand Down Expand Up @@ -337,7 +348,7 @@ export class DefaultApi extends BaseAPI {
* @throws {RequiredError}
* @memberof DefaultApi
*/
public daoTokenGetAllowanceV1(daoTokenGetAllowanceRequest?: DaoTokenGetAllowanceRequest, options?: any) {
public daoTokenGetAllowanceV1(daoTokenGetAllowanceRequest?: DaoTokenGetAllowanceRequest, options?: AxiosRequestConfig) {
return DefaultApiFp(this.configuration).daoTokenGetAllowanceV1(daoTokenGetAllowanceRequest, options).then((request) => request(this.axios, this.basePath));
}

Expand All @@ -349,7 +360,7 @@ export class DefaultApi extends BaseAPI {
* @throws {RequiredError}
* @memberof DefaultApi
*/
public enrollAdminV1(enrollAdminV1Request?: EnrollAdminV1Request, options?: any) {
public enrollAdminV1(enrollAdminV1Request?: EnrollAdminV1Request, options?: AxiosRequestConfig) {
return DefaultApiFp(this.configuration).enrollAdminV1(enrollAdminV1Request, options).then((request) => request(this.axios, this.basePath));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
*/


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

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

Expand All @@ -38,7 +39,7 @@ export const COLLECTION_FORMATS = {
*/
export interface RequestArgs {
url: string;
options: any;
options: AxiosRequestConfig;
}

/**
Expand All @@ -64,8 +65,8 @@ export class BaseAPI {
* @extends {Error}
*/
export class RequiredError extends Error {
name: "RequiredError" = "RequiredError";
constructor(public field: string, msg?: string) {
super(msg);
this.name = "RequiredError"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
*/


import { Configuration } from "./configuration";
import { RequiredError, RequestArgs } from "./base";
import { AxiosInstance } from 'axios';
import type { Configuration } from "./configuration";
import type { RequestArgs } from "./base";
import type { AxiosInstance, AxiosResponse } from 'axios';
import { RequiredError } from "./base";

/**
*
Expand Down Expand Up @@ -83,24 +84,35 @@ export const setOAuthToObject = async function (object: any, name: string, scope
}
}

function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
if (parameter == null) return;
if (typeof parameter === "object") {
if (Array.isArray(parameter)) {
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
}
else {
Object.keys(parameter).forEach(currentKey =>
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
);
}
}
else {
if (urlSearchParams.has(key)) {
urlSearchParams.append(key, parameter);
}
else {
urlSearchParams.set(key, parameter);
}
}
}

/**
*
* @export
*/
export const setSearchParams = function (url: URL, ...objects: any[]) {
const searchParams = new URLSearchParams(url.search);
for (const object of objects) {
for (const key in object) {
if (Array.isArray(object[key])) {
searchParams.delete(key);
for (const item of object[key]) {
searchParams.append(key, item);
}
} else {
searchParams.set(key, object[key]);
}
}
}
setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString();
}

Expand Down Expand Up @@ -131,8 +143,8 @@ export const toPathString = function (url: URL) {
* @export
*/
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
return axios.request(axiosRequestArgs);
return axios.request<T, R>(axiosRequestArgs);
};
}
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.2.1"
"version": "6.3.0"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.1
6.3.0

0 comments on commit d1389f6

Please sign in to comment.