swagger-api / swagger-api/swagger-codegen

[HASKELL] Definitions which are arrays generate empty types

Open
#11,083 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

When generating a haskell-http-backend API client from an API file that contains one or more definitions which are type: array, the resulting Haskell types will be empty.

The Haskell types should contain a list of the array item type, or otherwise be a newtype or type alias for the type [<array item item>]. Instead, the definition which is an array will have an empty datatype generated for it.

Because of this bad generation, some API clients generated by swagger-codegen are unusable.

Swagger-codegen version

2.4.21. (Latest stable 2.0 at time of writing).

Swagger declaration file content or url

A minimal example can be found here

Command line used for generation
swagger-codegen generate -i bad_swagger_example.yaml --additional-properties cabalPackage=test-haskell -l haskell-http-client -o test-haskell/
Steps to reproduce
  1. Run the above command, or any similar one, to generate a haskell-http-client backend for the provided example YAML.
  2. Open test-haskell/lib/Test/Model.hs.
  3. See that the definition of the data type Foo does not contain a list of Bar (i.e. a [Bar]), as expected.
Related issues/PRs

Looks related to #10559

Suggest a fix/enhancement

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

Run the documented swagger-codegen command with the linked minimal Swagger example, then inspect test-haskell/lib/Test/Model.hs and compare the generated Foo and Bar definitions. Done means an array definition generates a Haskell type containing the item list type, such as [Bar], rather than an empty datatype.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.