chore(Makefile): remove yq dependency to generate ts client

pull/10616/head
Nathaniel Cook 2018-12-18 09:50:34 -07:00
parent d9e9b1fd85
commit e3eff83aaa
4 changed files with 160 additions and 12 deletions

View File

@ -154,7 +154,7 @@ run: chronogiraffe
./bin/$(GOOS)/influxd --developer-mode=true
generate-typescript-client:
cat http/cur_swagger.yml | yq read -j - > openapi.json
cat http/cur_swagger.yml | go run ./internal/yaml2json > openapi.json
openapi-generator generate -g typescript-axios -o ui/src/api -i openapi.json
rm openapi.json

2
go.mod
View File

@ -42,7 +42,7 @@ require (
github.com/fatih/color v1.7.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/getkin/kin-openapi v0.1.0
github.com/ghodss/yaml v1.0.0 // indirect
github.com/ghodss/yaml v1.0.0
github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd // indirect
github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493 // indirect
github.com/go-ldap/ldap v2.5.1+incompatible // indirect

View File

@ -0,0 +1,26 @@
package main
import (
"io/ioutil"
"log"
"os"
yaml "github.com/ghodss/yaml"
)
// yaml2json reads yaml data from stdin and outputs json to stdout.
// There are no arguments or flags.
func main() {
in, err := ioutil.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}
out, err := yaml.YAMLToJSON(in)
if err != nil {
log.Fatal(err)
}
_, err = os.Stdout.Write(out)
if err != nil {
log.Fatal(err)
}
}

View File

@ -69,6 +69,52 @@ export class RequiredError extends Error {
}
}
/**
*
* @export
* @interface AnalyzeQueryResponse
*/
export interface AnalyzeQueryResponse {
/**
*
* @type {Array<AnalyzeQueryResponseErrors>}
* @memberof AnalyzeQueryResponse
*/
errors?: Array<AnalyzeQueryResponseErrors>;
}
/**
*
* @export
* @interface AnalyzeQueryResponseErrors
*/
export interface AnalyzeQueryResponseErrors {
/**
*
* @type {number}
* @memberof AnalyzeQueryResponseErrors
*/
character?: number;
/**
*
* @type {number}
* @memberof AnalyzeQueryResponseErrors
*/
column?: number;
/**
*
* @type {number}
* @memberof AnalyzeQueryResponseErrors
*/
line?: number;
/**
*
* @type {string}
* @memberof AnalyzeQueryResponseErrors
*/
message?: string;
}
/**
*
* @export
@ -450,14 +496,6 @@ export interface CellUpdate {
name?: string;
}
/**
*
* @export
* @interface Cells
*/
export interface Cells extends Array<Cell> {
}
/**
*
* @export
@ -550,10 +588,10 @@ export interface CreateCell {
export interface Dashboard {
/**
*
* @type {Cells}
* @type {Array<Cell>}
* @memberof Dashboard
*/
cells?: Cells;
cells?: Array<Cell>;
/**
* user-facing description of the dashboard
* @type {string}
@ -9273,6 +9311,48 @@ export class OrganizationsApi extends BaseAPI {
*/
export const QueryApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @summary analyze an influxql or flux query
* @param {'application/json'} [contentType]
* @param {string} [authorization] the authorization header should be in the format of &#x60;Token &lt;key&gt;&#x60;
* @param {Query} [query] flux or influxql query to analyze
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
queryAnalyzePost(contentType?: 'application/json', authorization?: string, query?: Query, options: any = {}): RequestArgs {
const localVarPath = `/query/analyze`;
const localVarUrlObj = url.parse(localVarPath, true);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign({ method: 'POST' }, baseOptions, options);
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (contentType !== undefined && contentType !== null) {
localVarHeaderParameter['Content-Type'] = String(contentType);
}
if (authorization !== undefined && authorization !== null) {
localVarHeaderParameter['Authorization'] = String(authorization);
}
localVarHeaderParameter['Content-Type'] = 'application/json';
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
const needsSerialization = (<any>"Query" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
localVarRequestOptions.data = needsSerialization ? JSON.stringify(query || {}) : (query || "");
return {
url: url.format(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* analyzes flux query and generates a query specification.
* @param {'application/json'} [contentType]
@ -9565,6 +9645,22 @@ export const QueryApiAxiosParamCreator = function (configuration?: Configuration
*/
export const QueryApiFp = function(configuration?: Configuration) {
return {
/**
*
* @summary analyze an influxql or flux query
* @param {'application/json'} [contentType]
* @param {string} [authorization] the authorization header should be in the format of &#x60;Token &lt;key&gt;&#x60;
* @param {Query} [query] flux or influxql query to analyze
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
queryAnalyzePost(contentType?: 'application/json', authorization?: string, query?: Query, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<AnalyzeQueryResponse> {
const localVarAxiosArgs = QueryApiAxiosParamCreator(configuration).queryAnalyzePost(contentType, authorization, query, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = Object.assign(localVarAxiosArgs.options, {url: basePath + localVarAxiosArgs.url})
return axios.request(axiosRequestArgs);
};
},
/**
* analyzes flux query and generates a query specification.
* @param {'application/json'} [contentType]
@ -9678,6 +9774,18 @@ export const QueryApiFp = function(configuration?: Configuration) {
*/
export const QueryApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
return {
/**
*
* @summary analyze an influxql or flux query
* @param {'application/json'} [contentType]
* @param {string} [authorization] the authorization header should be in the format of &#x60;Token &lt;key&gt;&#x60;
* @param {Query} [query] flux or influxql query to analyze
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
queryAnalyzePost(contentType?: 'application/json', authorization?: string, query?: Query, options?: any) {
return QueryApiFp(configuration).queryAnalyzePost(contentType, authorization, query, options)(axios, basePath);
},
/**
* analyzes flux query and generates a query specification.
* @param {'application/json'} [contentType]
@ -9764,6 +9872,20 @@ export const QueryApiFactory = function (configuration?: Configuration, basePath
* @extends {BaseAPI}
*/
export class QueryApi extends BaseAPI {
/**
*
* @summary analyze an influxql or flux query
* @param {'application/json'} [contentType]
* @param {string} [authorization] the authorization header should be in the format of &#x60;Token &lt;key&gt;&#x60;
* @param {Query} [query] flux or influxql query to analyze
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof QueryApi
*/
public queryAnalyzePost(contentType?: 'application/json', authorization?: string, query?: Query, options?: any) {
return QueryApiFp(this.configuration).queryAnalyzePost(contentType, authorization, query, options)(this.axios, this.basePath);
}
/**
* analyzes flux query and generates a query specification.
* @param {'application/json'} [contentType]