-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[typescript-fetch] Fix uploading files (#2900)
* [typescript-fetch] Fix uploading files * Check for Blob instead of File * Update samples * Update samples * Update samples * Update samples * Regenerate samples * Bug * Manually fix samples * Implement support for Buffer and Blob in a backwards-compatible way * Rework how blob and buffer instance checking works * Check for Blob/Buffer existence properly * Avoid using Buffer and Blob in type declarations * Remove Buffer support * Update samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts Co-Authored-By: Esteban Marin <estebanmarin@gmx.ch> * Update samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts Co-Authored-By: Esteban Marin <estebanmarin@gmx.ch>
- Loading branch information
Showing
13 changed files
with
441 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
52 changes: 52 additions & 0 deletions
52
samples/client/petstore/typescript-fetch/builds/default/models/InlineObject.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// tslint:disable | ||
/** | ||
* 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 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
import { exists, mapValues } from '../runtime'; | ||
/** | ||
* | ||
* @export | ||
* @interface InlineObject | ||
*/ | ||
export interface InlineObject { | ||
/** | ||
* Updated name of the pet | ||
* @type {string} | ||
* @memberof InlineObject | ||
*/ | ||
name?: string; | ||
/** | ||
* Updated status of the pet | ||
* @type {string} | ||
* @memberof InlineObject | ||
*/ | ||
status?: string; | ||
} | ||
|
||
export function InlineObjectFromJSON(json: any): InlineObject { | ||
return { | ||
'name': !exists(json, 'name') ? undefined : json['name'], | ||
'status': !exists(json, 'status') ? undefined : json['status'], | ||
}; | ||
} | ||
|
||
export function InlineObjectToJSON(value?: InlineObject): any { | ||
if (value === undefined) { | ||
return undefined; | ||
} | ||
return { | ||
'name': value.name, | ||
'status': value.status, | ||
}; | ||
} | ||
|
||
|
52 changes: 52 additions & 0 deletions
52
samples/client/petstore/typescript-fetch/builds/default/models/InlineObject1.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// tslint:disable | ||
/** | ||
* 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 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
import { exists, mapValues } from '../runtime'; | ||
/** | ||
* | ||
* @export | ||
* @interface InlineObject1 | ||
*/ | ||
export interface InlineObject1 { | ||
/** | ||
* Additional data to pass to server | ||
* @type {string} | ||
* @memberof InlineObject1 | ||
*/ | ||
additionalMetadata?: string; | ||
/** | ||
* file to upload | ||
* @type {Blob} | ||
* @memberof InlineObject1 | ||
*/ | ||
file?: Blob; | ||
} | ||
|
||
export function InlineObject1FromJSON(json: any): InlineObject1 { | ||
return { | ||
'additionalMetadata': !exists(json, 'additionalMetadata') ? undefined : json['additionalMetadata'], | ||
'file': !exists(json, 'file') ? undefined : json['file'], | ||
}; | ||
} | ||
|
||
export function InlineObject1ToJSON(value?: InlineObject1): any { | ||
if (value === undefined) { | ||
return undefined; | ||
} | ||
return { | ||
'additionalMetadata': value.additionalMetadata, | ||
'file': value.file, | ||
}; | ||
} | ||
|
||
|
This file contains 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
52 changes: 52 additions & 0 deletions
52
samples/client/petstore/typescript-fetch/builds/es6-target/models/InlineObject.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// tslint:disable | ||
/** | ||
* 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 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
import { exists, mapValues } from '../runtime'; | ||
/** | ||
* | ||
* @export | ||
* @interface InlineObject | ||
*/ | ||
export interface InlineObject { | ||
/** | ||
* Updated name of the pet | ||
* @type {string} | ||
* @memberof InlineObject | ||
*/ | ||
name?: string; | ||
/** | ||
* Updated status of the pet | ||
* @type {string} | ||
* @memberof InlineObject | ||
*/ | ||
status?: string; | ||
} | ||
|
||
export function InlineObjectFromJSON(json: any): InlineObject { | ||
return { | ||
'name': !exists(json, 'name') ? undefined : json['name'], | ||
'status': !exists(json, 'status') ? undefined : json['status'], | ||
}; | ||
} | ||
|
||
export function InlineObjectToJSON(value?: InlineObject): any { | ||
if (value === undefined) { | ||
return undefined; | ||
} | ||
return { | ||
'name': value.name, | ||
'status': value.status, | ||
}; | ||
} | ||
|
||
|
52 changes: 52 additions & 0 deletions
52
samples/client/petstore/typescript-fetch/builds/es6-target/models/InlineObject1.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// tslint:disable | ||
/** | ||
* 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 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
import { exists, mapValues } from '../runtime'; | ||
/** | ||
* | ||
* @export | ||
* @interface InlineObject1 | ||
*/ | ||
export interface InlineObject1 { | ||
/** | ||
* Additional data to pass to server | ||
* @type {string} | ||
* @memberof InlineObject1 | ||
*/ | ||
additionalMetadata?: string; | ||
/** | ||
* file to upload | ||
* @type {Blob} | ||
* @memberof InlineObject1 | ||
*/ | ||
file?: Blob; | ||
} | ||
|
||
export function InlineObject1FromJSON(json: any): InlineObject1 { | ||
return { | ||
'additionalMetadata': !exists(json, 'additionalMetadata') ? undefined : json['additionalMetadata'], | ||
'file': !exists(json, 'file') ? undefined : json['file'], | ||
}; | ||
} | ||
|
||
export function InlineObject1ToJSON(value?: InlineObject1): any { | ||
if (value === undefined) { | ||
return undefined; | ||
} | ||
return { | ||
'additionalMetadata': value.additionalMetadata, | ||
'file': value.file, | ||
}; | ||
} | ||
|
||
|
This file contains 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
52 changes: 52 additions & 0 deletions
52
samples/client/petstore/typescript-fetch/builds/with-interfaces/models/InlineObject.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// tslint:disable | ||
/** | ||
* 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 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
import { exists, mapValues } from '../runtime'; | ||
/** | ||
* | ||
* @export | ||
* @interface InlineObject | ||
*/ | ||
export interface InlineObject { | ||
/** | ||
* Updated name of the pet | ||
* @type {string} | ||
* @memberof InlineObject | ||
*/ | ||
name?: string; | ||
/** | ||
* Updated status of the pet | ||
* @type {string} | ||
* @memberof InlineObject | ||
*/ | ||
status?: string; | ||
} | ||
|
||
export function InlineObjectFromJSON(json: any): InlineObject { | ||
return { | ||
'name': !exists(json, 'name') ? undefined : json['name'], | ||
'status': !exists(json, 'status') ? undefined : json['status'], | ||
}; | ||
} | ||
|
||
export function InlineObjectToJSON(value?: InlineObject): any { | ||
if (value === undefined) { | ||
return undefined; | ||
} | ||
return { | ||
'name': value.name, | ||
'status': value.status, | ||
}; | ||
} | ||
|
||
|
52 changes: 52 additions & 0 deletions
52
samples/client/petstore/typescript-fetch/builds/with-interfaces/models/InlineObject1.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// tslint:disable | ||
/** | ||
* 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 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
import { exists, mapValues } from '../runtime'; | ||
/** | ||
* | ||
* @export | ||
* @interface InlineObject1 | ||
*/ | ||
export interface InlineObject1 { | ||
/** | ||
* Additional data to pass to server | ||
* @type {string} | ||
* @memberof InlineObject1 | ||
*/ | ||
additionalMetadata?: string; | ||
/** | ||
* file to upload | ||
* @type {Blob} | ||
* @memberof InlineObject1 | ||
*/ | ||
file?: Blob; | ||
} | ||
|
||
export function InlineObject1FromJSON(json: any): InlineObject1 { | ||
return { | ||
'additionalMetadata': !exists(json, 'additionalMetadata') ? undefined : json['additionalMetadata'], | ||
'file': !exists(json, 'file') ? undefined : json['file'], | ||
}; | ||
} | ||
|
||
export function InlineObject1ToJSON(value?: InlineObject1): any { | ||
if (value === undefined) { | ||
return undefined; | ||
} | ||
return { | ||
'additionalMetadata': value.additionalMetadata, | ||
'file': value.file, | ||
}; | ||
} | ||
|
||
|
This file contains 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.