Skip to content

Commit

Permalink
Merge 57b238d into a4720c6
Browse files Browse the repository at this point in the history
  • Loading branch information
acsukesh committed Jan 5, 2018
2 parents a4720c6 + 57b238d commit fbfd427
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.lang.model.SourceVersion;

import org.springframework.util.ClassUtils;

import com.fasterxml.jackson.databind.JavaType;
Expand Down Expand Up @@ -147,7 +149,7 @@ public static WrapSchema getOrCreateArgsSchema(OperationMeta operationMeta) {
Parameter[] params = method.getParameters();
for (int idx = 0; idx < params.length; idx++) {
Parameter param = params[idx];
String paramName = operationMeta.getParamName(idx);
String paramName = getValidParamName(operationMeta.getParamName(idx));

config.addField(paramName, param.getParameterizedType());
}
Expand All @@ -157,4 +159,17 @@ public static WrapSchema getOrCreateArgsSchema(OperationMeta operationMeta) {
return createWrapSchema(config);
});
}

private static String getValidParamName(String paramName) {
if (SourceVersion.isName(paramName)) {
return paramName;
}
StringBuffer newParam = new StringBuffer();
for (int index = 0; index < paramName.length(); index++) {
if (Character.isJavaIdentifierPart(paramName.charAt(index))) {
newParam.append(paramName.charAt(index));
}
}
return newParam.toString();
}
}

0 comments on commit fbfd427

Please sign in to comment.