Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R] renaming files to conform to style guide #2142

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public String getHelp() {
public RClientCodegen() {
super();
outputFolder = "generated-code/r";
modelTemplateFiles.put("model.mustache", ".r");
apiTemplateFiles.put("api.mustache", ".r");
modelTemplateFiles.put("model.mustache", ".R");
apiTemplateFiles.put("api.mustache", ".R");

modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
Expand Down Expand Up @@ -149,9 +149,9 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("description.mustache", "", "DESCRIPTION"));
supportingFiles.add(new SupportingFile("Rbuildignore.mustache", "", ".Rbuildignore"));
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
supportingFiles.add(new SupportingFile("response.mustache", File.separator + "R", "Response.r"));
supportingFiles.add(new SupportingFile("element.mustache", File.separator + "R", "Element.r"));
supportingFiles.add(new SupportingFile("api_client.mustache", File.separator + "R", "ApiClient.r"));
supportingFiles.add(new SupportingFile("response.mustache", File.separator + "R", "api_response.R"));
//supportingFiles.add(new SupportingFile("element.mustache", File.separator + "R", "Element.R"));
supportingFiles.add(new SupportingFile("api_client.mustache", File.separator + "R", "api_client.R"));
supportingFiles.add(new SupportingFile("NAMESPACE.mustache", "", "NAMESPACE"));
supportingFiles.add(new SupportingFile("testthat.mustache", "", "testthat.R"));
}
Expand Down Expand Up @@ -214,12 +214,12 @@ public String toParamName(String name) {
}

@Override
public String toModelName(String name) {
return toModelFilename(name);
public String toModelFilename(String name) {
return underscore(toModelName(name));
}

@Override
public String toModelFilename(String name) {
public String toModelName(String name) {
if (!StringUtils.isEmpty(modelNamePrefix)) {
name = modelNamePrefix + "_" + name;
}
Expand Down Expand Up @@ -251,7 +251,7 @@ public String toApiFilename(String name) {
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.

// e.g. PetApi.r => pet_api.r
return camelize(name + "_api");
return underscore(name + "_api");
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions modules/openapi-generator/src/main/resources/r/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@
# void response, no need to return anything
{{/returnType}}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

}{{#hasMore}},{{/hasMore}}
Expand Down
91 changes: 0 additions & 91 deletions samples/client/petstore/R/R/ApiResponse.r

This file was deleted.

24 changes: 0 additions & 24 deletions samples/client/petstore/R/R/Element.r

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
# void response, no need to return anything
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand Down Expand Up @@ -109,9 +109,9 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
# void response, no need to return anything
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand All @@ -135,9 +135,9 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand All @@ -161,9 +161,9 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand All @@ -187,9 +187,9 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
Pet$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand All @@ -215,9 +215,9 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
# void response, no need to return anything
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand Down Expand Up @@ -246,9 +246,9 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
# void response, no need to return anything
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand Down Expand Up @@ -277,9 +277,9 @@ PetApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
ApiResponse$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ StoreApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
# void response, no need to return anything
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand All @@ -87,9 +87,9 @@ StoreApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
integer$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand All @@ -113,9 +113,9 @@ StoreApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
Order$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

},
Expand All @@ -141,9 +141,9 @@ StoreApi <- R6::R6Class(
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
Order$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
ApiResponse$new("API server error", resp)
}

}
Expand Down
Loading