Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Haskell] Refactor generator to create separate client, server generator #5100

Open
wing328 opened this issue Mar 17, 2017 · 9 comments
Open

Comments

@wing328
Copy link
Contributor

wing328 commented Mar 17, 2017

Description

Currently, Haskell generator (HaskellServantCodegen.java) generates both client and server code. We want to refactor HaskellServantCodegen.java into the following:

HaskellServantCodegen.java - for server
HaskellClientCodegen.java - for client
AbstractHaskellCodegen.java - abstract class for client/server generator

The goal is to make Haskell generator more consistent with other generators (as no other generator output both client and server code at the same time)

Swagger-codegen version

Latest master

Suggest a Fix

If anyone wants to contribute the enhancement, please reply to let us know.

@mandrean
Copy link
Contributor

mandrean commented Mar 17, 2017

👍

Cross-referencing my comment from #5097:

@wing328 Thanks! Yes, I think it's a very good idea to split them up.

Also, it might be a good idea to evaluate other solutions for the client. I don't think servant-client is the best choice here.

I would go with http-client, which is used by many other high-profile Haskell packages (as you can see in the Used by 256 packages: section on Stackage), including PureScript, Yesod, stack it self, and many others.

@wing328
Copy link
Contributor Author

wing328 commented Mar 17, 2017

@mandrean sounds good to me to use http-client. If a user still prefers servant-client, we can simply keep it in the current generator (for backward compatibility)

@mandrean
Copy link
Contributor

mandrean commented Mar 17, 2017

Another option could be https://github.com/bos/wreq which is based on http-client but supposedly easier ridiculously easy to use! (http://www.serpentine.com/wreq/#whirlwind-tour)

And it has built-in support for Basic Auth and Oauth2.

My vote goes to wreq for now.

@wing328
Copy link
Contributor Author

wing328 commented Mar 18, 2017

Both http-client and wreq look good to me. For Java API client, it now supports the following HTTP libraries via the library option/switch:

	library
	    library template (sub-template) to use (Default: okhttp-gson)
	        jersey1 - HTTP client: Jersey client 1.19.1. JSON processing: Jackson 2.7.0. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
	        feign - HTTP client: Netflix Feign 8.16.0. JSON processing: Jackson 2.7.0
	        jersey2 - HTTP client: Jersey client 2.22.2. JSON processing: Jackson 2.7.0
	        okhttp-gson - HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.6.2. Enable Parcelable modles on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
	        retrofit - HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.
	        retrofit2 - HTTP client: OkHttp 3.2.0. JSON processing: Gson 2.6.1 (Retrofit 2.0.2). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)

Supporting multiple HTTP libraries is possible via a "swappable" ApiClient class.

My suggestion is to go with the HTTP library that you feel comfortable. Later there may be enhancement to support HTTP libraries when more and more Haskell developers discover Swagger Codegen.

@mandrean
Copy link
Contributor

mandrean commented Mar 20, 2017

Great suggestion. Super busy at work right now, bu I'll try to squeeze out a feature-complete wreq PoC for Petstore.json, then we can start templating the codegen from there.

@jonschoning
Copy link
Contributor

jonschoning commented Mar 22, 2017

my vote would be for http-client over wreq, as http-client avoids a dependency on lens (& assumes familarity w/ lens operators) (and has less deps in general), is more actively maintained, and is more straightforward imho.

Actually, it would not be unreasonable to have multiple haskell client generators as some of the other languages do. that way the servant generator could be kept.

@nvmd
Copy link

nvmd commented May 25, 2017

I'm working on a gradual improvements to haskell-servant right now. Generated code itself first, and codegen refactoring after that.

@wing328
Copy link
Contributor Author

wing328 commented May 25, 2017

@nvmd thanks. If the enhancement is not backward compatible with the existing code, then please file it against 2.3.0 branch. Any questions just let us know.

@wing328
Copy link
Contributor Author

wing328 commented Sep 4, 2017

Hi all, when you've time, please try the Haskell http-client generator by @jonschoning : #6429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants