[BUG] invalid implementation of get_cowboy_config/2
Created by: DenysGonchar
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 fix
section -
[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/3
functions.
Related issues/PRs
none
Suggest a fix
- implementation of
get_cowboy_config/2
should 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/3
andstore_key/3
local functions - change default value for
cowboy_extra_opts
from an empty list ([]
) to an empty map (#{}
)
ExtraOpts = maps:get(cowboy_extra_opts, Params, #{}),
- add
cowboy_extra_opts
to the*_server:start/2
spec 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()}.