-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cmd-api-server): missing pretsc npm script #500
Adds the `pretsc` script that generates the Typescript client files based on the openapi.json specs. Also updated the openapi.json so that the healthcheck endpoint has a shortened operation ID (which is a separate, larger effort that is still pending across the entire code-base so figured it's good to start addressing it piece by piece at least while we are at it). Also added the axios dependency to the cmd-api-server package since this is necessary for the exported Typescript API client object to work properly (it is being used for sending the HTTP requests) Fixes #500 Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com> (cherry picked from commit 2b7f1cc0adbab31382443d44072ef4e01f73cb88) Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
- Loading branch information
Showing
12 changed files
with
409 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...i-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator-ignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md | ||
|
||
git_push.sh | ||
.npmignore | ||
.gitignore |
4 changes: 4 additions & 0 deletions
4
...pi-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
api.ts | ||
base.ts | ||
configuration.ts | ||
index.ts |
1 change: 1 addition & 0 deletions
1
...-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5.0.0-beta2 |
189 changes: 189 additions & 0 deletions
189
packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* Hyperledger Cactus API | ||
* Interact with a Cactus deployment through HTTP. | ||
* | ||
* The version of the OpenAPI document: 0.0.1 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
|
||
import { Configuration } from './configuration'; | ||
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; | ||
// Some imports not used depending on template conditions | ||
// @ts-ignore | ||
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; | ||
|
||
/** | ||
* | ||
* @export | ||
* @interface HealthCheckResponse | ||
*/ | ||
export interface HealthCheckResponse { | ||
/** | ||
* | ||
* @type {boolean} | ||
* @memberof HealthCheckResponse | ||
*/ | ||
success?: boolean; | ||
/** | ||
* | ||
* @type {string} | ||
* @memberof HealthCheckResponse | ||
*/ | ||
createdAt: string; | ||
/** | ||
* | ||
* @type {MemoryUsage} | ||
* @memberof HealthCheckResponse | ||
*/ | ||
memoryUsage: MemoryUsage; | ||
} | ||
/** | ||
* | ||
* @export | ||
* @interface MemoryUsage | ||
*/ | ||
export interface MemoryUsage { | ||
/** | ||
* | ||
* @type {number} | ||
* @memberof MemoryUsage | ||
*/ | ||
rss?: number; | ||
/** | ||
* | ||
* @type {number} | ||
* @memberof MemoryUsage | ||
*/ | ||
heapTotal?: number; | ||
/** | ||
* | ||
* @type {number} | ||
* @memberof MemoryUsage | ||
*/ | ||
heapUsed?: number; | ||
/** | ||
* | ||
* @type {number} | ||
* @memberof MemoryUsage | ||
*/ | ||
external?: number; | ||
/** | ||
* | ||
* @type {number} | ||
* @memberof MemoryUsage | ||
*/ | ||
arrayBuffers?: number; | ||
} | ||
|
||
/** | ||
* DefaultApi - axios parameter creator | ||
* @export | ||
*/ | ||
export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { | ||
return { | ||
/** | ||
* Returns the current timestamp of the API server as proof of health/liveness | ||
* @summary Can be used to verify liveness of an API server instance | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
getHealthCheck: async (options: any = {}): Promise<RequestArgs> => { | ||
const localVarPath = `/api/v1/api-server/healthcheck`; | ||
// use dummy base URL string because the URL constructor only accepts absolute URLs. | ||
const localVarUrlObj = new URL(localVarPath, 'https://example.com'); | ||
let baseOptions; | ||
if (configuration) { | ||
baseOptions = configuration.baseOptions; | ||
} | ||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; | ||
const localVarHeaderParameter = {} as any; | ||
const localVarQueryParameter = {} as any; | ||
|
||
|
||
|
||
const query = new URLSearchParams(localVarUrlObj.search); | ||
for (const key in localVarQueryParameter) { | ||
query.set(key, localVarQueryParameter[key]); | ||
} | ||
for (const key in options.query) { | ||
query.set(key, options.query[key]); | ||
} | ||
localVarUrlObj.search = (new URLSearchParams(query)).toString(); | ||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; | ||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; | ||
|
||
return { | ||
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, | ||
options: localVarRequestOptions, | ||
}; | ||
}, | ||
} | ||
}; | ||
|
||
/** | ||
* DefaultApi - functional programming interface | ||
* @export | ||
*/ | ||
export const DefaultApiFp = function(configuration?: Configuration) { | ||
return { | ||
/** | ||
* Returns the current timestamp of the API server as proof of health/liveness | ||
* @summary Can be used to verify liveness of an API server instance | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
async getHealthCheck(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<HealthCheckResponse>> { | ||
const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).getHealthCheck(options); | ||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { | ||
const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; | ||
return axios.request(axiosRequestArgs); | ||
}; | ||
}, | ||
} | ||
}; | ||
|
||
/** | ||
* DefaultApi - factory interface | ||
* @export | ||
*/ | ||
export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { | ||
return { | ||
/** | ||
* Returns the current timestamp of the API server as proof of health/liveness | ||
* @summary Can be used to verify liveness of an API server instance | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
*/ | ||
getHealthCheck(options?: any): AxiosPromise<HealthCheckResponse> { | ||
return DefaultApiFp(configuration).getHealthCheck(options).then((request) => request(axios, basePath)); | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* DefaultApi - object-oriented interface | ||
* @export | ||
* @class DefaultApi | ||
* @extends {BaseAPI} | ||
*/ | ||
export class DefaultApi extends BaseAPI { | ||
/** | ||
* Returns the current timestamp of the API server as proof of health/liveness | ||
* @summary Can be used to verify liveness of an API server instance | ||
* @param {*} [options] Override http request option. | ||
* @throws {RequiredError} | ||
* @memberof DefaultApi | ||
*/ | ||
public getHealthCheck(options?: any) { | ||
return DefaultApiFp(this.configuration).getHealthCheck(options).then((request) => request(this.axios, this.basePath)); | ||
} | ||
} | ||
|
||
|
71 changes: 71 additions & 0 deletions
71
...ages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* Hyperledger Cactus API | ||
* Interact with a Cactus deployment through HTTP. | ||
* | ||
* The version of the OpenAPI document: 0.0.1 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
|
||
import { Configuration } from "./configuration"; | ||
// Some imports not used depending on template conditions | ||
// @ts-ignore | ||
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; | ||
|
||
export const BASE_PATH = "https://www.cactus.stream".replace(/\/+$/, ""); | ||
|
||
/** | ||
* | ||
* @export | ||
*/ | ||
export const COLLECTION_FORMATS = { | ||
csv: ",", | ||
ssv: " ", | ||
tsv: "\t", | ||
pipes: "|", | ||
}; | ||
|
||
/** | ||
* | ||
* @export | ||
* @interface RequestArgs | ||
*/ | ||
export interface RequestArgs { | ||
url: string; | ||
options: any; | ||
} | ||
|
||
/** | ||
* | ||
* @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 || this.basePath; | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* | ||
* @export | ||
* @class RequiredError | ||
* @extends {Error} | ||
*/ | ||
export class RequiredError extends Error { | ||
name: "RequiredError" = "RequiredError"; | ||
constructor(public field: string, msg?: string) { | ||
super(msg); | ||
} | ||
} |
Oops, something went wrong.