OpenAPITools / OpenAPITools/openapi-generator
[BUG] List<Enum> response generates invalid Elm code
Nobody has claimed this yet.
- 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?
- Have you
tested with the latest masterlatest stable 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
When an endpoint returns an array of enum values the generate Elm code is incomplete and invalid.
Running the generator on the example file, the following is generated:
module Api.Request.SomethingController exposing
( somethingControllerGet
)
import Api
import Api.Data exposing (..)
import Dict
import Http
import Json.Decode
import Json.Encode
somethingControllerGet : Api.Request (List String)
somethingControllerGet =
Api.request
"GET"
"/api/something"
[]
[]
[]
Nothing
(Json.Decode.list somethingControllerResponseDecoder)
Multiple issues here:
- The generated function return a
List String. This should be aList Enumwhere Enum is the type specified in the spec. - There is no
Api.Datagenerated. - The
somethingControllerResponseDecoderdoes not exist.
The generator should either fail, fall back to String properly, or should generate the correct code. The generator should not produce code that will not compile in any case.
openapi-generator version
7.17.0
OpenAPI declaration file content or url
https://gist.github.com/bjornpijnacker/c66e6447404f91f0baa7f785aceba4ae
Generation Details
openapi-generator generate -i openapi.json -g elm -o output
Steps to reproduce
N/A
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the documented openapi-generator command with the linked OpenAPI declaration and the elm generator. Inspect the generated Api.Request module and Api.Data output, then verify that the List response has a valid type and decoder and that the generated Elm code compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elm, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100