Add post processing to files generated by Haskell generators#968
Add post processing to files generated by Haskell generators#968
Conversation
|
btw, are you generating the sample with |
|
not sure if i like having hfmt (and requiring/directing the user to install the hfmt tool) alter the output of the templates, but i'll look it over and see if it's more or less readable than the current output, a least for the haskell-http-client generator |
|
@jonschoning thanks for the feedback. The formatting done by hfmt can be switched off by removing the environment variable "HFMT_PATH". I agree with you that some users may not like the output of hfmt so the formatting should remain optional. |
|
UPDATE: added |
|
After looking at some of the differences, I'm not really liking this change for two reasons:
if the current output of the source templates was really bad, this would be an improvement, but since the output of the templates have already been written carefully to be pretty readable, i think this just makes things harder to read than easier. |
| (coerce -> loginUser) :<|> | ||
| (coerce -> logoutUser) :<|> | ||
| (coerce -> updateUser)) = client (Proxy :: Proxy OpenAPIPetstoreAPI) | ||
| ((coerce -> addPet) :<|> (coerce -> deletePet) :<|> (coerce -> findPetsByStatus) :<|> (coerce -> findPetsByTags) :<|> (coerce -> getPetById) :<|> (coerce -> updatePet) :<|> (coerce -> updatePetWithForm) :<|> (coerce -> uploadFile) :<|> (coerce -> deleteOrder) :<|> (coerce -> getInventory) :<|> (coerce -> getOrderById) :<|> (coerce -> placeOrder) :<|> (coerce -> createUser) :<|> (coerce -> createUsersWithArrayInput) :<|> (coerce -> createUsersWithListInput) :<|> (coerce -> deleteUser) :<|> (coerce -> getUserByName) :<|> (coerce -> loginUser) :<|> (coerce -> logoutUser) :<|> (coerce -> updateUser)) = |
There was a problem hiding this comment.
this is basically unreadable
|
@jonschoning thanks for reviewing the output. What about using Ref: UPDAET: I've updated the samples using |
|
UPDATE: I've renamed the environment variable to "HASKELL_POST_PROCESS_FILE" to make it consistent across all generators. The user can define it with code formatter of their choice or using other tools to post process the auto-generated Haskell files. |
|
stylish-haskell has better formatting, but it appears to not handle all cases and generates errors: I like the approach of letting the user choose the code formatter as they wish. |
I couldn't repeat the issue locally. Here are partial results: Here is how I set the env variable:
Definitely. I updated the samples to show you the difference made by the code formatter. The samples should be not be formatted automatically. I've updated this PR to restore the Haskell samples without using a code formatter. |
|
I like that. I saw you used which one would you prefer we generate the samples with? oas2 or oas3? |
|
I still use oas2 version to update samples. We may need to move some samples to another repository instead as the size of the repo will become too big if we include samples generated with OAS3 spec If this change looks good to you, please feel free to approve and merge it. |
|
ok, i approve this then.. I will have to make some updates to the example app in the samples because it is compiling against the oas3 version. |
641021c to
ab93f0e
Compare
…Tools#968) * add hfmt support (without updating the sample) * update haskell httpclient samples with hfmt * add code format option to haskell servant, minor bug fixes * update code samples with hfmt * update samples using stylish-haskell * rename env variable * update haskell samples with stylish-haskell * regenerate haskell samples without stylish-haskell * regenerate haskell servant sample * update example-app & tests-integration for OAS2 code
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif 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\.master,3.3.x,4.0.x. Default:master.Description of the PR
If the environment variable HFMT_PATH (e.g. $HOME/.local/bin/hfmt) is defined, use it to format the Haskell code.
TODO: run hfmt to format Haskell servant codecc @jonschoning, @algas