OpenAPITools / OpenAPITools/openapi-generator

[BUG] Elm Discriminator generates non-existent exports

Open
#16,104 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Elm 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?
Description

When generating Elm code for something that uses a discriminator it add some non-existent things to the exposing (...) list in the Data.elm file.

openapi-generator version

6.6.0

❯ openapi-generator-cli --version
openapi-generator-cli 6.6.0
  commit : 7f8b853
  built  : -999999999-01-01T00:00:00+18:00
  source : https://github.com/openapitools/openapi-generator
  docs   : https://openapi-generator.tech/
OpenAPI declaration file content or url

https://gist.github.com/TheOddler/6cc108f76c5c123900f9741af0bb408b

Generation Details
❯ openapi-generator-cli generate -g elm -i backend/openapi/openapi-bug-mininal.json -o frontend/generated
Steps to reproduce
  1. Download the above linked content, and generate elm code from it.
  2. Open the src/Api/Data.elm file
  3. See that it added ExampleTag(..) and exampleTagVariants to the exposed stuff
  4. Notice that neither of those actually exist in the file anywhere else
Related issues/PRs
Suggest a fix

I think those two exports should just not be added, then everything works (at least manually doing that seems to have fixed it for me).

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 linked OpenAPI declaration using openapi-generator-cli generate -g elm, then inspect the generated src/Api/Data.elm file. The fix is complete when ExampleTag(..) and exampleTagVariants are no longer listed in exposing (...) unless they are actually defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
elm
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.