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
  • #5234
Closed
Open
Issue created Feb 07, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] Elixir generated client does not work with optional request body

Created by: boolafish

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

If the request body of an api is optional, the generated elixir client cannot override the param correctly with the params if given.

For instance, one can do

Api.Account.account_get_transactions(
  Connection.new()
)

or

Api.Account.account_get_transactions(
  Connection.new(),
  [{:"GetAllTransactionsBodySchema", %{}}]
)

But no matter how we pass params into the function, it would not have any effect: (with limit 1, the response should only return 1 item)

Api.Account.account_get_transactions(
  Connection.new(),
  [{:"GetAllTransactionsBodySchema", %{
    limit: 1
  }}]
)

or

Api.Account.account_get_transactions(
  Connection.new(),
  [{:limit, 1}]
)
openapi-generator version

latest docker

OpenAPI declaration file content or url

https://github.com/omisego/elixir-omg/blob/862a6adfd436fbb1316be760ac6b72090127a115/apps/omg_watcher_rpc/priv/swagger/info_api_specs.yaml#L556

Command line used for generation

see this make command: https://github.com/omisego/elixir-omg/blob/862a6adfd436fbb1316be760ac6b72090127a115/priv/Makefile#L20

Steps to reproduce
  1. clone elixir-omg
git clone https://github.com/omisego/elixir-omg
  1. run a local service in a tab
make init_test
make docker-nuke
docker-compose up
  1. in another tab:
cd elixir-omg/priv
mix deps.get
make generate_api_code
iex -S mix

alias WatcherInfoAPI.Connection
alias WatcherInfoAPI.Api

Api.Account.account_get_transactions(
  Connection.new(),
  [{:"GetAllTransactionsBodySchema", %{
    limit: 1
  }}]
)
Related issues/PRs

Workaround ourself: https://github.com/omisego/elixir-omg/pull/1302

Suggest a fix

N/A

Assignee
Assign to
Time tracking