@@ -397,7 +397,7 @@ public void generateServiceHandlerFactory(GenerationContext context) {
397
397
generateServiceMux (context );
398
398
writer .addImport ("ServiceException" , "__ServiceException" , "@aws-smithy/server-common" );
399
399
writer .openBlock ("const serFn: (op: $1T) => __OperationSerializer<$2T<Context>, $1T, __ServiceException> = "
400
- + "(op) => {" , "};" , operationsSymbol , serviceSymbol , () -> {
400
+ + "(op) => {" , "};" , operationsSymbol , serviceSymbol , () -> {
401
401
writer .openBlock ("switch (op) {" , "}" , () -> {
402
402
operations .stream ()
403
403
.filter (o -> o .getTrait (HttpTrait .class ).isPresent ())
@@ -440,12 +440,12 @@ public void generateOperationHandlerFactory(GenerationContext context, Operation
440
440
441
441
if (context .getSettings ().isDisableDefaultValidation ()) {
442
442
writer .write ("export const get$L = <Context>(operation: __Operation<$T, $T, Context>, "
443
- + "customizer: __ValidationCustomizer<$S>): "
444
- + "__ServiceHandler<Context, __HttpRequest, __HttpResponse> => {" ,
443
+ + "customizer: __ValidationCustomizer<$S>): "
444
+ + "__ServiceHandler<Context, __HttpRequest, __HttpResponse> => {" ,
445
445
operationHandlerSymbol .getName (), inputType , outputType , operationSymbol .getName ());
446
446
} else {
447
447
writer .write ("export const get$L = <Context>(operation: __Operation<$T, $T, Context>): "
448
- + "__ServiceHandler<Context, __HttpRequest, __HttpResponse> => {" ,
448
+ + "__ServiceHandler<Context, __HttpRequest, __HttpResponse> => {" ,
449
449
operationHandlerSymbol .getName (), inputType , outputType );
450
450
}
451
451
writer .indent ();
@@ -642,19 +642,25 @@ private void generateOperationRequestSerializer(
642
642
// Ensure that the request type is imported.
643
643
writer .addUseImports (requestType );
644
644
writer .addImport ("Endpoint" , "__Endpoint" , "@aws-sdk/types" );
645
+
646
+ // e.g., se_ES
647
+ String methodName = ProtocolGenerator .getSerFunctionShortName (symbol );
645
648
// e.g., serializeAws_restJson1_1ExecuteStatement
646
- String methodName = ProtocolGenerator .getSerFunctionName (symbol , getName ());
649
+ String methodLongName = ProtocolGenerator .getSerFunctionName (symbol , getName ());
650
+
647
651
// Add the normalized input type.
648
652
Symbol inputType = symbol .expectProperty ("inputType" , Symbol .class );
649
653
String contextType = CodegenUtils .getOperationSerializerContextType (writer , context .getModel (), operation );
650
654
655
+ writer .writeDocs (methodLongName );
651
656
writer .openBlock ("export const $L = async(\n "
652
657
+ " input: $T,\n "
653
658
+ " context: $L\n "
654
659
+ "): Promise<$T> => {" , "}" , methodName , inputType , contextType , requestType , () -> {
655
660
656
- // Get the hostname, path, port, and scheme from client's resolved endpoint. Then construct the request from
657
- // them. The client's resolved endpoint can be default one or supplied by users.
661
+ // Get the hostname, path, port, and scheme from client's resolved endpoint.
662
+ // Then construct the request from them. The client's resolved endpoint can
663
+ // be default one or supplied by users.
658
664
writer .write ("const {hostname, protocol = $S, port, path: basePath} = await context.endpoint();" , "https" );
659
665
660
666
writeRequestHeaders (context , operation , bindingIndex );
@@ -777,12 +783,12 @@ private void writeResolvedPath(
777
783
Shape target = model .expectShape (binding .getMember ().getTarget ());
778
784
779
785
String labelValueProvider = "() => " + getInputValue (
780
- context ,
781
- binding .getLocation (),
782
- "input." + memberName + "!" ,
783
- binding .getMember (),
784
- target
785
- );
786
+ context ,
787
+ binding .getLocation (),
788
+ "input." + memberName + "!" ,
789
+ binding .getMember (),
790
+ target
791
+ );
786
792
787
793
// Get the correct label to use.
788
794
Segment uriLabel = uriLabels .stream ().filter (s -> s .getContent ().equals (memberName )).findFirst ().get ();
@@ -1342,7 +1348,7 @@ private String getNamedMembersInputParam(
1342
1348
switch (bindingType ) {
1343
1349
case PAYLOAD :
1344
1350
Symbol symbol = context .getSymbolProvider ().toSymbol (target );
1345
- return ProtocolGenerator .getSerFunctionName (symbol , context . getProtocolName () )
1351
+ return ProtocolGenerator .getSerFunctionShortName (symbol )
1346
1352
+ "(" + dataSource + ", context)" ;
1347
1353
default :
1348
1354
throw new CodegenException ("Unexpected named member shape binding location `" + bindingType + "`" );
@@ -1887,17 +1893,18 @@ private void readDirectQueryBindings(GenerationContext context, List<HttpBinding
1887
1893
"@aws-smithy/server-common" );
1888
1894
writer .write ("let queryValue: string;" );
1889
1895
writer .openBlock ("if (Array.isArray(query[$S])) {" , "}" ,
1890
- binding .getLocationName (),
1891
- () -> {
1892
- writer .openBlock ("if (query[$S].length === 1) {" , "}" ,
1893
- binding .getLocationName (),
1894
- () -> {
1895
- writer .write ("queryValue = query[$S][0];" , binding .getLocationName ());
1896
- });
1897
- writer . openBlock ( "else {" , "}" , () -> {
1898
- writer .write ( "throw new __SerializationException();" );
1899
- } );
1896
+ binding .getLocationName (),
1897
+ () -> {
1898
+ writer .openBlock ("if (query[$S].length === 1) {" , "}" ,
1899
+ binding .getLocationName (),
1900
+ () -> {
1901
+ writer .write ("queryValue = query[$S][0];" , binding .getLocationName ());
1902
+ }
1903
+ );
1904
+ writer .openBlock ( "else {" , "}" , () -> {
1905
+ writer . write ( "throw new __SerializationException();" );
1900
1906
});
1907
+ });
1901
1908
writer .openBlock ("else {" , "}" , () -> {
1902
1909
writer .write ("queryValue = query[$S] as string;" , binding .getLocationName ());
1903
1910
});
@@ -2052,18 +2059,21 @@ private void generateOperationResponseDeserializer(
2052
2059
// Ensure that the response type is imported.
2053
2060
writer .addUseImports (responseType );
2054
2061
// e.g., deserializeAws_restJson1_1ExecuteStatement
2055
- String methodName = ProtocolGenerator .getDeserFunctionName (symbol , getName ());
2062
+ String methodName = ProtocolGenerator .getDeserFunctionShortName (symbol );
2063
+ String methodLongName = ProtocolGenerator .getDeserFunctionName (symbol , getName ());
2056
2064
String errorMethodName = methodName + "Error" ;
2057
2065
// Add the normalized output type.
2058
2066
Symbol outputType = symbol .expectProperty ("outputType" , Symbol .class );
2059
2067
String contextType = CodegenUtils .getOperationDeserializerContextType (context .getSettings (), writer ,
2060
2068
context .getModel (), operation );
2061
2069
2062
2070
// Handle the general response.
2071
+ writer .writeDocs (methodLongName );
2063
2072
writer .openBlock ("export const $L = async(\n "
2064
2073
+ " output: $T,\n "
2065
2074
+ " context: $L\n "
2066
- + "): Promise<$T> => {" , "}" , methodName , responseType , contextType , outputType , () -> {
2075
+ + "): Promise<$T> => {" , "}" ,
2076
+ methodName , responseType , contextType , outputType , () -> {
2067
2077
// Redirect error deserialization to the dispatcher if we receive an error range
2068
2078
// status code that's not the modeled code (300 or higher). This allows for
2069
2079
// returning other 2XX codes that don't match the defined value.
@@ -2103,10 +2113,13 @@ private void generateErrorDeserializer(GenerationContext context, StructureShape
2103
2113
HttpBindingIndex bindingIndex = HttpBindingIndex .of (context .getModel ());
2104
2114
Model model = context .getModel ();
2105
2115
Symbol errorSymbol = symbolProvider .toSymbol (error );
2106
- String errorDeserMethodName = ProtocolGenerator .getDeserFunctionName (errorSymbol ,
2107
- context .getProtocolName ()) + "Response" ;
2116
+ String errorDeserMethodName = ProtocolGenerator .getDeserFunctionShortName (errorSymbol ) + "Res" ;
2117
+ String errorDeserMethodLongName = ProtocolGenerator .getDeserFunctionName (errorSymbol , context .getProtocolName ())
2118
+ + "Res" ;
2119
+
2108
2120
String outputName = isErrorCodeInBody ? "parsedOutput" : "output" ;
2109
2121
2122
+ writer .writeDocs (errorDeserMethodLongName );
2110
2123
writer .openBlock ("const $L = async (\n "
2111
2124
+ " $L: any,\n "
2112
2125
+ " context: __SerdeContext\n "
@@ -2661,8 +2674,8 @@ private String getNamedMembersOutputParam(
2661
2674
case PAYLOAD :
2662
2675
// Redirect to a deserialization function.
2663
2676
Symbol symbol = context .getSymbolProvider ().toSymbol (target );
2664
- return ProtocolGenerator .getDeserFunctionName (symbol , context . getProtocolName () )
2665
- + "(" + dataSource + ", context)" ;
2677
+ return ProtocolGenerator .getDeserFunctionShortName (symbol )
2678
+ + "(" + dataSource + ", context)" ;
2666
2679
default :
2667
2680
throw new CodegenException ("Unexpected named member shape binding location `" + bindingType + "`" );
2668
2681
}
0 commit comments