Fix issue #7262 with the parameter name in the path. The problem was that camelCase naming was forced only in this part of the code when everywhere else it is configurable. (#7313)

This commit is contained in:
Jean-François Côté 2018-01-06 21:33:46 -05:00 committed by William Cheng
parent 6c2a583bcd
commit 0a9c6f56c8
6 changed files with 11 additions and 24 deletions

View File

@ -1,7 +1,6 @@
package io.swagger.codegen.languages; package io.swagger.codegen.languages;
import java.io.File; import java.io.File;
import java.lang.StringBuffer;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -258,11 +257,9 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
} }
// Prep a string buffer where we're going to set up our new version of the string. // Prep a string buffer where we're going to set up our new version of the string.
StringBuffer pathBuffer = new StringBuffer(); StringBuilder pathBuffer = new StringBuilder();
StringBuilder parameterName = new StringBuilder();
// Set up other variables for tracking the current state of the string.
int insideCurly = 0; int insideCurly = 0;
boolean foundUnderscore = false;
// Iterate through existing string, one character at a time. // Iterate through existing string, one character at a time.
for (int i = 0; i < op.path.length(); i++) { for (int i = 0; i < op.path.length(); i++) {
@ -279,23 +276,13 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
insideCurly--; insideCurly--;
// Add the more complicated component instead of just the brace. // Add the more complicated component instead of just the brace.
pathBuffer.append(toVarName(parameterName.toString()));
pathBuffer.append("))}"); pathBuffer.append("))}");
break; parameterName.setLength(0);
case '_':
// If we're inside the curly brace, the following character will need to be uppercase.
// Otherwise, just add the character.
if (insideCurly > 0) {
foundUnderscore = true;
} else {
pathBuffer.append(op.path.charAt(i));
}
break; break;
default: default:
// If we previously found an underscore, we need an uppercase letter. if (insideCurly > 0) {
// Otherwise, just add the character. parameterName.append(op.path.charAt(i));
if (foundUnderscore) {
pathBuffer.append(Character.toUpperCase(op.path.charAt(i)));
foundUnderscore = false;
} else { } else {
pathBuffer.append(op.path.charAt(i)); pathBuffer.append(op.path.charAt(i));
} }