Skip to content

Upgrade haskell-servant generator to latest LTS #1469

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

Merged
merged 5 commits into from
Dec 4, 2018

Conversation

f-f
Copy link
Contributor

@f-f f-f commented Nov 16, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Problem: the current haskell-servant client is based on a set of libraries (lts package set) from one year ago, based on the 8.0.x release of GHC. It is typical for library writers in the Haskell community to maintain compatibility with the latest 3 major versions of the compiler. By this standard (since 8.2, 8.4 and 8.6 are out) we are generating an outdated client. Moreover, the servant library itself went through several breaking versions in the meanwhile, so the code generated by this generator is not really compatible with a project started today.

This PR upgrades to the latest lts (12.18 for GHC 8.4) and servant version, and adds several new features:

  • optionals are now Maybes
  • UUID, UTCTime and Day are now represented with the correct types
  • the configuration for the client now contains only one parameter, the url
  • add ToSchema instances to generated types, so they can be re-exposed for free in the spec of the service using the client
  • switch to the tls-http-manager, so we can connect to https urls
  • add Nix support in the stack.yaml
  • add a nicer API to call the endpoints

Note: all of this is quite breaking, so I opened the PR against the 4.x branch

/cc @wing328

f-f added 2 commits November 16, 2018 13:45
- Upgrade Servant to the latest version
- Add Maybe for optional values
- Add UUID, UTCTime and Day types
- Fix the URL configuration so that it has one param with all data
- Add Data and ToSchema instances to models
- Switch to TLS http manager so it can connect to https urls
- Add nicer API to call the endpoints
- Add Nix support
@wing328
Copy link
Member

wing328 commented Nov 19, 2018

cc @jonschoning, @algas to see if they've time to do a review on the change.

@jonschoning
Copy link
Contributor

definitely looks like an improvement over the old bitrotted code.

  1. i'm seeing a build error in the sample code https://gist.github.com/jonschoning/c4603fb8e8f617aac96e5a608b7d17aa

  2. we should probably remove the old swagger files in the samples folder as well

@f-f
Copy link
Contributor Author

f-f commented Nov 20, 2018

@jonschoning thanks for the review!

  1. Right, I didn't try running stack build on the petstore, good catch
  2. Yes, I'll remove them

@f-f f-f force-pushed the upgrade-haskell-servant branch from dcf4e30 to 5729960 Compare November 20, 2018 13:46
@jonschoning
Copy link
Contributor

looks good to me

@wing328 wing328 modified the milestones: 3.3.4, 4.0.0 Nov 30, 2018
@wing328 wing328 merged commit 6976a8c into OpenAPITools:4.0.x Dec 4, 2018
@wing328
Copy link
Member

wing328 commented Dec 4, 2018

@jonschoning thanks for reviewing the change.

@f-f thanks for the enhancement, which has been merged into master.

@wing328
Copy link
Member

wing328 commented Jan 2, 2019

@f-f thanks again for the contribution, which has been included in the 4.0.0-beta release: https://twitter.com/oas_generator/status/1079727020374806529.

Happy New Year and looking forward to more collaboration and contributions in 2019!

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* [Haskell Servant] Upgrade to lts-12

- Upgrade Servant to the latest version
- Add Maybe for optional values
- Add UUID, UTCTime and Day types
- Fix the URL configuration so that it has one param with all data
- Add Data and ToSchema instances to models
- Switch to TLS http manager so it can connect to https urls
- Add nicer API to call the endpoints
- Add Nix support

* [Haskell Servant] Upgrade Petstore

* [Haskell Servant] Delete old swagger-petstore samples

* [Haskell Servant] Use generics for ToForm and FromForm instances

* [Haskell Servant] Generate ToSchema instance only if it's safe to do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants