Fix parsing of null descriptions
This commit is contained in:
@@ -10,13 +10,16 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@ExperimentalSerializationApi
|
@ExperimentalSerializationApi
|
||||||
class RetrofitBuilder @Inject constructor(private val okHttpBuilder: OkHttpBuilder) {
|
class RetrofitBuilder @Inject constructor(private val okHttpBuilder: OkHttpBuilder) {
|
||||||
|
private val json by lazy { Json { coerceInputValues = true } }
|
||||||
|
|
||||||
fun buildRetrofit(baseUrl: String, token: String? = null): Retrofit {
|
fun buildRetrofit(baseUrl: String, token: String? = null): Retrofit {
|
||||||
Timber.v("buildRetrofit() called with: baseUrl = $baseUrl, token = $token")
|
Timber.v("buildRetrofit() called with: baseUrl = $baseUrl, token = $token")
|
||||||
val contentType = "application/json".toMediaType()
|
val contentType = "application/json".toMediaType()
|
||||||
|
val converterFactory = json.asConverterFactory(contentType)
|
||||||
return Retrofit.Builder()
|
return Retrofit.Builder()
|
||||||
.baseUrl(baseUrl)
|
.baseUrl(baseUrl)
|
||||||
.client(okHttpBuilder.buildOkHttp(token))
|
.client(okHttpBuilder.buildOkHttp(token))
|
||||||
.addConverterFactory(Json.asConverterFactory(contentType))
|
.addConverterFactory(converterFactory)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ data class GetRecipeSummaryResponse(
|
|||||||
@SerialName("name") val name: String,
|
@SerialName("name") val name: String,
|
||||||
@SerialName("slug") val slug: String,
|
@SerialName("slug") val slug: String,
|
||||||
@SerialName("image") val image: String,
|
@SerialName("image") val image: String,
|
||||||
@SerialName("description") val description: String,
|
@SerialName("description") val description: String = "",
|
||||||
@SerialName("recipeCategory") val recipeCategories: List<String>,
|
@SerialName("recipeCategory") val recipeCategories: List<String>,
|
||||||
@SerialName("tags") val tags: List<String>,
|
@SerialName("tags") val tags: List<String>,
|
||||||
@SerialName("rating") val rating: Int?,
|
@SerialName("rating") val rating: Int?,
|
||||||
|
|||||||
Reference in New Issue
Block a user