Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ private void generateOperationSerializer(
Symbol inputType = symbol.expectProperty("inputType", Symbol.class);
String contextType = CodegenUtils.getOperationSerializerContextType(writer, context.getModel(), operation);

writer.openBlock("export async function $L(\n"
writer.openBlock("export const $L = async(\n"
+ " input: $T,\n"
+ " context: $L\n"
+ "): Promise<$T> {", "}", methodName, inputType, contextType, requestType, () -> {
+ "): Promise<$T> => {", "}", methodName, inputType, contextType, requestType, () -> {
writeHeaders(context, operation, bindingIndex);
writeResolvedPath(context, operation, bindingIndex, trait);
boolean hasQueryComponents = writeRequestQueryString(context, operation, bindingIndex, trait);
Expand Down Expand Up @@ -847,10 +847,10 @@ private void generateOperationDeserializer(
String contextType = CodegenUtils.getOperationDeserializerContextType(writer, context.getModel(), operation);

// Handle the general response.
writer.openBlock("export async function $L(\n"
writer.openBlock("export const $L = async(\n"
+ " output: $T,\n"
+ " context: $L\n"
+ "): Promise<$T> {", "}", methodName, responseType, contextType, outputType, () -> {
+ "): Promise<$T> => {", "}", methodName, responseType, contextType, outputType, () -> {
// Redirect error deserialization to the dispatcher if we receive an error range
// status code that's not the modeled code (400 or higher). This allows for
// returning other 2XX or 3XX codes that don't match the defined value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ static Set<StructureShape> generateErrorDispatcher(
Symbol outputType = symbol.expectProperty("outputType", Symbol.class);
String errorMethodName = ProtocolGenerator.getDeserFunctionName(symbol, context.getProtocolName()) + "Error";

writer.openBlock("async function $L(\n"
writer.openBlock("const $L = async(\n"
+ " output: $T,\n"
+ " context: __SerdeContext,\n"
+ "): Promise<$T> {", "}", errorMethodName, responseType, outputType, () -> {
+ "): Promise<$T> => {", "}", errorMethodName, responseType, outputType, () -> {
// Prepare error response for parsing error code. If error code needs to be parsed from response body
// then we collect body and parse it to JS object, otherwise leave the response body as is.
if (shouldParseErrorBody) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ private void generateOperationSerializer(GenerationContext context, OperationSha
// Add the normalized input type.
Symbol inputType = symbol.expectProperty("inputType", Symbol.class);

writer.openBlock("export async function $L(\n"
writer.openBlock("export const $L = async(\n"
+ " input: $T,\n"
+ " context: __SerdeContext\n"
+ "): Promise<$T> {", "}", methodName, inputType, requestType, () -> {
+ "): Promise<$T> => {", "}", methodName, inputType, requestType, () -> {
writeRequestHeaders(context, operation);
boolean hasRequestBody = writeRequestBody(context, operation);
boolean hasHostPrefix = operation.hasTrait(EndpointTrait.class);
Expand Down Expand Up @@ -313,10 +313,10 @@ private void generateOperationDeserializer(GenerationContext context, OperationS
Symbol outputType = symbol.expectProperty("outputType", Symbol.class);

// Handle the general response.
writer.openBlock("export async function $L(\n"
writer.openBlock("export const $L = async(\n"
+ " output: $T,\n"
+ " context: __SerdeContext\n"
+ "): Promise<$T> {", "}", methodName, responseType, outputType, () -> {
+ "): Promise<$T> => {", "}", methodName, responseType, outputType, () -> {
// Redirect error deserialization to the dispatcher
writer.openBlock("if (output.statusCode >= 400) {", "}", () -> {
writer.write("return $L(output, context);", errorMethodName);
Expand Down