Skip to content

Commit

Permalink
Merge pull request #9 from vickyl1/vickyl1/trim-endpoint-path
Browse files Browse the repository at this point in the history
Trim slashes from endpoint path to prevent duplicate slashes.
  • Loading branch information
ryanmcnamara committed Jan 8, 2016
2 parents 782b2a6 + 254d267 commit 13e604c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.palantir.code.ts.generator.model.ServiceEndpointModel;
import com.palantir.code.ts.generator.model.ServiceEndpointParameterModel;
import com.palantir.code.ts.generator.model.ServiceModel;
import com.palantir.code.ts.generator.utils.PathUtils;

import cz.habarta.typescript.generator.ModelCompiler;
import cz.habarta.typescript.generator.Settings;
Expand Down Expand Up @@ -92,7 +93,7 @@ public void emitTypescriptClass(IndentedOutputWriter classWriter) {
classWriter.writeLine("var httpCallData = <IHttpEndpointOptions> {");
classWriter.increaseIndent();
classWriter.writeLine("serviceIdentifier: \"" + Character.toLowerCase(model.name().charAt(0)) + model.name().substring(1) + "\",");
classWriter.writeLine("endpointPath: \"" + model.servicePath() + "/" + endpointModel.endpointPath() + "\",");
classWriter.writeLine("endpointPath: \"" + getEndpointPathString(model, endpointModel) + "\",");
classWriter.writeLine("method: \"" + endpointModel.endpointMethodType() + "\",");
classWriter.writeLine("mediaType: \"" + endpointModel.endpointMediaType() + "\",");
List<String> requiredHeaders = Lists.newArrayList();
Expand Down Expand Up @@ -154,6 +155,11 @@ public void emitTypescriptInterface(IndentedOutputWriter interfaceWriter) {
interfaceWriter.writeLine("}");
}

private String getEndpointPathString(ServiceModel model, ServiceEndpointModel endpointModel) {
String endpointPath = model.servicePath() + "/" + endpointModel.endpointPath();
return PathUtils.trimSlashes(endpointPath);
}

private String getEndpointParametersString(ServiceEndpointModel endpointModel) {
List<String> parameterStrings = Lists.newArrayList();
for (ServiceEndpointParameterModel parameterModel : endpointModel.parameters()) {
Expand Down

0 comments on commit 13e604c

Please sign in to comment.