-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[typescript-fetch] Fix uploading files #2900
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
Merged
wing328
merged 21 commits into
OpenAPITools:master
from
janbuchar:typescript-fetch-file-upload
May 31, 2019
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e6b745c
[typescript-fetch] Fix uploading files
janbuchar 8bdc162
Check for Blob instead of File
janbuchar 4a6b00e
Merge remote-tracking branch 'upstream/master' into typescript-fetch-…
janbuchar f621eaa
Update samples
janbuchar 412217b
Merge branch 'master' into typescript-fetch-file-upload
janbuchar 04003ee
Update samples
janbuchar 73ac448
Update samples
janbuchar 0d1cfc8
Update samples
janbuchar d73aff5
Merge remote-tracking branch 'upstream/master' into typescript-fetch-…
janbuchar df125e6
Regenerate samples
janbuchar bf7ee5e
Bug
janbuchar d8514aa
Manually fix samples
janbuchar b8f470e
Merge remote-tracking branch 'upstream/master' into typescript-fetch-…
janbuchar 68cd6dc
Implement support for Buffer and Blob in a backwards-compatible way
janbuchar 915868a
Rework how blob and buffer instance checking works
janbuchar a1a3a6d
Check for Blob/Buffer existence properly
janbuchar f61c1c2
Avoid using Buffer and Blob in type declarations
janbuchar 016170d
Merge remote-tracking branch 'upstream/master' into typescript-fetch-…
janbuchar 8adcb8e
Remove Buffer support
janbuchar f5c1ed2
Update samples/client/petstore/typescript-fetch/tests/default/test/Pe…
janbuchar 2ea96f7
Update samples/client/petstore/typescript-fetch/tests/default/test/Pe…
janbuchar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Check for Blob/Buffer existence properly
- Loading branch information
commit a1a3a6da3b9476318f1315586dd19866bb08fded
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
samples/client/petstore/typescript-fetch/builds/default/models/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ import { | |
| } from '../models'; | ||
|
|
||
| export interface AddPetRequest { | ||
| pet: Pet; | ||
| body: Pet; | ||
| } | ||
|
|
||
| export interface DeletePetRequest { | ||
|
|
@@ -37,15 +37,14 @@ export interface FindPetsByStatusRequest { | |
|
|
||
| export interface FindPetsByTagsRequest { | ||
| tags: Array<string>; | ||
| maxCount?: number; | ||
| } | ||
|
|
||
| export interface GetPetByIdRequest { | ||
| petId: number; | ||
| } | ||
|
|
||
| export interface UpdatePetRequest { | ||
| pet: Pet; | ||
| body: Pet; | ||
| } | ||
|
|
||
| export interface UpdatePetWithFormRequest { | ||
|
|
@@ -69,8 +68,8 @@ export class PetApi extends runtime.BaseAPI { | |
| * Add a new pet to the store | ||
| */ | ||
| async addPetRaw(requestParameters: AddPetRequest): Promise<runtime.ApiResponse<void>> { | ||
| if (requestParameters.pet === null || requestParameters.pet === undefined) { | ||
| throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling addPet.'); | ||
| if (requestParameters.body === null || requestParameters.body === undefined) { | ||
| throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); | ||
| } | ||
|
|
||
| const queryParameters: runtime.HTTPQuery = {}; | ||
|
|
@@ -93,7 +92,7 @@ export class PetApi extends runtime.BaseAPI { | |
| method: 'POST', | ||
| headers: headerParameters, | ||
| query: queryParameters, | ||
| body: PetToJSON(requestParameters.pet), | ||
| body: PetToJSON(requestParameters.body), | ||
| }); | ||
|
|
||
| return new runtime.VoidApiResponse(response); | ||
|
|
@@ -168,7 +167,7 @@ export class PetApi extends runtime.BaseAPI { | |
| if (this.configuration && this.configuration.accessToken) { | ||
| // oauth required | ||
| if (typeof this.configuration.accessToken === 'function') { | ||
| headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["read:pets"]); | ||
| headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); | ||
| } else { | ||
| headerParameters["Authorization"] = this.configuration.accessToken; | ||
| } | ||
|
|
@@ -208,16 +207,12 @@ 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) { | ||
| // oauth required | ||
| if (typeof this.configuration.accessToken === 'function') { | ||
| headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["read:pets"]); | ||
| headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this change?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be due to a fix in oauth scope to propagate these values probably. |
||
| } else { | ||
| headerParameters["Authorization"] = this.configuration.accessToken; | ||
| } | ||
|
|
@@ -282,8 +277,8 @@ export class PetApi extends runtime.BaseAPI { | |
| * Update an existing pet | ||
| */ | ||
| async updatePetRaw(requestParameters: UpdatePetRequest): Promise<runtime.ApiResponse<void>> { | ||
| if (requestParameters.pet === null || requestParameters.pet === undefined) { | ||
| throw new runtime.RequiredError('pet','Required parameter requestParameters.pet was null or undefined when calling updatePet.'); | ||
| if (requestParameters.body === null || requestParameters.body === undefined) { | ||
| throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); | ||
| } | ||
|
|
||
| const queryParameters: runtime.HTTPQuery = {}; | ||
|
|
@@ -306,7 +301,7 @@ export class PetApi extends runtime.BaseAPI { | |
| method: 'PUT', | ||
| headers: headerParameters, | ||
| query: queryParameters, | ||
| body: PetToJSON(requestParameters.pet), | ||
| body: PetToJSON(requestParameters.body), | ||
| }); | ||
|
|
||
| return new runtime.VoidApiResponse(response); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it is easier to only support Blob, since
Bufferdoes not exist in thedomtypings https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.tsor we need to add typings which include
BufferThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be enough to install
@types/node, which seems pretty sensible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I imagine a user wouldn't want to install
@types/nodefor a web project, since the node API won't be available in the web...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a user would care much... create-react-app for typescript installs @types/node too.