Fix parsing of null descriptions

This commit is contained in:
Kirill Kamakin
2021-11-13 12:30:59 +03:00
parent 284f32588f
commit 31fc27ebef
2 changed files with 5 additions and 2 deletions

View File

@@ -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()
} }
} }

View File

@@ -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?,