openapi-generator
openapi-generator copied to clipboard
scala-sttp: fix for issue 15785 api returns unit.
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-sttp (3) 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.
thanks for the PR
cc @clasnake (2017/07), @jimschubert (2017/09) ❤️, @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) @Fish86 (2023/06)
@wing328 I'm not sure if you had seen it, but #18536 is a different commit with changes for sttp4. This one is sttp3 only. I split those up in case one or the other needed a roll back. Edit: Meaning the other one should not be closed, maybe.
ah right. sorry. just reopened it