File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/resources/typescript-fetch
samples/client/petstore/typescript-fetch/builds Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44export const BASE_PATH = "{ {{basePath} }}".replace(/\/+$/, "");
55
6+ const isBlob = (value: any) => typeof Blob !== 'undefined' && value instanceof Blob;
7+
68/**
79 * This is the base class for all generated API classes.
810 */
@@ -47,7 +49,9 @@ export class BaseAPI {
4749 // do not handle correctly sometimes.
4850 url += ' ?' + querystring(context.query);
4951 }
50- const body = context.body instanceof FormData ? context.body : JSON.stringify(context.body);
52+ const body = (context.body instanceof FormData || isBlob(context.body))
53+ ? context.body
54+ : JSON.stringify(context.body);
5155 const init = {
5256 method: context.method,
5357 headers: context.headers,
Original file line number Diff line number Diff line change 1+ // tslint:disable
2+ /**
3+ * OpenAPI Petstore
4+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+ *
6+ * The version of the OpenAPI document: 1.0.0
7+ *
8+ *
9+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10+ * https://openapi-generator.tech
11+ * Do not edit the class manually.
12+ */
13+
14+ import { exists , mapValues } from '../runtime' ;
15+ /**
16+ *
17+ * @export
18+ * @interface InlineObject
19+ */
20+ export interface InlineObject {
21+ /**
22+ * Updated name of the pet
23+ * @type {string }
24+ * @memberof InlineObject
25+ */
26+ name ?: string ;
27+ /**
28+ * Updated status of the pet
29+ * @type {string }
30+ * @memberof InlineObject
31+ */
32+ status ?: string ;
33+ }
34+
35+ export function InlineObjectFromJSON ( json : any ) : InlineObject {
36+ return {
37+ 'name' : ! exists ( json , 'name' ) ? undefined : json [ 'name' ] ,
38+ 'status' : ! exists ( json , 'status' ) ? undefined : json [ 'status' ] ,
39+ } ;
40+ }
41+
42+ export function InlineObjectToJSON ( value ?: InlineObject ) : any {
43+ if ( value === undefined ) {
44+ return undefined ;
45+ }
46+ return {
47+ 'name' : value . name ,
48+ 'status' : value . status ,
49+ } ;
50+ }
51+
52+
Original file line number Diff line number Diff line change 1+ // tslint:disable
2+ /**
3+ * OpenAPI Petstore
4+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+ *
6+ * The version of the OpenAPI document: 1.0.0
7+ *
8+ *
9+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10+ * https://openapi-generator.tech
11+ * Do not edit the class manually.
12+ */
13+
14+ import { exists , mapValues } from '../runtime' ;
15+ /**
16+ *
17+ * @export
18+ * @interface InlineObject1
19+ */
20+ export interface InlineObject1 {
21+ /**
22+ * Additional data to pass to server
23+ * @type {string }
24+ * @memberof InlineObject1
25+ */
26+ additionalMetadata ?: string ;
27+ /**
28+ * file to upload
29+ * @type {Blob }
30+ * @memberof InlineObject1
31+ */
32+ file ?: Blob ;
33+ }
34+
35+ export function InlineObject1FromJSON ( json : any ) : InlineObject1 {
36+ return {
37+ 'additionalMetadata' : ! exists ( json , 'additionalMetadata' ) ? undefined : json [ 'additionalMetadata' ] ,
38+ 'file' : ! exists ( json , 'file' ) ? undefined : json [ 'file' ] ,
39+ } ;
40+ }
41+
42+ export function InlineObject1ToJSON ( value ?: InlineObject1 ) : any {
43+ if ( value === undefined ) {
44+ return undefined ;
45+ }
46+ return {
47+ 'additionalMetadata' : value . additionalMetadata ,
48+ 'file' : value . file ,
49+ } ;
50+ }
51+
52+
Original file line number Diff line number Diff line change 1414
1515export const BASE_PATH = "http://petstore.swagger.io/v2" . replace ( / \/ + $ / , "" ) ;
1616
17+ const isBlob = ( value : any ) => typeof Blob !== 'undefined' && value instanceof Blob ;
18+
1719/**
1820 * This is the base class for all generated API classes.
1921 */
@@ -58,7 +60,9 @@ export class BaseAPI {
5860 // do not handle correctly sometimes.
5961 url += '?' + querystring ( context . query ) ;
6062 }
61- const body = context . body instanceof FormData ? context . body : JSON . stringify ( context . body ) ;
63+ const body = ( context . body instanceof FormData || isBlob ( context . body ) )
64+ ? context . body
65+ : JSON . stringify ( context . body ) ;
6266 const init = {
6367 method : context . method ,
6468 headers : context . headers ,
Original file line number Diff line number Diff line change 1+ // tslint:disable
2+ /**
3+ * OpenAPI Petstore
4+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+ *
6+ * The version of the OpenAPI document: 1.0.0
7+ *
8+ *
9+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10+ * https://openapi-generator.tech
11+ * Do not edit the class manually.
12+ */
13+
14+ import { exists , mapValues } from '../runtime' ;
15+ /**
16+ *
17+ * @export
18+ * @interface InlineObject
19+ */
20+ export interface InlineObject {
21+ /**
22+ * Updated name of the pet
23+ * @type {string }
24+ * @memberof InlineObject
25+ */
26+ name ?: string ;
27+ /**
28+ * Updated status of the pet
29+ * @type {string }
30+ * @memberof InlineObject
31+ */
32+ status ?: string ;
33+ }
34+
35+ export function InlineObjectFromJSON ( json : any ) : InlineObject {
36+ return {
37+ 'name' : ! exists ( json , 'name' ) ? undefined : json [ 'name' ] ,
38+ 'status' : ! exists ( json , 'status' ) ? undefined : json [ 'status' ] ,
39+ } ;
40+ }
41+
42+ export function InlineObjectToJSON ( value ?: InlineObject ) : any {
43+ if ( value === undefined ) {
44+ return undefined ;
45+ }
46+ return {
47+ 'name' : value . name ,
48+ 'status' : value . status ,
49+ } ;
50+ }
51+
52+
Original file line number Diff line number Diff line change 1+ // tslint:disable
2+ /**
3+ * OpenAPI Petstore
4+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+ *
6+ * The version of the OpenAPI document: 1.0.0
7+ *
8+ *
9+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10+ * https://openapi-generator.tech
11+ * Do not edit the class manually.
12+ */
13+
14+ import { exists , mapValues } from '../runtime' ;
15+ /**
16+ *
17+ * @export
18+ * @interface InlineObject1
19+ */
20+ export interface InlineObject1 {
21+ /**
22+ * Additional data to pass to server
23+ * @type {string }
24+ * @memberof InlineObject1
25+ */
26+ additionalMetadata ?: string ;
27+ /**
28+ * file to upload
29+ * @type {Blob }
30+ * @memberof InlineObject1
31+ */
32+ file ?: Blob ;
33+ }
34+
35+ export function InlineObject1FromJSON ( json : any ) : InlineObject1 {
36+ return {
37+ 'additionalMetadata' : ! exists ( json , 'additionalMetadata' ) ? undefined : json [ 'additionalMetadata' ] ,
38+ 'file' : ! exists ( json , 'file' ) ? undefined : json [ 'file' ] ,
39+ } ;
40+ }
41+
42+ export function InlineObject1ToJSON ( value ?: InlineObject1 ) : any {
43+ if ( value === undefined ) {
44+ return undefined ;
45+ }
46+ return {
47+ 'additionalMetadata' : value . additionalMetadata ,
48+ 'file' : value . file ,
49+ } ;
50+ }
51+
52+
Original file line number Diff line number Diff line change 1414
1515export const BASE_PATH = "http://petstore.swagger.io/v2" . replace ( / \/ + $ / , "" ) ;
1616
17+ const isBlob = ( value : any ) => typeof Blob !== 'undefined' && value instanceof Blob ;
18+
1719/**
1820 * This is the base class for all generated API classes.
1921 */
@@ -58,7 +60,9 @@ export class BaseAPI {
5860 // do not handle correctly sometimes.
5961 url += '?' + querystring ( context . query ) ;
6062 }
61- const body = context . body instanceof FormData ? context . body : JSON . stringify ( context . body ) ;
63+ const body = ( context . body instanceof FormData || isBlob ( context . body ) )
64+ ? context . body
65+ : JSON . stringify ( context . body ) ;
6266 const init = {
6367 method : context . method ,
6468 headers : context . headers ,
Original file line number Diff line number Diff line change 1+ // tslint:disable
2+ /**
3+ * OpenAPI Petstore
4+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+ *
6+ * The version of the OpenAPI document: 1.0.0
7+ *
8+ *
9+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10+ * https://openapi-generator.tech
11+ * Do not edit the class manually.
12+ */
13+
14+ import { exists , mapValues } from '../runtime' ;
15+ /**
16+ *
17+ * @export
18+ * @interface InlineObject
19+ */
20+ export interface InlineObject {
21+ /**
22+ * Updated name of the pet
23+ * @type {string }
24+ * @memberof InlineObject
25+ */
26+ name ?: string ;
27+ /**
28+ * Updated status of the pet
29+ * @type {string }
30+ * @memberof InlineObject
31+ */
32+ status ?: string ;
33+ }
34+
35+ export function InlineObjectFromJSON ( json : any ) : InlineObject {
36+ return {
37+ 'name' : ! exists ( json , 'name' ) ? undefined : json [ 'name' ] ,
38+ 'status' : ! exists ( json , 'status' ) ? undefined : json [ 'status' ] ,
39+ } ;
40+ }
41+
42+ export function InlineObjectToJSON ( value ?: InlineObject ) : any {
43+ if ( value === undefined ) {
44+ return undefined ;
45+ }
46+ return {
47+ 'name' : value . name ,
48+ 'status' : value . status ,
49+ } ;
50+ }
51+
52+
Original file line number Diff line number Diff line change 1+ // tslint:disable
2+ /**
3+ * OpenAPI Petstore
4+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
5+ *
6+ * The version of the OpenAPI document: 1.0.0
7+ *
8+ *
9+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10+ * https://openapi-generator.tech
11+ * Do not edit the class manually.
12+ */
13+
14+ import { exists , mapValues } from '../runtime' ;
15+ /**
16+ *
17+ * @export
18+ * @interface InlineObject1
19+ */
20+ export interface InlineObject1 {
21+ /**
22+ * Additional data to pass to server
23+ * @type {string }
24+ * @memberof InlineObject1
25+ */
26+ additionalMetadata ?: string ;
27+ /**
28+ * file to upload
29+ * @type {Blob }
30+ * @memberof InlineObject1
31+ */
32+ file ?: Blob ;
33+ }
34+
35+ export function InlineObject1FromJSON ( json : any ) : InlineObject1 {
36+ return {
37+ 'additionalMetadata' : ! exists ( json , 'additionalMetadata' ) ? undefined : json [ 'additionalMetadata' ] ,
38+ 'file' : ! exists ( json , 'file' ) ? undefined : json [ 'file' ] ,
39+ } ;
40+ }
41+
42+ export function InlineObject1ToJSON ( value ?: InlineObject1 ) : any {
43+ if ( value === undefined ) {
44+ return undefined ;
45+ }
46+ return {
47+ 'additionalMetadata' : value . additionalMetadata ,
48+ 'file' : value . file ,
49+ } ;
50+ }
51+
52+
Original file line number Diff line number Diff line change 1414
1515export const BASE_PATH = "http://petstore.swagger.io/v2" . replace ( / \/ + $ / , "" ) ;
1616
17+ const isBlob = ( value : any ) => typeof Blob !== 'undefined' && value instanceof Blob ;
18+
1719/**
1820 * This is the base class for all generated API classes.
1921 */
@@ -58,7 +60,9 @@ export class BaseAPI {
5860 // do not handle correctly sometimes.
5961 url += '?' + querystring ( context . query ) ;
6062 }
61- const body = context . body instanceof FormData ? context . body : JSON . stringify ( context . body ) ;
63+ const body = ( context . body instanceof FormData || isBlob ( context . body ) )
64+ ? context . body
65+ : JSON . stringify ( context . body ) ;
6266 const init = {
6367 method : context . method ,
6468 headers : context . headers ,
You can’t perform that action at this time.
0 commit comments