Skip to content

Commit

Permalink
Added path param normalization for Rust clients (#20309)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranger-ross authored Dec 14, 2024
1 parent 8aa8e38 commit 3a09ebb
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,20 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
OperationMap objectMap = objs.getOperations();
List<CodegenOperation> operations = objectMap.getOperation();
for (CodegenOperation operation : operations) {
if (operation.pathParams != null && operation.pathParams.size() > 0) {
for (var pathParam : operation.pathParams) {
if (!pathParam.baseName.contains("-")) {
continue;
}

var newName = pathParam.baseName.replace("-", "_");
LOGGER.info(pathParam.baseName + " cannot be used as a path param. Renamed to " + newName);

operation.path = operation.path.replace("{" + pathParam.baseName + "}", "{" + newName + "}");
pathParam.baseName = newName;
}
}

// http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put)
if (HYPER_LIBRARY.equals(getLibrary())) {
operation.httpMethod = StringUtils.camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
Expand Down

0 comments on commit 3a09ebb

Please sign in to comment.