diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java index c21e4e437e3..8b4a5503db5 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java @@ -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 -> { @@ -1143,8 +1143,8 @@ 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. @@ -1152,7 +1152,7 @@ private boolean shouldWriteDefaultBody(GenerationContext context, Shape operatio * @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); } /**