normalize_identifier(tag) clobbers acronyms in module names
feynmanliang opened this issue · 1 comments
cbaf0ce#diff-dd87d6a5f9e67976199e9a1bf044c7785e0dc97d4045794df4585b96e1808090L78-R81 changes how tags are normalized between version 0.0.3 and 0.0.4 in a backwards incompatible manner.
Expected behavior: When the actual tag is "OpenAI", I expect the camelized tag to be "OpenAI".
Actual behavior: After cbaf0ce, the camelized tag becomes "OpenAi".
A minimal repro:
Before:
iex(4)> "OpenAI" |> String.replace(~r|[-/ ]+|, "_") |> Macro.camelize()
"OpenAI"
After:
iex(3)> "OpenAI" |> OpenAPI.Generator.Operation.normalize_identifier() |> Macro.camelize()
"OpenAi"
Since the tag is used for module names (
) and elixir convention is to use CamelCase for these:Aliases, commonly used as module names, are an exception as they must be capitalized and written in CamelCase, like OptionParser.
one possible resolution could be to avoid downcase
ing tag names in normalize_identifier
so that the trailing "I" in "OpenAI"'s case is preserved
From reading https://hexdocs.pm/elixir/1.12/Macro.html#camelize/1
If uppercase characters are present, they are not modified in any way as a mechanism to preserve acronyms:
It seems like the RC is that we are downcase
ing the module names and clobbering acronyms. I'll send a PR to preserve acronyms in module names.