From f4596f1211b35148cc07e63fc621199375f82b81 Mon Sep 17 00:00:00 2001 From: Isaac van Bakel Date: Thu, 8 Jul 2021 12:13:58 +0100 Subject: [PATCH] Make endpoints which don't return anything yield NoContent Relevant issue: OpenAPITools/openapi-generator#9901 The haskell-http-client generator tries to generate a polymorphic return type for endpoints which don't return anything in the success case, but still produce content in other cases. This means that these endpoints hit a decoding error in the success case, because there is no content to decode. This changes the behaviour so that endpoints that don't return anything are *always* generated as returning NoContent, and never try to decode the response. This change is based on a similar one for the haskell-servant generator, which can be found at: OpenAPITools/openapi-generator#9830 which resolved a similar issue for that generator. --- .../codegen/languages/HaskellHttpClientCodegen.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index 497634d1d9f5..f1978e172015 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -879,15 +879,8 @@ public boolean isDataTypeBinary(final String dataType) { private void processReturnType(CodegenOperation op) { String returnType = op.returnType; if (returnType == null || returnType.equals("null")) { - if (op.hasProduces) { - returnType = "res"; - op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_UNKNOWN_RETURN, true); - } else { - returnType = "NoContent"; - if (!op.vendorExtensions.containsKey(VENDOR_EXTENSION_X_INLINE_ACCEPT)) { - SetNoContent(op, VENDOR_EXTENSION_X_INLINE_ACCEPT); - } - } + returnType = "NoContent"; + SetNoContent(op, VENDOR_EXTENSION_X_INLINE_ACCEPT); } if (returnType.contains(" ")) { returnType = "(" + returnType + ")";