From 798c3e196095389221c1970896c6c29c5e6827bc Mon Sep 17 00:00:00 2001 From: jld3103 Date: Tue, 3 Oct 2023 20:24:22 +0200 Subject: [PATCH] feat(dynamite): Support default responses Signed-off-by: jld3103 --- .../dynamite/lib/src/builder/client.dart | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/dynamite/dynamite/lib/src/builder/client.dart b/packages/dynamite/dynamite/lib/src/builder/client.dart index 51e5bf5e..f7c6f962 100644 --- a/packages/dynamite/dynamite/lib/src/builder/client.dart +++ b/packages/dynamite/dynamite/lib/src/builder/client.dart @@ -190,14 +190,10 @@ Iterable buildTags( ]..sort(sortRequiredParameters); final name = toDartName(filterMethodName(operationName, tag ?? '')); - var responses = >{}; + var responses = >{}; if (operation.responses != null) { for (final responseEntry in operation.responses!.entries) { - final statusCode = int.tryParse(responseEntry.key); - if (statusCode == null) { - print('Default responses are not supported right now. Skipping it for $operationName'); - continue; - } + final statusCode = responseEntry.key; final response = responseEntry.value; responses[response] ??= []; @@ -225,7 +221,6 @@ Iterable buildTags( '''); buildAuthCheck( - responses, pathEntry, operation, spec, @@ -357,8 +352,12 @@ final _uri = Uri(path: _path, queryParameters: _queryParameters.isNotEmpty ? _qu '''); if (responses.values.isNotEmpty) { - final codes = statusCodes.join(','); - code.writeln('const {$codes},'); + if (statusCodes.contains('default')) { + code.writeln('null,'); + } else { + final codes = statusCodes.join(','); + code.writeln('const {$codes},'); + } } code.writeln(''' @@ -478,7 +477,6 @@ Iterable buildPatternCheck( } Iterable buildAuthCheck( - final Map> responses, final MapEntry pathEntry, final openapi.Operation operation, final openapi.OpenAPI spec,