Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -277,8 +277,24 @@ export class {{classname}} extends runtime.BaseAPI {
{{/isArray}}
{{/formParams}}
{{/hasFormParams}}

let urlPath = `{{{path}}}`;
{{#pathParams}}
{{#isDateTimeType}}
urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent((requestParameters['{{paramName}}'] as any).toISOString()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please also check here whether it actually is a date object, i.e. instanceof Date

same below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If it isn't a date what should we do? Obvious options seem to be to stringify whatever it is, or throw an error in the generated code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also, just to call out, none of the other parameter types are making that check now (query params, form params). Assume that if I add the check I should update all those to have the same handling?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah if its not a Date, just stringify. not sure this can happen in typescript-fetch, but just to be sure.
the other places (query params) should probably also have some safeguard, but ideally in a separate PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added type checking to date params: 373a34c

{{/isDateTimeType}}
{{^isDateTimeType}}
{{#isDateType}}
urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent((requestParameters['{{paramName}}'] as any).toISOString().substring(0,10)));
{{/isDateType}}
{{^isDateType}}
urlPath = urlPath.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}'])));
{{/isDateType}}
{{/isDateTimeType}}
{{/pathParams}}

const response = await this.request({
path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters['{{paramName}}']))){{/pathParams}},
path: urlPath,
method: '{{httpMethod}}',
headers: headerParameters,
query: queryParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ export class DefaultApi extends runtime.BaseAPI {

const headerParameters: runtime.HTTPHeaders = {};


let urlPath = `/person/display/{personId}`;
urlPath = urlPath.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters['personId'])));

const response = await this.request({
path: `/person/display/{personId}`.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters['personId']))),
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ export class DefaultApi extends runtime.BaseAPI {

const headerParameters: runtime.HTTPHeaders = {};


let urlPath = `/person/display/{personId}`;
urlPath = urlPath.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters['personId'])));

const response = await this.request({
path: `/person/display/{personId}`.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters['personId']))),
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ export class AnotherFakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/another-fake/dummy`;

const response = await this.request({
path: `/another-fake/dummy`,
path: urlPath,
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ export class DefaultApi extends runtime.BaseAPI {

const headerParameters: runtime.HTTPHeaders = {};


let urlPath = `/foo`;

const response = await this.request({
path: `/foo`,
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ export class FakeApi extends runtime.BaseAPI {

const headerParameters: runtime.HTTPHeaders = {};


let urlPath = `/fake/BigDecimalMap`;

const response = await this.request({
path: `/fake/BigDecimalMap`,
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
Expand All @@ -207,8 +210,11 @@ export class FakeApi extends runtime.BaseAPI {

const headerParameters: runtime.HTTPHeaders = {};


let urlPath = `/fake/health`;

const response = await this.request({
path: `/fake/health`,
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -250,8 +256,11 @@ export class FakeApi extends runtime.BaseAPI {
headerParameters['header_1'] = String(requestParameters['header1']);
}


let urlPath = `/fake/http-signature-test`;

const response = await this.request({
path: `/fake/http-signature-test`,
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
Expand All @@ -278,8 +287,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/outer/boolean`;

const response = await this.request({
path: `/fake/outer/boolean`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -311,8 +323,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/outer/composite`;

const response = await this.request({
path: `/fake/outer/composite`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -340,8 +355,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/outer/number`;

const response = await this.request({
path: `/fake/outer/number`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -373,8 +391,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/outer/string`;

const response = await this.request({
path: `/fake/outer/string`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -413,8 +434,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/property/enum-int`;

const response = await this.request({
path: `/fake/property/enum-int`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -450,8 +474,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/additionalProperties-reference`;

const response = await this.request({
path: `/fake/additionalProperties-reference`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -486,8 +513,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'image/png';


let urlPath = `/fake/body-with-binary`;

const response = await this.request({
path: `/fake/body-with-binary`,
path: urlPath,
method: 'PUT',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -521,8 +551,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/body-with-file-schema`;

const response = await this.request({
path: `/fake/body-with-file-schema`,
path: urlPath,
method: 'PUT',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -566,8 +599,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/body-with-query-params`;

const response = await this.request({
path: `/fake/body-with-query-params`,
path: urlPath,
method: 'PUT',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -601,8 +637,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake`;

const response = await this.request({
path: `/fake`,
path: urlPath,
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -733,8 +772,11 @@ export class FakeApi extends runtime.BaseAPI {
formParams.append('callback', requestParameters['callback'] as any);
}


let urlPath = `/fake`;

const response = await this.request({
path: `/fake`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -811,8 +853,11 @@ export class FakeApi extends runtime.BaseAPI {
formParams.append('enum_form_string', requestParameters['enumFormString'] as any);
}


let urlPath = `/fake`;

const response = await this.request({
path: `/fake`,
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -892,8 +937,11 @@ export class FakeApi extends runtime.BaseAPI {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}

let urlPath = `/fake`;

const response = await this.request({
path: `/fake`,
path: urlPath,
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -928,8 +976,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/inline-additionalProperties`;

const response = await this.request({
path: `/fake/inline-additionalProperties`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -965,8 +1016,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/inline-freeform-additionalProperties`;

const response = await this.request({
path: `/fake/inline-freeform-additionalProperties`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -1029,8 +1083,11 @@ export class FakeApi extends runtime.BaseAPI {
formParams.append('param2', requestParameters['param2'] as any);
}


let urlPath = `/fake/jsonFormData`;

const response = await this.request({
path: `/fake/jsonFormData`,
path: urlPath,
method: 'GET',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -1066,8 +1123,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/nullable`;

const response = await this.request({
path: `/fake/nullable`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -1163,8 +1223,11 @@ export class FakeApi extends runtime.BaseAPI {

const headerParameters: runtime.HTTPHeaders = {};


let urlPath = `/fake/test-query-parameters`;

const response = await this.request({
path: `/fake/test-query-parameters`,
path: urlPath,
method: 'PUT',
headers: headerParameters,
query: queryParameters,
Expand Down Expand Up @@ -1198,8 +1261,11 @@ export class FakeApi extends runtime.BaseAPI {

headerParameters['Content-Type'] = 'application/json';


let urlPath = `/fake/stringMap-reference`;

const response = await this.request({
path: `/fake/stringMap-reference`,
path: urlPath,
method: 'POST',
headers: headerParameters,
query: queryParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI {
queryParameters["api_key_query"] = await this.configuration.apiKey("api_key_query"); // api_key_query authentication
}


let urlPath = `/fake_classname_test`;

const response = await this.request({
path: `/fake_classname_test`,
path: urlPath,
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
Expand Down
Loading