OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.88k stars 6.59k forks source link

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

Open cro opened 3 years ago

cro commented 3 years ago

Bug Report Checklist

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?

wing328 commented 3 years ago

The Elixir client generator is relatively new so I don't think it can handle circular references yet.

We welcome contributions or sponsorships to add the support.