Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6354
Closed
Open
Issue created May 18, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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
  1. generate an erlang-server
  2. 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 and store_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()}.
Assignee
Assign to
Time tracking