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-http-generator - Make endpoints which don't return anything yield NoContent #9916

Merged

Conversation

ivanbakel
Copy link
Contributor

@ivanbakel ivanbakel commented Jul 8, 2021

Fixes #9901

The haskell-http-client generator tries to generate a polymorphic return type for endpoints which don't return anything in the success case, but still produce content in other cases. This means that these endpoints hit a decoding error in the success case, because there is no content to decode.

This changes the behaviour so that endpoints that don't return anything are always generated as returning NoContent, and never try to decode the response. This change is based on a similar one for the haskell-servant generator, which can be found at #9830, which resolved a similar issue for that generator.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    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/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Relevant issue: OpenAPITools#9901

The haskell-http-client generator tries to generate a polymorphic return
type for endpoints which don't return anything in the success case, but
still produce content in other cases. This means that these endpoints
hit a decoding error in the success case, because there is no content to
decode.

This changes the behaviour so that endpoints that don't return anything
are *always* generated as returning NoContent, and never try to decode
the response. This change is based on a similar one for the
haskell-servant generator, which can be found at:

OpenAPITools#9830

which resolved a similar issue for that generator.
@wing328
Copy link
Member

wing328 commented Jul 13, 2021

cc @jonschoning

@wing328 wing328 modified the milestone: 5.2.0 Jul 13, 2021
@jonschoning jonschoning self-assigned this Jul 14, 2021
@jonschoning jonschoning merged commit 65a271c into OpenAPITools:master Jul 15, 2021
@wing328 wing328 added this to the 5.2.1 milestone Aug 13, 2021
ivanbakel added a commit to ivanbakel/openapi-generator that referenced this pull request Aug 18, 2021
While the fix in OpenAPITools#9916 correctly made endpoint types which did not
produce content return the `NoContent` type, those endpoint still
generated `Produces` instances with the wrong mime types due to not
resetting the `hasProduces` variable. This corrects that fix so that the
`Produces` instance for `MimeNoContent` is generated instead of any
other instance.
wing328 pushed a commit that referenced this pull request Aug 21, 2021
While the fix in #9916 correctly made endpoint types which did not
produce content return the `NoContent` type, those endpoint still
generated `Produces` instances with the wrong mime types due to not
resetting the `hasProduces` variable. This corrects that fix so that the
`Produces` instance for `MimeNoContent` is generated instead of any
other instance.
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.

[BUG] Haskell-http-client gives empty responses a polymorphic return type in some cases
3 participants