Skip to content

Commit 67c733a

Browse files
committed
Allow RPC protocols to set the body without input
1 parent fdfccfa commit 67c733a

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private boolean writeRequestBody(GenerationContext context, OperationShape opera
208208
return true;
209209
}
210210

211-
return false;
211+
return writeUndefinedInputBody(context, operation);
212212
}
213213

214214
/**
@@ -266,6 +266,32 @@ protected abstract void serializeInputDocument(
266266
StructureShape inputStructure
267267
);
268268

269+
/**
270+
* Writes any default body contents when an operation has an undefined input.
271+
*
272+
* <p>Implementations of this method are expected to set a value to the
273+
* {@code body} variable that will be serialized as the request body.
274+
* This variable will NOT be defined in scope and should be defined by
275+
* implementations if they wish to set it.
276+
*
277+
* <p>For example:
278+
*
279+
* <pre>{@code
280+
* const body = "{}";
281+
* }</pre>
282+
*
283+
* <p>Implementations should return true if they define a body variable, and
284+
* false otherwise.
285+
*
286+
* @param context The generation context.
287+
* @param operation The operation being generated.
288+
* @return If a body variable was defined.
289+
*/
290+
protected boolean writeUndefinedInputBody(GenerationContext context, OperationShape operation) {
291+
// Pass
292+
return false;
293+
}
294+
269295
private void generateOperationDeserializer(GenerationContext context, OperationShape operation) {
270296
SymbolProvider symbolProvider = context.getSymbolProvider();
271297
Symbol symbol = symbolProvider.toSymbol(operation);

0 commit comments

Comments
 (0)