Browse Source

dynamite: Handle more response mime types and in a better way

pull/204/head
jld3103 2 years ago
parent
commit
41b1bef6b0
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 34
      packages/dynamite/lib/src/openapi_builder.dart

34
packages/dynamite/lib/src/openapi_builder.dart

@ -810,25 +810,21 @@ class OpenAPIBuilder implements Builder {
), ),
mediaType.schema!, mediaType.schema!,
); );
switch (mimeType) { if (mimeType == '*/*' || mimeType.startsWith('image/')) {
case 'application/json': dataType = 'Uint8List';
dataType = result.name; dataValue = 'response.body';
if (result.name == 'dynamic') { } else if (mimeType.startsWith('text/')) {
dataValue = ''; dataType = 'String';
} else { dataValue = 'utf8.decode(response.body)';
dataValue = result.deserialize(result.decode('utf8.decode(response.body)')); } else if (mimeType == 'application/json') {
} dataType = result.name;
break; if (result.name == 'dynamic') {
case 'image/png': dataValue = '';
dataType = 'Uint8List'; } else {
dataValue = 'response.body'; dataValue = result.deserialize(result.decode('utf8.decode(response.body)'));
break; }
case 'text/plain': } else {
dataType = 'String'; throw Exception('Can not parse mime type "$mimeType"');
dataValue = 'utf8.decode(response.body)';
break;
default:
throw Exception('Can not parse mime type "$mimeType"');
} }
} }
} }

Loading…
Cancel
Save