From b63536f99b029f3d20c8c5a797798fb644f7f597 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Thu, 23 Mar 2023 06:57:35 +0100 Subject: [PATCH] dynamite: Output accept header --- packages/dynamite/lib/src/openapi_builder.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index 1c605fff..c0292baf 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -584,10 +584,20 @@ class OpenAPIBuilder implements Builder { ..._descriptionToDocs(operation.description), ]); + final acceptHeader = operation.responses?.values + .map((final response) => response.content?.keys) + .reduce( + (final a, final b) => [ + ...a ?? [], + ...b ?? [], + ], + ) + ?.toSet() + .join(','); final code = StringBuffer(''' var path = '$path'; final queryParameters = {}; - final headers = {}; + final headers = {${acceptHeader != null ? "'Accept': '$acceptHeader'," : ''}}; Uint8List? body; ''');