Open michaelcarrano opened 5 years ago
Hi, the preference would definitely be to extend the existing generator and make it flexible to use different json serialization libraries. The config which code to generate can be passed in via attributes on the invocation_form, see https://app.apibuilder.io/apicollective/apibuilder-generator/0.14.85#model-invocation_form
For example the scala generators make use of this to be able to choose between play-json and circe and between joda and java-time libraries for date and datetime types. See https://github.com/apicollective/apibuilder-generator/blob/master/scala-generator/src/main/scala/models/Config.scala
To create a new generator under apibuilder-generator
, take a look at https://github.com/apicollective/apibuilder-generator/pull/558
To create a new Kotlin generator, I can think of a few ways:
KotlinGenerator
to be KotlinJacksonGenerator
and create a new KotlinMoshiGenerator
that is similar to the jackson one.KotlinGenerator
to take some config. The majority of the generated code still can be used (Retrofit2, RxJava2).As for the difference between Jackson and Moshi, the generator itself doesn't really use Jackson but rather generates stuff like com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME
which can be swapped (I think?) to use the Moshi equivalent.
I am looking into adopting ApiBuilder and to leverage the generators in client side apps. I mainly deal with Android.
Our Android stack makes use of: Kotlin RxJava2 Retrofit2 Moshi
I noticed the Kotlin generator that currently exists uses most of the same stack but uses Jackson instead for de/serializing of Json.
Any advice if I want to create a new client to use Moshi instead? What about being able to configure the generator so that the client can use Moshi, Gson, or Jackson?