Created by: ghostbuster91
We'd like to propose the following changes to the scala-sttp generator. While the existing version works quite well (thanks to all of the contributors!), in a couple of places it diverges from the way sttp is most often used in the wild, and from the original design goals.
List of changes together with reasons behind them:
- allow libraries' versions customization - although it is not hard to change them by hand we think that it plays nicely with the rest of the cli options and improves the overal user's experience
- return erros by default in a separate error channel - being explicit in terms of returned error types is the way to go in scala (there is a switch which allows to restore the old behavior)
- some of the helper functions were incorporated into sttp directly
- some of the helper functions were removed as they were redundant/unnecessary
- auth parameters are passed explicitly rather than implicitly - we belive that the rule of tumb to follow when choosing between imlicit vs explicit arguments is whether they are business or techincal one. Auth parameters belongs to the first category.
- because credentials were no longer passed implicitly there was no need to keep custom auth releated classes
- json processing related instances are now imported via single import statement
- fixed multipart requests
- removed ApiModel class - it was artifical and redundant
- added circe as another json library - circe is as popular as json4s if not more
- removed sttpClientCodegen inheritance from akkaClientCodegen
- extract classes to deal with cli properties - Dealing with them is quite cumbersome and what is worse it is error-prone. It is easy to make a mistake, especially when dealing with properties which mutually exlude themselfs. Having another layer of abstraction on top of them makes things much easier.
- build.sbt was reduced to minimum
Despite breaking changes I opened this PR against master branch since the sttp generator is marked as beta. But let me know if that needs to be changed.
PR checklist
-
Read the contribution guidelines. -
If contributing template-only or documentation-only changes which will change sample output, build the project beforehand. -
Run the shell script ./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/config/java*
. For Windows users, please run the script in Git BASH. -
File the PR against the correct branch: master
-
Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Summoning technical committee: @clasnake @jimschubert , @shijinkui , @ramzimaalej , @chameleon82 , @Bouillie