swagger-api / swagger-api/swagger-codegen
[HASKELL] Definitions which are arrays generate empty types
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
- Run the above command, or any similar one, to generate a
haskell-http-clientbackend for the provided example YAML. - Open
test-haskell/lib/Test/Model.hs. - See that the definition of the data type
Foodoes not contain a list ofBar(i.e. a[Bar]), as expected.
Related issues/PRs
Looks related to #10559
Suggest a fix/enhancement
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 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