@@ -274,6 +274,64 @@ it.effect("converts Google Discovery documents into Executor-preserving OpenAPI
274274 } ) ,
275275) ;
276276
277+ it . effect ( "marks Google Discovery media-download methods as binary responses" , ( ) =>
278+ Effect . gen ( function * ( ) {
279+ const result = yield * convertGoogleDiscoveryToOpenApi ( {
280+ discoveryUrl : "https://www.googleapis.com/discovery/v1/apis/drive/v3/rest" ,
281+ // @effect -diagnostics-next-line preferSchemaOverJson:off
282+ documentText : JSON . stringify ( {
283+ name : "drive" ,
284+ version : "v3" ,
285+ title : "Drive API" ,
286+ rootUrl : "https://www.googleapis.com/" ,
287+ servicePath : "drive/v3/" ,
288+ resources : {
289+ files : {
290+ methods : {
291+ export : {
292+ id : "drive.files.export" ,
293+ httpMethod : "GET" ,
294+ path : "files/{fileId}/export" ,
295+ supportsMediaDownload : true ,
296+ useMediaDownloadService : true ,
297+ parameters : {
298+ fileId : { location : "path" , required : true , type : "string" } ,
299+ mimeType : { location : "query" , required : true , type : "string" } ,
300+ } ,
301+ } ,
302+ } ,
303+ } ,
304+ } ,
305+ schemas : { } ,
306+ } ) ,
307+ } ) ;
308+
309+ const spec = decodeConvertedSpec ( result . specText ) ;
310+ const operation = spec . paths [ "/files/{fileId}/export" ] ?. get ;
311+ expect ( operation ?. responses ) . toMatchObject ( {
312+ "200" : {
313+ content : {
314+ "application/octet-stream" : {
315+ schema : { type : "string" , format : "binary" } ,
316+ } ,
317+ } ,
318+ } ,
319+ } ) ;
320+
321+ const parsed = yield * parse ( result . specText ) ;
322+ const extracted = yield * extract ( parsed ) ;
323+ const exportOperation = extracted . operations . find (
324+ ( candidate ) => candidate . operationId === "files.export" ,
325+ ) ;
326+ expect ( exportOperation ?. operationId ) . toBe ( "files.export" ) ;
327+ const responseFileHint = Option . flatMap (
328+ exportOperation ?. responseBody ?? Option . none ( ) ,
329+ ( body ) => body . fileHint ,
330+ ) ;
331+ expect ( Option . isSome ( responseFileHint ) ) . toBe ( true ) ;
332+ } ) ,
333+ ) ;
334+
277335it . effect ( "bundles Google Discovery documents into one Google OpenAPI source" , ( ) =>
278336 Effect . gen ( function * ( ) {
279337 const result = yield * convertGoogleDiscoveryBundleToOpenApi ( {
0 commit comments