Skip to content

Commit

Permalink
Fix logic for deciding whether to write a default input body (#1304)
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenbaker authored Jun 17, 2024
1 parent aec00b0 commit dddbe3c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ private void writeContentTypeHeader(GenerationContext context, Shape operationOr
optionalContentType = bindingIndex.determineResponseContentType(operationOrError, getDocumentContentType());
}
// If we need to write a default body then it needs a content type.
if (!optionalContentType.isPresent() && shouldWriteDefaultBody(context, operationOrError, isInput)) {
if (optionalContentType.isEmpty() && shouldWriteDefaultBody(context, operationOrError, isInput)) {
optionalContentType = Optional.of(getDocumentContentType());
}
optionalContentType.ifPresent(contentType -> {
Expand Down Expand Up @@ -1143,16 +1143,16 @@ private boolean shouldWriteDefaultBody(GenerationContext context, Shape operatio
}

/**
* Given a context and operation, should a default input body be written. By default no body will be written
* if there are no members bound to the input.
* Given a context and operation, should a default input body be written. By default, a body
* will be written if and only if there are payload members bound to the input.
*
* @param context The generation context.
* @param operation The operation whose input is being serialized.
*
* @return True if a default body should be generated.
*/
protected boolean shouldWriteDefaultInputBody(GenerationContext context, OperationShape operation) {
return HttpBindingIndex.of(context.getModel()).getRequestBindings(operation).isEmpty();
return HttpBindingIndex.of(context.getModel()).hasRequestBody(operation);
}

/**
Expand Down

0 comments on commit dddbe3c

Please sign in to comment.