openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

scala-sttp4: fix for issue 15785 api returns unit.

Open dwischolek-modulon opened this issue 1 year ago • 2 comments

PR checklist

  • [x] Read the contribution guidelines.
  • [x] 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.
  • [x] Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    

This PR solves #15785 for the scala-sttp4 generator. Rationale for the changes:

  • the problem that was tackled in #11949 was not really about default values.
  • asUnit[Unit] leads to an error, anyways, so not only with default responses, this is the wrong encoding.
  • using asEither(asString, ignore) works, but turns the structured error in Left into a String, shedding information in the process. The "asString.mapWithMetadata(..."-construct allows for empty or garbage response bodies while keeping the Left() information intact.
  • asJsonAlwaysUnsafe is gone from sttp for a LONG time. This needed replacement, anyways.

dwischolek-modulon avatar Apr 29 '24 16:04 dwischolek-modulon

closed via #18537

wing328 avatar Apr 30 '24 05:04 wing328

@clasnake (2017/07), @jimschubert (2017/09) ❤️, @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) @Fish86 (2023/06) please review when you've time. thanks

wing328 avatar Apr 30 '24 08:04 wing328