OpenAPITools / OpenAPITools/openapi-generator

[BUG][ELIXIR] JIRA API OpenApi spec generates uncompilable code

Open
#10,755 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am trying to generate an Elixir client for the Jira API. The generation completes, but I cannot compile the resuliting project.

openapi-generator version

I tried with current stable and the latest. I am using the docker container version.

OpenAPI declaration file content or url

https://developer.atlassian.com/cloud/jira/platform/swagger-v3.v3.json

Generation Details
docker run --rm -v "$PWD:/local" openapitools/openapi-generator-cli:latest generate \
                  -i https://developer.atlassian.com/cloud/jira/platform/swagger-v3.v3.json \
                  -g elixir \
                  -o /local/out/elixir
cd out/elixir
mix deps.get
mix compile
Steps to reproduce
docker run --rm -v "$PWD:/local" openapitools/openapi-generator-cli:latest generate \
                  -i https://developer.atlassian.com/cloud/jira/platform/swagger-v3.v3.json \
                  -g elixir \
                  -o /local/out/elixir
cd out/elixir
mix deps.get
mix compile

results in

== Compilation error in file lib/the_jira_cloud_platform_restapi/api/issue_properties.ex ==
** (CompileError) lib/the_jira_cloud_platform_restapi/api/issue_properties.ex:213: TheJiraCloudPlatformRESTAPI.Model.AnyType.__struct__/1 is undefined, cannot expand struct TheJiraCloudPlatformRESTAPI.Model.AnyType. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
    (stdlib 3.15) lists.erl:1358: :lists.mapfoldl/3
    (stdlib 3.15) lists.erl:1359: :lists.mapfoldl/3
    (elixir 1.12.3) expanding macro: Kernel.|>/2
Suggest a fix

This is my first experience with generating client code with openapi-generator. The validator suggested in the issue template says the .json spec is valid, but it can't be displayed because there are circular references. Is the Elixir plugin for openapi-generator unable to resolve this kind of situation?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the Docker generation command using the Jira OpenAPI spec, then run mix deps.get and mix compile in out/elixir. Inspect lib/the_jira_cloud_platform_restapi/api/issue_properties.ex and the generated AnyType model references shown in the compilation error. Done means the generated Elixir project compiles without the undefined AnyType struct error.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.