Skip to content

Commit dddbe3c

Browse files
authored
Fix logic for deciding whether to write a default input body (#1304)
1 parent aec00b0 commit dddbe3c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ private void writeContentTypeHeader(GenerationContext context, Shape operationOr
10961096
optionalContentType = bindingIndex.determineResponseContentType(operationOrError, getDocumentContentType());
10971097
}
10981098
// If we need to write a default body then it needs a content type.
1099-
if (!optionalContentType.isPresent() && shouldWriteDefaultBody(context, operationOrError, isInput)) {
1099+
if (optionalContentType.isEmpty() && shouldWriteDefaultBody(context, operationOrError, isInput)) {
11001100
optionalContentType = Optional.of(getDocumentContentType());
11011101
}
11021102
optionalContentType.ifPresent(contentType -> {
@@ -1143,16 +1143,16 @@ private boolean shouldWriteDefaultBody(GenerationContext context, Shape operatio
11431143
}
11441144

11451145
/**
1146-
* Given a context and operation, should a default input body be written. By default no body will be written
1147-
* if there are no members bound to the input.
1146+
* Given a context and operation, should a default input body be written. By default, a body
1147+
* will be written if and only if there are payload members bound to the input.
11481148
*
11491149
* @param context The generation context.
11501150
* @param operation The operation whose input is being serialized.
11511151
*
11521152
* @return True if a default body should be generated.
11531153
*/
11541154
protected boolean shouldWriteDefaultInputBody(GenerationContext context, OperationShape operation) {
1155-
return HttpBindingIndex.of(context.getModel()).getRequestBindings(operation).isEmpty();
1155+
return HttpBindingIndex.of(context.getModel()).hasRequestBody(operation);
11561156
}
11571157

11581158
/**

0 commit comments

Comments
 (0)