Open hasufell opened 5 years ago
There are an assortment of issues with the haskell-servant backend. I've been working on some related to the "Date" type and underscores and updates to servant. All of that is here:
https://github.com/adamConnerSax/swagger-codegen/tree/UpdateHaskellServant
Once I get all my issues fixed, I'll try and see what happens to yours and then update here.
I can see in the Java that swagger-codegen treats "List" as a primitive (!!) and also renames the swagger type "array" to "List" neither of which really make sense to me. So maybe I'll try to sort that out. But I don't really know java or the rest of swagger-codegen so I'm only able to do very simple things.
I think I fixed this one as well. Just involved removing "List" as a reserved word. There's what I think is a working version at the link above if you just need it to work. I'm not submitting the new version as a PR to swagger-codegen until I check some more things and get someone with more (read: any) servant experience to check that I haven't caused new issues.
We use swagger-codegen for https://hackage.haskell.org/package/docusign-base in production However, there are a number of things that are not fully automated: E.g. the resulting docusign module is >7k LOC and will just blow up your ram, so we separated all types into single modules. You can check out https://github.com/capital-match/docusign-base#basic-steps if you want to see if the codegen does something funky. I would say that project (docusign) is big enough to stumble over a lot of things if something goes wrong... I might also give your branch a try!
The swagger definition is here
Thanks! Maybe I will give that a try. Also, there is apparently a new version of swagger-codegen happening https://github.com/openapitools/openapi-generator And they are going to incorporate the fixes there, with the help of the haskell-servant backend authors.
Also, there is apparently a new version of swagger-codegen happening https://github.com/openapitools/openapi-generator
That version still generates a 7k LOC Types.hs file ;)
And it appears to have the same bug with List_
vs [List]
Description
Haskell GHC compiler fails to build the generated haskell code due to diverging data type names when the swagger type is
list
:The data type that is generated is:
But the API will use:
The whole generated project can be viewed at https://github.com/hasufell/petstore-swagger-bug
Swagger-codegen version
2.4.0-SNAPSHOT
built from git d9c4e014e6791072b1c71faa4a77098f9bdcc3a4Swagger declaration file content or url
This is derived from the minimal swagger petstore definition. The pet type has been renamed to
list
:Command line used for generation
Steps to reproduce
After generation, run:
stack build