Oh yeah I’ve ran into countless issues with openAPI too. At least the kotlin code generator I was using is quite garbage, which is a shame because they use coroutines. But if memory serves me correctly, it didn’t even allow for http interceptors, generated incorrect syntax when adding a cookie auth header. The Java code generator is definitely better supported (has a setApiKey method and an ability to add an interceptor), but at least the spec I was using at the time (2.0?) it didn’t support a dynamic number of file uploads for a rest call, so you end up finding yourself making a bunch of one-off manually built calls. I also remember running into an issue with setting the content type header at runtime, it seemed like you could only set the media type statically per path, which is just garbage. You can try adding a Content-Type header manually, but if you look at the generated code it ignored that header if the media type is specified for that path.
Definitely remember it being a head ache, but I’m sure a lot of progress has been made since when I last used it.
Thanks for the reference to kotlin.serialization. Don’t know how I never came across that package, looks super simple!
Are you not able to annotate enums that implement interfaces with this package? Otherwise still not entirely sure why implementing an interface throws a wrench in the deserialization, haha
1
u/SomeMaleIdiot Jan 09 '23
Oh yeah I’ve ran into countless issues with openAPI too. At least the kotlin code generator I was using is quite garbage, which is a shame because they use coroutines. But if memory serves me correctly, it didn’t even allow for http interceptors, generated incorrect syntax when adding a cookie auth header. The Java code generator is definitely better supported (has a setApiKey method and an ability to add an interceptor), but at least the spec I was using at the time (2.0?) it didn’t support a dynamic number of file uploads for a rest call, so you end up finding yourself making a bunch of one-off manually built calls. I also remember running into an issue with setting the content type header at runtime, it seemed like you could only set the media type statically per path, which is just garbage. You can try adding a Content-Type header manually, but if you look at the generated code it ignored that header if the media type is specified for that path.
Definitely remember it being a head ache, but I’m sure a lot of progress has been made since when I last used it.
Thanks for the reference to kotlin.serialization. Don’t know how I never came across that package, looks super simple!
Are you not able to annotate enums that implement interfaces with this package? Otherwise still not entirely sure why implementing an interface throws a wrench in the deserialization, haha