Skip to content
GitLab
    • Explore Projects Groups Snippets
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
  • #3958
Something went wrong while setting issue due date.
Closed
Open
Issue created 5 years ago by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items
  • New related issue

  • Report abuse to administrator

  • New related issue

  • Report abuse to administrator

[BUG][Elixir] Wrong api client spec on multiple result types

Closed

[BUG][Elixir] Wrong api client spec on multiple result types

Created by: bigardone

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

When a reponse has different types, the generated client's spec ony refers to the type corresponding to a 200 as the result, when it should list all the possible types. Example:

Current generated version:

  @doc """
  Returns an user by `id`
  Returns an user account

  ## Parameters

  - connection (Connection): Connection to server
  - id (String.t): User ID
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, %Model.UserShowSuccess{}} on success
  {:error, info} on failure
  """
  @spec fetch_user_by_id(Tesla.Env.client(), String.t(), keyword()) ::
          {:ok, Model.UserShowSuccess.t()} | {:error, Tesla.Env.t()}
  def fetch_user_by_id(connection, id, _opts \\ []) do
    %{}
    |> method(:get)
    |> url("/internal/users/#{id}")
    |> Enum.into([])
    |> (&request(connection, &1)).()
    |> evaluate_response([
      {200, %Model.UserShowSuccess{}},
      {404, %Model.NotFoundError{}},
      {500, %Model.InternalServerError{}}
    ])
  end

This, however, makes dialyzer throw warnings, because the @spec fetch_user_by_id shoud be:

 @spec fetch_user_by_id(Tesla.Env.client(), String.t(), keyword()) ::
          {:ok, Model.UserShowSuccess.t()} | {:ok, Model.NotFoundError.t()} | {:ok, Model.InternalServerError.t()} | {:error, Tesla.Env.t()}
  def fetch_user_by_id(connection, id, _opts \\ []) do
    # ...
  end
openapi-generator version

0.0.19-4.1.2

OpenAPI declaration file content or url

https://gist.github.com/bigardone/c656634c18d2e713c16de30537e013da

Command line used for generation

openapi-generator generate -i https://gist.githubusercontent.com/bigardone/c656634c18d2e713c16de30537e013da/raw/53d378b195de969712bf6db5d43154763449a8f7/OpenAPISpec.json -g elixir

Steps to reproduce
Related issues/PRs
Suggest a fix

All possible return types should be listed separated by | in here https://github.com/OpenAPITools/openapi-generator/blob/44e4dc3ff4765ae03ce5f1c91799d347b09ec498/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java#L694

  1. Oh no!

    You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico.

    Incoming!

    Drop your designs to start your upload.
Tasks
0
server returned results with length 1, expected length of 9

Linked items
0

Link issues together to show that they're related. Learn more.

Activity


Please register or sign in to reply
0 Assignees
None
Assign to
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
Due date
None
None
None
Time tracking
No estimate or time spent
Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only project members with at least the Reporter role, the author, and assignees can view or be notified about this issue.

Lock issue
Unlocked
0
0 participants
Reference:

Menu

Explore Projects Groups Snippets