Skip to content
Permalink
Browse files

query params - using parameter.reqParamName instead of parameter.name…

… as most of the time, this field should prevail over the variable name in resource.

This fixes query/path param mapping errors when annotation value for param name was different than Java variable value used (Java variable name was used instead of annotation name)
  • Loading branch information...
fcamblor committed Sep 1, 2017
1 parent b2d04b5 commit 55226db6e793f310f12f7befa77c14cb5edd6340
@@ -53,7 +53,7 @@ public ParameterExpressionBuilder surroundWithCheckValid(
"checkNotNull(%s, \"%s param <%s> is required\")",
this.parameterExpr,
this.kind,
parameter.name
parameter.reqParamName
);
}
}
@@ -306,11 +306,11 @@ private void buildResourceRoutesCodeChunks(ResourceClass resourceClass, List<Imm
} else if (kind == ResourceMethodParameterKind.BODY) {
inEntityClass = parameter.type;
}
callParameters.add(String.format("/* [%s] %s */ %s", kind, parameter.name, kind.fetchFromReqCode(parameter, resourceMethod)));
callParameters.add(String.format("/* [%s] %s */ %s", kind, parameter.reqParamName, kind.fetchFromReqCode(parameter, resourceMethod)));

if(kind.resolvedWithQueryParamMapper()) {
queryParametersDefinition.add(String.format(" ParamDef.of(%s, \"%s\")",
TypeHelper.getTypeReferenceExpressionFor(parameter.type), parameter.name));
TypeHelper.getTypeReferenceExpressionFor(parameter.type), parameter.reqParamName));
}

if (kind != ResourceMethodParameterKind.CONTEXT) {
@@ -322,7 +322,7 @@ private void buildResourceRoutesCodeChunks(ResourceClass resourceClass, List<Imm
" {PARAMETER}.schemaKey = \"%s\";\n" +
" {PARAMETER}.required = %s;\n" +
" operation.parameters.add({PARAMETER});\n",
parameter.name,
parameter.reqParamName,
kind.name().toLowerCase(),
toTypeDescription(parameter.type),
toSchemaKey(parameter.type),

0 comments on commit 55226db

Please sign in to comment.
You can’t perform that action at this time.