File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed
Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ export const findCompatibleMediaType = (
1818 if (
1919 contentType . startsWith ( "*/*" ) ||
2020 contentType . startsWith ( "application/json" ) ||
21- contentType . startsWith ( "application/octet-stream" )
21+ contentType . startsWith ( "application/octet-stream" ) ||
22+ contentType . startsWith ( "multipart/form-data" )
2223 ) {
2324 return requestBodyOrResponseObject . content [ contentType ] ;
2425 }
Original file line number Diff line number Diff line change @@ -165,6 +165,9 @@ export const getType = (
165165 schema . nullable
166166 ) ;
167167 case "string" :
168+ if ( schema . format === "binary" ) {
169+ return f . createTypeReferenceNode ( "Blob" ) ;
170+ }
168171 return withNullable (
169172 f . createKeywordTypeNode ( ts . SyntaxKind . StringKeyword ) ,
170173 schema . nullable
Original file line number Diff line number Diff line change @@ -98,7 +98,12 @@ export async function ${camel(prefix)}Fetch<
9898 throw error;
9999 }
100100
101- return await response.json();
101+ if (response.headers.get('content-type').includes('json')) {
102+ return await response.json();
103+ } else {
104+ // if it is not a json response, asume it is a blob and cast it to TData
105+ return (await response.blob()) as unknown as TData;
106+ }
102107 } catch (e) {
103108 throw {
104109 status: "unknown" as const,
You can’t perform that action at this time.
0 commit comments