Skip to content

Commit

Permalink
add mapping options to zapier client generator (#16785)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Oct 11, 2023
1 parent 384ff94 commit 015f000
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ protected void initializeSpecialCharacterMapping() {
*/
@Override
public String toParamName(String name) {
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}

if (reservedWords.contains(name)) {
return escapeReservedWord(name);
} else if (((CharSequence) name).chars().anyMatch(character -> specialCharReplacements.keySet().contains(String.valueOf((char) character)))) {
Expand All @@ -127,6 +132,11 @@ public String toParamName(String name) {

@Override
public String toModelName(final String name) {
// obtain the name from modelNameMapping directly if provided
if (modelNameMapping.containsKey(name)) {
return modelNameMapping.get(name);
}

return name;
}

Expand Down Expand Up @@ -183,7 +193,7 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
CodegenResponse r = super.fromResponse(responseCode, response);
try {
Map<String, Map<String, Map<String, Object>>> map = Json.mapper().readerFor(Map.class).readValue(Json.pretty(response.getContent()));
Map.Entry<String, Map<String, Map<String, Object>>> entry = map.entrySet().stream().findFirst().orElseThrow(()-> new IllegalStateException("no response object available"));
Map.Entry<String, Map<String, Map<String, Object>>> entry = map.entrySet().stream().findFirst().orElseThrow(() -> new IllegalStateException("no response object available"));
Map<String, Map<String, Object>> example = entry.getValue();
r.examples = toExamples(example.get("examples"));
} catch (Exception e) {
Expand Down

0 comments on commit 015f000

Please sign in to comment.