-
Notifications
You must be signed in to change notification settings - Fork 42
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
Usage with kotlinx.serialization #42
Comments
In principle the Ktor serializer/deserializer should be compatible since it uses Ktror's respond and receive, but i haven't tested. |
Yes, I get the following exception: I'll try to see if I can work around this. |
Your issue is related to how kotlinX handles generics. You can get initialisation time types of the generics, see here: There is currently no way to generate a per route parser/serializer from a single factory IIRC, you would have to manually (through another module) register the parsers/serializers for each specific type. Look at how the KtorContentProvider works, it is a default module loaded through reflection (you can configure the searched packages in the config) with the interface OpenAPIGenModuleExtension. I'll implement the necessary changes when it is clear what changes are required. |
Thanks for the info. I guessed that I would somehow need to register serializers for everything this library needs to send. Didn't look that much into how kotlinx.serialization works under the hood (and how Ktor calls kotlinx.serialization), I will check that. |
Hi, I created a extension on DataModel to serialize using a kotlinx.serialization. I few some tests and I got success results.
And I need mark @serializable on model classes.
I can use in this way:
Thank you! |
I replaced a tiny detail
This leads to errors if you maybe miss to add inheritance from DataModel. Otherwise you have missing values in your openapi.json. Not sure if this is what one wants. |
@christiangroth Can you please share the branch where kotlinx serialization is supported? |
I was able to figure out what was wrong in my case. Some element serialization simply didn't work since they are not part of DataModel. So I replaced function
where |
Hi @xupyprmv sorry for the later answer and thanks for sharing your solution :) Unfortunately I don't think there is a branch officially supporting kotlinx.serialization, at least I did not found one. But as I am also not actively developing this project I cannot say what the future may bring. |
Hi,
This library looks great!
I am having problems with getting things working in my Ktor application which uses kotlinx.serialization for API serialization/deserialization. I can't find if this library should work (or is tested) with kotlinx.serialization? And if so if there are any specific settings that need to be set?
The text was updated successfully, but these errors were encountered: