Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/generators/typescript-axios.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ------ | ----------- | ------ | ------- |
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|apiPackage|package for generated api classes| |null|
|axiosVersion|Use this property to override the axios version in package.json| |^1.6.1|
|axiosVersion|Use this property to override the axios version in package.json| |^1.12.2|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|enumNameSuffix|Suffix that will be appended to all enum names.| |Enum|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
public static final String IMPORT_FILE_EXTENSION_SWITCH_DESC = "File extension to use with relative imports. Set it to '.js' or '.mjs' when using [ESM](https://nodejs.org/api/esm.html).";
public static final String USE_SQUARE_BRACKETS_IN_ARRAY_NAMES = "useSquareBracketsInArrayNames";
public static final String AXIOS_VERSION = "axiosVersion";
public static final String DEFAULT_AXIOS_VERSION = "^1.6.1";
public static final String DEFAULT_AXIOS_VERSION = "^1.12.2";
public static final String WITH_AWSV4_SIGNATURE = "withAWSV4Signature";

@Getter @Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export interface {{classname}}{{operationIdCamelCase}}Request {
* {{description}}
*/
{{/description}}
readonly {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}
readonly {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^required}} | undefined{{/required}}
{{^-last}}

{{/-last}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* tslint:disable */
/* eslint-disable */
{{>licenseInfo}}

interface AWSv4Configuration {
Expand All @@ -14,37 +15,37 @@ interface AWSv4Configuration {
}

export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
awsv4?: AWSv4Configuration;
basePath?: string;
serverIndex?: number;
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>) | undefined;
username?: string | undefined;
password?: string | undefined;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>) | undefined;
awsv4?: AWSv4Configuration | undefined;
basePath?: string | undefined;
serverIndex?: number | undefined;
baseOptions?: any;
formDataCtor?: new () => any;
formDataCtor?: (new () => any) | undefined;
}

export class Configuration {
/**
* parameter for apiKey security
* @param name security name
*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>) | undefined;
/**
* parameter for basic security
*/
username?: string;
username?: string | undefined;
/**
* parameter for basic security
*/
password?: string;
password?: string | undefined;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>) | undefined;
/**
* parameter for aws4 signature security
* @param {Object} AWS4Signature - AWS4 Signature security
Expand All @@ -55,27 +56,27 @@ export class Configuration {
* @param {string} credentials.sessionToken - aws session token
* @memberof Configuration
*/
awsv4?: AWSv4Configuration;
awsv4?: AWSv4Configuration | undefined;
/**
* override base path
*/
basePath?: string;
basePath?: string | undefined;
/**
* override server index
*/
serverIndex?: number;
serverIndex?: number | undefined;
/**
* base options for axios calls
*/
baseOptions?: any;
baseOptions?: any | undefined;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
formDataCtor?: (new () => any) | undefined;

constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
*/
{{/deprecated}}
{{/description}}
'{{baseName}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}};
'{{baseName}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}}{{^required}} | undefined{{/required}};
{{/vars}}
}{{#hasEnums}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{{/withAWSV4Signature}}
},
"devDependencies": {
"@types/node": "12.11.5 - 12.20.42",
"@types/node": "12.11.5 - 14.14.31",
"typescript": "^4.0 || ^5.0"
}{{#npmRepository}},{{/npmRepository}}
{{#npmRepository}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"declaration": true,
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
"module": "commonjs",
"strictNullChecks": true,
"exactOptionalPropertyTypes": true,
"noImplicitAny": true,
"outDir": "dist",
"rootDir": ".",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
{{#allParams.0}}
export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request {
{{#allParams}}
{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#hasReadOnly}}Omit<{{{dataType}}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{{dataType}}}{{/hasReadOnly}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{#hasReadOnly}}Omit<{{{dataType}}}, {{#readOnlyVars}}'{{baseName}}'{{^-last}}|{{/-last}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{{dataType}}}{{/hasReadOnly}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^required}} | undefined{{/required}};
{{/allParams}}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
* @deprecated
{{/deprecated}}
*/
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^required}} | undefined{{/required}};
{{/vars}}
}{{#hasEnums}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");

export interface ConfigurationParameters {
basePath?: string; // override base path
fetchApi?: FetchAPI; // override for fetch implementation
middleware?: Middleware[]; // middleware to apply before/after fetch requests
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
basePath?: string | undefined; // override base path
fetchApi?: FetchAPI | undefined; // override for fetch implementation
middleware?: Middleware[] | undefined; // middleware to apply before/after fetch requests
queryParamsStringify?: ((params: HTTPQuery) => string) | undefined; // stringify function for query strings
username?: string | undefined; // parameter for basic security
password?: string | undefined; // parameter for basic security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>) | undefined; // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined; // parameter for oauth2 security
headers?: HTTPHeaders | undefined; //header params we want to use on every request
credentials?: RequestCredentials | undefined; //value for the credentials param we want to use on each request
}

export class Configuration {
Expand Down Expand Up @@ -151,7 +151,6 @@ export class BaseAPI {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials,
};

const overriddenInit: RequestInit = {
Expand All @@ -162,6 +161,10 @@ export class BaseAPI {
}))
};

if (!overriddenInit.credentials && this.configuration.credentials) {
overriddenInit.credentials = this.configuration.credentials;
}

let body: any;
if (isFormData(overriddenInit.body)
|| (overriddenInit.body instanceof URLSearchParams)
Expand Down Expand Up @@ -282,7 +285,12 @@ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS'
export type HTTPHeaders = { [key: string]: string };
export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery };
export type HTTPBody = Json | FormData | URLSearchParams;
export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody };
export type HTTPRequestInit = {
headers?: HTTPHeaders | undefined;
method: HTTPMethod;
credentials?: RequestCredentials | undefined;
body?: HTTPBody | undefined;
};
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';

export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise<RequestInit>
Expand Down Expand Up @@ -373,13 +381,13 @@ export interface ErrorContext {
url: string;
init: RequestInit;
error: unknown;
response?: Response;
response?: Response | undefined;
}

export interface Middleware {
pre?(context: RequestContext): Promise<FetchParams | void>;
post?(context: ResponseContext): Promise<Response | void>;
onError?(context: ErrorContext): Promise<Response | void>;
pre?: ((context: RequestContext) => Promise<FetchParams | void>) | undefined;
post?: ((context: ResponseContext) => Promise<Response | void>) | undefined;
onError?: ((context: ErrorContext) => Promise<Response | void>) | undefined;
}

export interface ApiResponse<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export interface Payload{{#lambda.titlecase}}{{#lambda.camelcase}}{{nickname}}{{
{{#allParams.0}}
export interface Payload{{#lambda.titlecase}}{{#lambda.camelcase}}{{nickname}}{{/lambda.camelcase}}{{/lambda.titlecase}}Request {
{{#allParams}}
{{paramName}}{{^required}}?{{/required}}: {{{dataTypeAlternate}}};
{{paramName}}{{^required}}?{{/required}}: {{{dataTypeAlternate}}}{{^required}} | undefined{{/required}};
{{/allParams}}
}
{{/allParams.0}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"strict": true,
{{/sagasAndRecords}}
"module": "commonjs",
"strictNullChecks": true,
"exactOptionalPropertyTypes": true,
"moduleResolution": "node",
"outDir": "dist",
{{^supportsES6}}
Expand Down
64 changes: 32 additions & 32 deletions samples/client/echo_api/typescript-axios/build/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,41 @@ import type { RequestArgs } from './base';
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base';

export interface Bird {
'size'?: string;
'color'?: string;
'size'?: string | undefined;
'color'?: string | undefined;
}
export interface Category {
'id'?: number;
'name'?: string;
'id'?: number | undefined;
'name'?: string | undefined;
}
export interface DataQuery extends Query {
/**
* test suffix
*/
'suffix'?: string;
'suffix'?: string | undefined;
/**
* Some text containing white spaces
*/
'text'?: string;
'text'?: string | undefined;
/**
* A date
*/
'date'?: string;
'date'?: string | undefined;
}


/**
* to test the default value of properties
*/
export interface DefaultValue {
'array_string_enum_ref_default'?: Array<StringEnumRef>;
'array_string_enum_default'?: Array<DefaultValueArrayStringEnumDefaultEnum>;
'array_string_default'?: Array<string>;
'array_integer_default'?: Array<number>;
'array_string'?: Array<string>;
'array_string_nullable'?: Array<string> | null;
'array_string_extension_nullable'?: Array<string> | null;
'string_nullable'?: string | null;
'array_string_enum_ref_default'?: Array<StringEnumRef> | undefined;
'array_string_enum_default'?: Array<DefaultValueArrayStringEnumDefaultEnum> | undefined;
'array_string_default'?: Array<string> | undefined;
'array_integer_default'?: Array<number> | undefined;
'array_string'?: Array<string> | undefined;
'array_string_nullable'?: Array<string> | null | undefined;
'array_string_extension_nullable'?: Array<string> | null | undefined;
'string_nullable'?: string | null | undefined;
}

export const DefaultValueArrayStringEnumDefaultEnum = {
Expand All @@ -70,20 +70,20 @@ export const DefaultValueArrayStringEnumDefaultEnum = {
export type DefaultValueArrayStringEnumDefaultEnum = typeof DefaultValueArrayStringEnumDefaultEnum[keyof typeof DefaultValueArrayStringEnumDefaultEnum];

export interface NumberPropertiesOnly {
'number'?: number;
'float'?: number;
'double'?: number;
'number'?: number | undefined;
'float'?: number | undefined;
'double'?: number | undefined;
}
export interface Pet {
'id'?: number;
'id'?: number | undefined;
'name': string;
'category'?: Category;
'category'?: Category | undefined;
'photoUrls': Array<string>;
'tags'?: Array<Tag>;
'tags'?: Array<Tag> | undefined;
/**
* pet status in the store
*/
'status'?: PetStatusEnum;
'status'?: PetStatusEnum | undefined;
}

export const PetStatusEnum = {
Expand All @@ -98,8 +98,8 @@ export interface Query {
/**
* Query
*/
'id'?: number;
'outcomes'?: Array<QueryOutcomesEnum>;
'id'?: number | undefined;
'outcomes'?: Array<QueryOutcomesEnum> | undefined;
}

export const QueryOutcomesEnum = {
Expand All @@ -121,20 +121,20 @@ export type StringEnumRef = typeof StringEnumRef[keyof typeof StringEnumRef];


export interface Tag {
'id'?: number;
'name'?: string;
'id'?: number | undefined;
'name'?: string | undefined;
}
export interface TestFormObjectMultipartRequestMarker {
'name'?: string;
'name'?: string | undefined;
}
export interface TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter {
'size'?: string;
'color'?: string;
'id'?: number;
'name'?: string;
'size'?: string | undefined;
'color'?: string | undefined;
'id'?: number | undefined;
'name'?: string | undefined;
}
export interface TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
'values'?: Array<string>;
'values'?: Array<string> | undefined;
}

/**
Expand Down
Loading
Loading