Skip to content

[BUG] List<Enum> response generates invalid Elm code #22530

@bjornpijnacker

Description

@bjornpijnacker

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 master latest 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 a List Enum where Enum is the type specified in the spec.
  • There is no Api.Data generated.
  • The somethingControllerResponseDecoder does 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions