Skip to content

Commit

Permalink
[haskell-http-client] Support --name-mappings and handle _ name (#18943
Browse files Browse the repository at this point in the history
…) (#18944)

* [haskell-http-client] Support --name-mappings and handle _ name (#18943)

Fixes #18943

* [haskell-http-client] Add missing TypeOperators flag

-Wtype-equality-requires-operators:
    The use of ‘~’ without TypeOperators
    will become an error in a future GHC release.
  • Loading branch information
valpackett committed Jun 19, 2024
1 parent c3a2fe0 commit da57701
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1182,12 +1182,19 @@ private static boolean isMultipartOperation(List<Map<String, String>> consumes)

@Override
public String toVarName(String name) {
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}

return toVarName("", name);
}

public String toVarName(String prefix, String name) {
boolean hasPrefix = !StringUtils.isBlank(prefix);
name = underscore(sanitizeName(name.replaceAll("-", "_")));
if (name.equals("_")) {
name = "underscore";
}
name = camelize(name, hasPrefix ? UPPERCASE_FIRST_CHAR : LOWERCASE_FIRST_LETTER);

if (hasPrefix) {
Expand All @@ -1203,6 +1210,10 @@ public String toVarName(String prefix, String name) {

@Override
public String toParamName(String name) {
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}

return toVarName(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Module : {{baseModule}}.Core
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Module : OpenAPIPetstore.Core
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}

Expand Down

0 comments on commit da57701

Please sign in to comment.