File tree 13 files changed +441
-5
lines changed
modules/openapi-generator/src/main/resources/typescript-fetch
samples/client/petstore/typescript-fetch/builds
13 files changed +441
-5
lines changed Original file line number Diff line number Diff line change 3
3
4
4
export const BASE_PATH = "{ {{basePath} }}".replace(/\/+$/, "");
5
5
6
+ const isBlob = (value: any) => typeof Blob !== 'undefined' && value instanceof Blob;
7
+
6
8
/**
7
9
* This is the base class for all generated API classes.
8
10
*/
@@ -47,7 +49,9 @@ export class BaseAPI {
47
49
// do not handle correctly sometimes.
48
50
url += ' ?' + querystring(context.query);
49
51
}
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);
51
55
const init = {
52
56
method: context.method,
53
57
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 14
14
15
15
export const BASE_PATH = "http://petstore.swagger.io/v2" . replace ( / \/ + $ / , "" ) ;
16
16
17
+ const isBlob = ( value : any ) => typeof Blob !== 'undefined' && value instanceof Blob ;
18
+
17
19
/**
18
20
* This is the base class for all generated API classes.
19
21
*/
@@ -58,7 +60,9 @@ export class BaseAPI {
58
60
// do not handle correctly sometimes.
59
61
url += '?' + querystring ( context . query ) ;
60
62
}
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 ) ;
62
66
const init = {
63
67
method : context . method ,
64
68
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 14
14
15
15
export const BASE_PATH = "http://petstore.swagger.io/v2" . replace ( / \/ + $ / , "" ) ;
16
16
17
+ const isBlob = ( value : any ) => typeof Blob !== 'undefined' && value instanceof Blob ;
18
+
17
19
/**
18
20
* This is the base class for all generated API classes.
19
21
*/
@@ -58,7 +60,9 @@ export class BaseAPI {
58
60
// do not handle correctly sometimes.
59
61
url += '?' + querystring ( context . query ) ;
60
62
}
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 ) ;
62
66
const init = {
63
67
method : context . method ,
64
68
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 14
14
15
15
export const BASE_PATH = "http://petstore.swagger.io/v2" . replace ( / \/ + $ / , "" ) ;
16
16
17
+ const isBlob = ( value : any ) => typeof Blob !== 'undefined' && value instanceof Blob ;
18
+
17
19
/**
18
20
* This is the base class for all generated API classes.
19
21
*/
@@ -58,7 +60,9 @@ export class BaseAPI {
58
60
// do not handle correctly sometimes.
59
61
url += '?' + querystring ( context . query ) ;
60
62
}
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 ) ;
62
66
const init = {
63
67
method : context . method ,
64
68
headers : context . headers ,
You can’t perform that action at this time.
0 commit comments