|
| 1 | +/* tslint:disable */ |
| 2 | +/* eslint-disable */ |
| 3 | +{{>licenseInfo}} |
| 4 | + |
| 5 | +export interface ConfigurationParameters { |
| 6 | + apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>); |
| 7 | + username?: string; |
| 8 | + password?: string; |
| 9 | + accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>); |
| 10 | + basePath?: string; |
| 11 | + serverIndex?: number; |
| 12 | + baseOptions?: any; |
| 13 | + formDataCtor?: new () => any; |
| 14 | +} |
| 15 | + |
| 16 | +export class Configuration { |
| 17 | + /** |
| 18 | + * parameter for apiKey security |
| 19 | + * @param name security name |
| 20 | + * @memberof Configuration |
| 21 | + */ |
| 22 | + apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>); |
| 23 | + /** |
| 24 | + * parameter for basic security |
| 25 | + * |
| 26 | + * @type {string} |
| 27 | + * @memberof Configuration |
| 28 | + */ |
| 29 | + username?: string; |
| 30 | + /** |
| 31 | + * parameter for basic security |
| 32 | + * |
| 33 | + * @type {string} |
| 34 | + * @memberof Configuration |
| 35 | + */ |
| 36 | + password?: string; |
| 37 | + /** |
| 38 | + * parameter for oauth2 security |
| 39 | + * @param name security name |
| 40 | + * @param scopes oauth2 scope |
| 41 | + * @memberof Configuration |
| 42 | + */ |
| 43 | + accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>); |
| 44 | + /** |
| 45 | + * override base path |
| 46 | + * |
| 47 | + * @type {string} |
| 48 | + * @memberof Configuration |
| 49 | + */ |
| 50 | + basePath?: string; |
| 51 | + /** |
| 52 | + * override server index |
| 53 | + * |
| 54 | + * @type {number} |
| 55 | + * @memberof Configuration |
| 56 | + */ |
| 57 | + serverIndex?: number; |
| 58 | + /** |
| 59 | + * base options for axios calls |
| 60 | + * |
| 61 | + * @type {any} |
| 62 | + * @memberof Configuration |
| 63 | + */ |
| 64 | + baseOptions?: any; |
| 65 | + /** |
| 66 | + * The FormData constructor that will be used to create multipart form data |
| 67 | + * requests. You can inject this here so that execution environments that |
| 68 | + * do not support the FormData class can still run the generated client. |
| 69 | + * |
| 70 | + * @type {new () => FormData} |
| 71 | + */ |
| 72 | + formDataCtor?: new () => any; |
| 73 | + |
| 74 | + constructor(param: ConfigurationParameters = {}) { |
| 75 | + this.apiKey = param.apiKey; |
| 76 | + this.username = param.username; |
| 77 | + this.password = param.password; |
| 78 | + this.accessToken = param.accessToken; |
| 79 | + this.basePath = param.basePath; |
| 80 | + this.serverIndex = param.serverIndex; |
| 81 | + this.baseOptions = { |
| 82 | + ...param.baseOptions, |
| 83 | + headers: { |
| 84 | + ...param.baseOptions?.headers, |
| 85 | + 'User-Agent': "OpenAPI-Generator{{#npmVersion}}/{{npmVersion}}{{/npmVersion}}/typescript-axios" |
| 86 | + } |
| 87 | + }; |
| 88 | + this.formDataCtor = param.formDataCtor; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Check if the given MIME is a JSON MIME. |
| 93 | + * JSON MIME examples: |
| 94 | + * application/json |
| 95 | + * application/json; charset=UTF8 |
| 96 | + * APPLICATION/JSON |
| 97 | + * application/vnd.company+json |
| 98 | + * @param mime - MIME (Multipurpose Internet Mail Extensions) |
| 99 | + * @return True if the given MIME is JSON, false otherwise. |
| 100 | + */ |
| 101 | + public isJsonMime(mime: string): boolean { |
| 102 | + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); |
| 103 | + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); |
| 104 | + } |
| 105 | +} |
0 commit comments