better code format, update samples (#9438)

This commit is contained in:
William Cheng 2021-05-10 18:26:23 +08:00 committed by GitHub
parent 1751aa7272
commit 4bb5c8ae0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 40 deletions

View File

@ -36,7 +36,6 @@ export type FetchArgs = {
options: {}; options: {};
} }
/** /**
* *
* @export * @export
@ -79,12 +78,12 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
{{/summary}} {{/summary}}
* @throws {RequiredError} * @throws {RequiredError}
*/ */
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: RequestOptions): FetchArgs { {{operationId}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options: RequestOptions): FetchArgs {
{{#allParams}} {{#allParams}}
{{#required}} {{#required}}
// verify required parameter '{{paramName}}' is not null or undefined // verify required parameter '{{paramName}}' is not null or undefined
if ({{paramName}} === null || {{paramName}} === undefined) { if ({{paramName}} === null || {{paramName}} === undefined) {
throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); throw new RequiredError('{{paramName}}','Required parameter {{paramName}} was null or undefined when calling {{operationId}}.');
} }
{{/required}} {{/required}}
{{/allParams}} {{/allParams}}
@ -227,7 +226,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
}; };
export type {{classname}}Type = { {{#operation}} export type {{classname}}Type = { {{#operation}}
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>, {{operationId}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}>,
{{/operation}} {{/operation}}
} }
@ -247,8 +246,8 @@ export const {{classname}} = function(configuration?: Configuration, fetch: Fetc
{{/summary}} {{/summary}}
* @throws {RequiredError} * @throws {RequiredError}
*/ */
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions = {}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> { {{operationId}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: RequestOptions = {}): Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response{{/returnType}}> {
const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options); const localVarFetchArgs = {{classname}}FetchParamCreator(configuration).{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}options);
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => { return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
return response{{#returnType}}.json(){{/returnType}}; return response{{#returnType}}.json(){{/returnType}};
@ -260,6 +259,7 @@ export const {{classname}} = function(configuration?: Configuration, fetch: Fetc
{{/operation}} {{/operation}}
} }
}; };
{{/operations}}{{/apis}}{{/apiInfo}} {{/operations}}{{/apis}}{{/apiInfo}}
export type ApiTypes = { {{#apiInfo}}{{#apis}}{{#operations}} export type ApiTypes = { {{#apiInfo}}{{#apis}}{{#operations}}
{{classname}}: {{classname}}Type, {{classname}}: {{classname}}Type,

View File

@ -1 +1 @@
5.0.0-SNAPSHOT 5.2.0-SNAPSHOT

View File

@ -46,7 +46,6 @@ export type FetchArgs = {
options: {}; options: {};
} }
/** /**
* *
* @export * @export
@ -765,6 +764,7 @@ export const PetApi = function(configuration?: Configuration, fetch: FetchAPI =
} }
}; };
/** /**
* StoreApi - fetch parameter creator * StoreApi - fetch parameter creator
* @export * @export
@ -968,6 +968,7 @@ export const StoreApi = function(configuration?: Configuration, fetch: FetchAPI
} }
}; };
/** /**
* UserApi - fetch parameter creator * UserApi - fetch parameter creator
* @export * @export
@ -1364,6 +1365,7 @@ export const UserApi = function(configuration?: Configuration, fetch: FetchAPI =
} }
}; };
export type ApiTypes = { export type ApiTypes = {
PetApi: PetApiType, PetApi: PetApiType,