|
| 1 | +/* tslint:disable */ |
| 2 | +/* eslint-disable */ |
| 3 | +{{>licenseInfo}} |
| 4 | + |
| 5 | +import type { Configuration } from './configuration'; |
| 6 | +// Some imports not used depending on template conditions |
| 7 | +// @ts-ignore |
| 8 | +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; |
| 9 | +import globalAxios from 'axios'; |
| 10 | + |
| 11 | +export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); |
| 12 | + |
| 13 | +globalAxios.defaults.headers.common['User-Agent'] = "OpenAPI-Generator{{#npmVersion}}/{{npmVersion}}{{/npmVersion}}/typescript-axios"; |
| 14 | + |
| 15 | +/** |
| 16 | + * |
| 17 | + * @export |
| 18 | + */ |
| 19 | +export const COLLECTION_FORMATS = { |
| 20 | + csv: ",", |
| 21 | + ssv: " ", |
| 22 | + tsv: "\t", |
| 23 | + pipes: "|", |
| 24 | +}; |
| 25 | + |
| 26 | +/** |
| 27 | + * |
| 28 | + * @export |
| 29 | + * @interface RequestArgs |
| 30 | + */ |
| 31 | +export interface RequestArgs { |
| 32 | + url: string; |
| 33 | + options: RawAxiosRequestConfig; |
| 34 | +} |
| 35 | + |
| 36 | +/** |
| 37 | + * |
| 38 | + * @export |
| 39 | + * @class BaseAPI |
| 40 | + */ |
| 41 | +export class BaseAPI { |
| 42 | + protected configuration: Configuration | undefined; |
| 43 | +
|
| 44 | + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { |
| 45 | + if (configuration) { |
| 46 | + this.configuration = configuration; |
| 47 | + this.basePath = configuration.basePath ?? basePath; |
| 48 | + } |
| 49 | + } |
| 50 | +}; |
| 51 | + |
| 52 | +/** |
| 53 | + * |
| 54 | + * @export |
| 55 | + * @class RequiredError |
| 56 | + * @extends {Error} |
| 57 | + */ |
| 58 | +export class RequiredError extends Error { |
| 59 | + constructor(public field: string, msg?: string) { |
| 60 | + super(msg); |
| 61 | + this.name = "RequiredError" |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +interface ServerMap { |
| 66 | + [key: string]: { |
| 67 | + url: string, |
| 68 | + description: string, |
| 69 | + }[]; |
| 70 | +} |
| 71 | + |
| 72 | +/** |
| 73 | + * |
| 74 | + * @export |
| 75 | + */ |
| 76 | +export const operationServerMap: ServerMap = { |
| 77 | + {{#apiInfo}} |
| 78 | + {{#apis}} |
| 79 | + {{#operations}} |
| 80 | + {{#operation}} |
| 81 | + {{#servers}} |
| 82 | + {{#-first}} |
| 83 | + "{{{classname}}}.{{{nickname}}}": [ |
| 84 | + {{/-first}} |
| 85 | + { |
| 86 | + url: "{{{url}}}", |
| 87 | + description: "{{{description}}}{{^description}}No description provided{{/description}}", |
| 88 | + {{#variables}} |
| 89 | + {{#-first}} |
| 90 | + variables: { |
| 91 | + {{/-first}} |
| 92 | + {{{name}}}: { |
| 93 | + description: "{{{description}}}{{^description}}No description provided{{/description}}", |
| 94 | + default_value: "{{{defaultValue}}}", |
| 95 | + {{#enumValues}} |
| 96 | + {{#-first}} |
| 97 | + enum_values: [ |
| 98 | + {{/-first}} |
| 99 | + "{{{.}}}"{{^-last}},{{/-last}} |
| 100 | + {{#-last}} |
| 101 | + ] |
| 102 | + {{/-last}} |
| 103 | + {{/enumValues}} |
| 104 | + }{{^-last}},{{/-last}} |
| 105 | + {{#-last}} |
| 106 | + } |
| 107 | + {{/-last}} |
| 108 | + {{/variables}} |
| 109 | + }{{^-last}},{{/-last}} |
| 110 | + {{#-last}} |
| 111 | + ], |
| 112 | + {{/-last}} |
| 113 | + {{/servers}} |
| 114 | + {{/operation}} |
| 115 | + {{/operations}} |
| 116 | + {{/apis}} |
| 117 | + {{/apiInfo}} |
| 118 | +} |
0 commit comments