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

Fix errors in Kotlin Unit methods #1124

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Conversation

jaymell
Copy link
Contributor

@jaymell jaymell commented Nov 16, 2023

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 is Unit. 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 the Unit 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 actual Serializer class stored in the generated code folder, so there's no reason to have the template.

Fixes #1117.

@jaymell jaymell changed the title Fix errors in Kotlin unit methods Fix errors in Kotlin Unit methods Nov 16, 2023
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 is `Unit`.
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 the `Unit` 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 actual `Serializer` class
stored in the generated code folder, so there's no reason to
have the template.

Fixes svix#1117.
@svix-james svix-james merged commit 30f1704 into svix:main Nov 17, 2023
2 checks passed
@jaymell jaymell deleted the kotlin-bug-fix branch November 17, 2023 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kotlin SDK error when deleting an endpoint
3 participants