swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.98k stars 6.03k forks source link

[Haskell] codegen generates fields of type `Date` without importing or declaring `Date` #8848

Open tysonzero opened 5 years ago

tysonzero commented 5 years ago
Description

Haskell codegen will generate fields of type Date, but will not import or declare Date, leading to stack build failing with errors like Not in scope: type constructor or class ‘Date’.

Swagger-codegen version

2.3.1

Swagger declaration file content or url

http://api.open.fec.gov/swagger

Command line used for generation

swagger-codegen generate -i http://api.open.fec.gov/swagger -l haskell

Steps to reproduce

Assuming haskell-stack installed:

swagger-codegen generate -i http://api.open.fec.gov/swagger -l haskell

stack build

Related issues/PRs

None found

Suggest a fix/enhancement

Generate type Day instead of Date and import Day from package time module Data.Time.

adamConnerSax commented 5 years ago

There are more errors after the date thing. See: https://github.com/haskell-servant/servant/issues/1084#issuecomment-439507900 I'm not sure if you still have this issue. I'm working on a fix that would address this and a few other issues with the servant generator. Current progress here: https://github.com/adamConnerSax/swagger-codegen/tree/UpdateHaskellServant It compiles now, but I have yet to test the result. I'll update here once I do.