Browse Source

dynamite: Rename raw response class to make it public

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

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

@ -157,7 +157,7 @@ class OpenAPIBuilder implements Builder {
).accept(emitter).toString(), ).accept(emitter).toString(),
Class( Class(
(final b) => b (final b) => b
..name = '_Response' ..name = 'RawResponse'
..fields.addAll([ ..fields.addAll([
Field( Field(
(final b) => b (final b) => b
@ -200,7 +200,7 @@ class OpenAPIBuilder implements Builder {
..annotations.add(refer('override')) ..annotations.add(refer('override'))
..lambda = true ..lambda = true
..body = const Code( ..body = const Code(
r"'_Response(statusCode: $statusCode, headers: $headers, body: ${utf8.decode(body)})'", r"'RawResponse(statusCode: $statusCode, headers: $headers, body: ${utf8.decode(body)})'",
), ),
), ),
), ),
@ -208,7 +208,7 @@ class OpenAPIBuilder implements Builder {
Class( Class(
(final b) => b (final b) => b
..name = '${prefix}ApiException' ..name = '${prefix}ApiException'
..extend = refer('_Response') ..extend = refer('RawResponse')
..implements.add(refer('Exception')) ..implements.add(refer('Exception'))
..constructors.addAll( ..constructors.addAll(
[ [
@ -233,7 +233,7 @@ class OpenAPIBuilder implements Builder {
Parameter( Parameter(
(final b) => b (final b) => b
..name = 'response' ..name = 'response'
..type = refer('_Response'), ..type = refer('RawResponse'),
), ),
) )
..body = Code('${prefix}ApiException(response.statusCode, response.headers, response.body,)'), ..body = Code('${prefix}ApiException(response.statusCode, response.headers, response.body,)'),
@ -530,7 +530,7 @@ class OpenAPIBuilder implements Builder {
Method( Method(
(final b) => b (final b) => b
..name = 'doRequest' ..name = 'doRequest'
..returns = refer('Future<_Response>') ..returns = refer('Future<RawResponse>')
..modifier = MethodModifier.async ..modifier = MethodModifier.async
..requiredParameters.addAll([ ..requiredParameters.addAll([
Parameter( Parameter(
@ -575,7 +575,7 @@ class OpenAPIBuilder implements Builder {
response.headers.forEach((final name, final values) { response.headers.forEach((final name, final values) {
responseHeaders[name] = values.last; responseHeaders[name] = values.last;
}); });
return _Response( return RawResponse(
response.statusCode, response.statusCode,
responseHeaders, responseHeaders,
await response.bodyBytes, await response.bodyBytes,

Loading…
Cancel
Save