Skip to content

Commit

Permalink
Make endpoints which don't return anything yield NoContent
Browse files Browse the repository at this point in the history
Relevant issue: OpenAPITools#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#9830

which resolved a similar issue for that generator.
  • Loading branch information
ivanbakel committed Jul 8, 2021
1 parent 7084a79 commit f4596f1
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ")";
Expand Down

0 comments on commit f4596f1

Please sign in to comment.