Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript][Fetch] only call toISOString() if date object #9594

Merged
merged 5 commits into from
May 8, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface FetchAPI {
}

/**
*
*
* @export
* @interface FetchArgs
*/
Expand All @@ -39,7 +39,7 @@ export interface FetchArgs {
}

/**
*
*
* @export
* @class BaseAPI
*/
Expand All @@ -55,7 +55,7 @@ export class BaseAPI {
};

/**
*
*
* @export
* @class RequiredError
* @extends {Error}
Expand Down Expand Up @@ -164,7 +164,9 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur
{{/isDateTime}}
{{^isDateTime}}
{{#isDate}}
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any).toISOString();
localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ?
({{paramName}} as any).toISOString().substr(0,10) :

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a notice, if the param type is "datetime" the string length should surpass 10 characters since it contains the timestamp as well.
For instance: "2014-01-01T23:28:56.782Z" or even "2014-02-01T09:28:56.321-10:00"

I suggest checking the type for date if you want to keep the substr(0,10) or else this would be problematic for datetime types.

{{paramName}};
{{/isDate}}
{{^isDate}}
localVarQueryParameter['{{baseName}}'] = {{paramName}};
Expand Down