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] Fix uploading files #2900

Merged
merged 21 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e6b745c
[typescript-fetch] Fix uploading files
janbuchar May 15, 2019
8bdc162
Check for Blob instead of File
janbuchar May 16, 2019
4a6b00e
Merge remote-tracking branch 'upstream/master' into typescript-fetch-…
janbuchar May 20, 2019
f621eaa
Update samples
janbuchar May 20, 2019
412217b
Merge branch 'master' into typescript-fetch-file-upload
janbuchar May 20, 2019
04003ee
Update samples
janbuchar May 20, 2019
73ac448
Update samples
janbuchar May 20, 2019
0d1cfc8
Update samples
janbuchar May 20, 2019
d73aff5
Merge remote-tracking branch 'upstream/master' into typescript-fetch-…
janbuchar May 22, 2019
df125e6
Regenerate samples
janbuchar May 22, 2019
bf7ee5e
Bug
janbuchar May 22, 2019
d8514aa
Manually fix samples
janbuchar May 22, 2019
b8f470e
Merge remote-tracking branch 'upstream/master' into typescript-fetch-…
janbuchar May 23, 2019
68cd6dc
Implement support for Buffer and Blob in a backwards-compatible way
janbuchar May 23, 2019
915868a
Rework how blob and buffer instance checking works
janbuchar May 24, 2019
a1a3a6d
Check for Blob/Buffer existence properly
janbuchar May 24, 2019
f61c1c2
Avoid using Buffer and Blob in type declarations
janbuchar May 24, 2019
016170d
Merge remote-tracking branch 'upstream/master' into typescript-fetch-…
janbuchar May 29, 2019
8adcb8e
Remove Buffer support
janbuchar May 29, 2019
f5c1ed2
Update samples/client/petstore/typescript-fetch/tests/default/test/Pe…
janbuchar May 29, 2019
2ea96f7
Update samples/client/petstore/typescript-fetch/tests/default/test/Pe…
janbuchar May 29, 2019
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 @@ -47,7 +47,9 @@ export class BaseAPI {
// do not handle correctly sometimes.
url += '?' + querystring(context.query);
}
const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body);
const body = (context.body instanceof FormData || context.body instanceof Body)
? context.body
: JSON.stringify(context.body);
const init = {
method: context.method,
headers: context.headers,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1-SNAPSHOT
4.0.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -23,7 +23,7 @@ import {
} from '../models';

export interface AddPetRequest {
body: Pet;
pet: Pet;
Copy link
Member

Choose a reason for hiding this comment

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

Look like you're using an old version. please pull the latest master and merge into your branch and then update the samples again.

}

export interface DeletePetRequest {
Expand All @@ -37,14 +37,15 @@ export interface FindPetsByStatusRequest {

export interface FindPetsByTagsRequest {
tags: Array<string>;
maxCount?: number;
}

export interface GetPetByIdRequest {
petId: number;
}

export interface UpdatePetRequest {
body: Pet;
pet: Pet;
}

export interface UpdatePetWithFormRequest {
Expand All @@ -68,8 +69,8 @@ export class PetApi extends runtime.BaseAPI {
* Add a new pet to the store
*/
async addPetRaw(requestParameters: AddPetRequest): Promise<runtime.ApiResponse<void>> {
if (requestParameters.body === null || requestParameters.body === undefined) {
throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.');
if (requestParameters.pet === null || requestParameters.pet === undefined) {
throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.');
}

const queryParameters: runtime.HTTPQuery = {};
Expand All @@ -92,7 +93,7 @@ export class PetApi extends runtime.BaseAPI {
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: PetToJSON(requestParameters.body),
body: PetToJSON(requestParameters.pet),
});

return new runtime.VoidApiResponse(response);
Expand Down Expand Up @@ -207,6 +208,10 @@ export class PetApi extends runtime.BaseAPI {
queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]);
}

if (requestParameters.maxCount !== undefined) {
queryParameters['maxCount'] = requestParameters.maxCount;
}

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
Expand Down Expand Up @@ -277,8 +282,8 @@ export class PetApi extends runtime.BaseAPI {
* Update an existing pet
*/
async updatePetRaw(requestParameters: UpdatePetRequest): Promise<runtime.ApiResponse<void>> {
if (requestParameters.body === null || requestParameters.body === undefined) {
throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.');
if (requestParameters.pet === null || requestParameters.pet === undefined) {
throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.');
}

const queryParameters: runtime.HTTPQuery = {};
Expand All @@ -301,7 +306,7 @@ export class PetApi extends runtime.BaseAPI {
method: 'PUT',
headers: headerParameters,
query: queryParameters,
body: PetToJSON(requestParameters.body),
body: PetToJSON(requestParameters.pet),
});

return new runtime.VoidApiResponse(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -28,7 +28,7 @@ export interface GetOrderByIdRequest {
}

export interface PlaceOrderRequest {
body: Order;
order: Order;
}

/**
Expand Down Expand Up @@ -135,8 +135,8 @@ export class StoreApi extends runtime.BaseAPI {
* Place an order for a pet
*/
async placeOrderRaw(requestParameters: PlaceOrderRequest): Promise<runtime.ApiResponse<Order>> {
if (requestParameters.body === null || requestParameters.body === undefined) {
throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.');
if (requestParameters.order === null || requestParameters.order === undefined) {
throw new runtime.RequiredError('order','Required parameter requestParameters.order was null or undefined when calling placeOrder.');
}

const queryParameters: runtime.HTTPQuery = {};
Expand All @@ -150,7 +150,7 @@ export class StoreApi extends runtime.BaseAPI {
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: OrderToJSON(requestParameters.body),
body: OrderToJSON(requestParameters.order),
});

return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -20,15 +20,15 @@ import {
} from '../models';

export interface CreateUserRequest {
body: User;
user: User;
}

export interface CreateUsersWithArrayInputRequest {
body: Array<User>;
user: Array<User>;
}

export interface CreateUsersWithListInputRequest {
body: Array<User>;
user: Array<User>;
}

export interface DeleteUserRequest {
Expand All @@ -46,7 +46,7 @@ export interface LoginUserRequest {

export interface UpdateUserRequest {
username: string;
body: User;
user: User;
}

/**
Expand All @@ -59,8 +59,8 @@ export class UserApi extends runtime.BaseAPI {
* Create user
*/
async createUserRaw(requestParameters: CreateUserRequest): Promise<runtime.ApiResponse<void>> {
if (requestParameters.body === null || requestParameters.body === undefined) {
throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.');
if (requestParameters.user === null || requestParameters.user === undefined) {
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUser.');
}

const queryParameters: runtime.HTTPQuery = {};
Expand All @@ -74,7 +74,7 @@ export class UserApi extends runtime.BaseAPI {
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: UserToJSON(requestParameters.body),
body: UserToJSON(requestParameters.user),
});

return new runtime.VoidApiResponse(response);
Expand All @@ -92,8 +92,8 @@ export class UserApi extends runtime.BaseAPI {
* Creates list of users with given input array
*/
async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest): Promise<runtime.ApiResponse<void>> {
if (requestParameters.body === null || requestParameters.body === undefined) {
throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.');
if (requestParameters.user === null || requestParameters.user === undefined) {
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithArrayInput.');
}

const queryParameters: runtime.HTTPQuery = {};
Expand All @@ -107,7 +107,7 @@ export class UserApi extends runtime.BaseAPI {
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: requestParameters.body.map(UserToJSON),
body: requestParameters.user.map(UserToJSON),
});

return new runtime.VoidApiResponse(response);
Expand All @@ -124,8 +124,8 @@ export class UserApi extends runtime.BaseAPI {
* Creates list of users with given input array
*/
async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest): Promise<runtime.ApiResponse<void>> {
if (requestParameters.body === null || requestParameters.body === undefined) {
throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.');
if (requestParameters.user === null || requestParameters.user === undefined) {
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling createUsersWithListInput.');
}

const queryParameters: runtime.HTTPQuery = {};
Expand All @@ -139,7 +139,7 @@ export class UserApi extends runtime.BaseAPI {
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: requestParameters.body.map(UserToJSON),
body: requestParameters.user.map(UserToJSON),
});

return new runtime.VoidApiResponse(response);
Expand Down Expand Up @@ -289,8 +289,8 @@ export class UserApi extends runtime.BaseAPI {
throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.');
}

if (requestParameters.body === null || requestParameters.body === undefined) {
throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.');
if (requestParameters.user === null || requestParameters.user === undefined) {
throw new runtime.RequiredError('user','Required parameter requestParameters.user was null or undefined when calling updateUser.');
}

const queryParameters: runtime.HTTPQuery = {};
Expand All @@ -304,7 +304,7 @@ export class UserApi extends runtime.BaseAPI {
method: 'PUT',
headers: headerParameters,
query: queryParameters,
body: UserToJSON(requestParameters.body),
body: UserToJSON(requestParameters.user),
});

return new runtime.VoidApiResponse(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './Category';
export * from './InlineObject';
export * from './InlineObject1';
export * from './ModelApiResponse';
export * from './Order';
export * from './Pet';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -209,7 +209,6 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string {
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
})
.filter(part => part.length > 0)
.join('&');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1-SNAPSHOT
4.0.0-SNAPSHOT
Loading