Fix errors in Kotlin Unit
methods
#1124
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Kotlin API fails on methods that don't return anything (which currently just includes
delete
methods) because the generated code by default tries to serialize the methods' return types in all cases, even if the return type isUnit
. I'm not exactly sure whether this is properly a bug in the openapi generator or in moshi. In any case, I was unable to fix the error by doing what initially seemed most sensible, which was to register a moshi adapter for theUnit
type.The fix here is not terribly elegant but in practice seems to fix the issue. I will also see about opening/adding to an existing issue on the openapi generator's github page and/or submitting a PR to fix this upstream.
Note also that I've removed the
Serializer.kt
template, which is unused. We've already got an actualSerializer
class stored in the generated code folder, so there's no reason to have the template.Fixes #1117.