Elixir Generator generates code with lots of warnings
Created by: halostatue
Description
When compiling Elixir code generated with openapi-generator
, there are compiler warnings (this is using ory/sdk/clients/client/elixir:
$ mix deps.get
warning: use Mix.Config is deprecated. Use the Config module instead
config/config.exs:3
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
mime 2.0.2
poison 3.1.0
tesla 1.4.4
* Getting tesla (Hex package)
* Getting poison (Hex package)
* Getting mime (Hex package)
There are other warnings:
$ mix compile
…
warning: found quoted atom "namespace" but the quotes are not required. Atoms made exclusively of ASCII letters, numbers, underscores, and optionally ending with ! or ? do not require quotes
lib/ory/api/read.ex:38:7
…
The code in question for the latter (and there are hundreds of these) is
optional_params = %{
:"namespace" => :query,
:"object" => :query,
:"relation" => :query,
:"subject_id" => :query,
:"subject_set.namespace" => :query,
:"subject_set.object" => :query,
:"subject_set.relation" => :query,
:"max-depth" => :query
}
It should be
optional_params = %{
:namespace => :query,
:object => :query,
:relation => :query,
:subject_id => :query,
:"subject_set.namespace" => :query,
:"subject_set.object" => :query,
:"subject_set.relation" => :query,
:"max-depth" => :query
}
The atom issue can be changed to the correct format by the use of mix format
in the target directory, but that requires a .formatter.exs
be created (which should be in every Elixir project at this point):
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
I will be opening at least one issue in the generated repo for some issues that I have seen, but for what I have highlighted here, these are issues in the Elixir generator or its templates (I reviewed the templates before opening this issue).
I’m happy to provide a PR, but I haven’t seriously done Java since JDK 1.1.
Related issues/PRs
- #12484 (closed)
- #4011
-
#10755 (I will have to investigate, but this can probably be resolved by making sure references to the self module are changed to
__MODULE__
) - #8804 (Jason is generally the preferred JSON parser/encoder in Elixir these days in any case)
- #12268 (this should be using
Application.compile_env/2
instead ofApplication.get_env/2
, or using a code fallback)