OpenAPITools / OpenAPITools/openapi-generator
[BUG] invalid implementation of get_cowboy_config/2
Open
Nobody has claimed this yet.
Issue: Bug
Server: Erlang
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue? - any spec
- Have you validated the input using an OpenAPI validator (example)? yes
- What's the version of OpenAPI Generator used?
v4.3.1 - Have you search for related issues/PRs? yes
- What's the actual output vs expected output? see
suggest a fixsection - [Optional] Bounty to sponsor the fix (example)
Description
invalid implementation of get_cowboy_config/2
openapi-generator version
v4.3.1 or the latest docker image
OpenAPI declaration file content or url
any valid declaration
Command line used for generation
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v4.3.1 \
-g erlang-server -i /local/openapi.yaml -o /local/erlang_server
Steps to reproduce
- generate an erlang-server
- check *_server.erl file, notice invalid implementation of
get_cowboy_config/2/get_cowboy_config/3functions.
Related issues/PRs
none
Suggest a fix
- implementation of
get_cowboy_config/2should look like this:
get_cowboy_config(LogicHandler, ExtraOpts) ->
DefaultOpts = get_default_opts(LogicHandler),
DefaultEnv = maps:get(env, DefaultOpts, #{}),
ExtraEnv = maps:get(env, ExtraOpts, #{}),
Env = maps:merge(DefaultEnv, ExtraEnv),
Opts = maps:merge(DefaultOpts, ExtraOpts),
maps:put(env, Env, Opts).
- remove
get_cowboy_config/3andstore_key/3local functions - change default value for
cowboy_extra_optsfrom an empty list ([]) to an empty map (#{})
ExtraOpts = maps:get(cowboy_extra_opts, Params, #{}),
- add
cowboy_extra_optsto the*_server:start/2spec definition:
-spec start( ID :: any(), #{
ip => inet:ip_address(),
port => inet:port_number(),
logic_handler => module(),
net_opts => [],
cowboy_extra_opts => cowboy:opts()
}) -> {ok, pid()} | {error, any()}.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Generate an erlang-server with the provided Docker command and inspect the generated *_server.erl file, focusing on get_cowboy_config/2, get_cowboy_config/3, and store_key/3. Compare the generated functions and start/2 specification with the requested behavior; done means the configuration uses map-based cowboy_extra_opts and the generated Erlang code is valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, erlang
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100