Open dlabs-matic-leva opened 2 weeks ago
I'd like to consume endpoint that generates .pdf file. This is OpenAPI schema for such endpoint:
"/api/transfers/export.pdf": { "get": { "operationId": "exportPdf", "summary": "", "parameters": [ { "name": "filter", "required": false, "in": "query", "style": "deepObject", "explode": true, "schema": { "$ref": "#/components/schemas/ExportTransfersFilters" } } ], "responses": { "200": { "content": { "application/octet-stream": { "schema": { "type": "string", "format": "binary" } } }, "description": "" } }, "tags": [ "Transfers" ], "security": [ { "oauth2": [ ] } ] } },
Currently swagger_parser generates such method:
@GET('/api/transfers/export.pdf') Future<String> exportPdf({ @Query('filter') ExportTransfersFilters? filter, });
which in turn generates Dio.fetch call with ResponseType == ResponseType.json. In case of PDF, this yields corrupted file.
ResponseType == ResponseType.json
Such Retrofit definition will generate correct Dio.fetch call:
@GET('/api/transfers/export.pdf') @DioResponseType(ResponseType.bytes) Future<HttpResponse> exportPdf({ @Query('filter') ExportTransfersFilters? filter, });
Use case
I'd like to consume endpoint that generates .pdf file. This is OpenAPI schema for such endpoint:
Currently swagger_parser generates such method:
which in turn generates Dio.fetch call with
ResponseType == ResponseType.json
. In case of PDF, this yields corrupted file.Proposal
Such Retrofit definition will generate correct Dio.fetch call: