From 31fc27ebef46ce78e1d59443fc9310fb00d515b3 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sat, 13 Nov 2021 12:30:59 +0300 Subject: [PATCH] Fix parsing of null descriptions --- .../java/gq/kirmanak/mealie/data/impl/RetrofitBuilder.kt | 5 ++++- .../mealie/data/recipes/network/GetRecipeSummaryResponse.kt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/gq/kirmanak/mealie/data/impl/RetrofitBuilder.kt b/app/src/main/java/gq/kirmanak/mealie/data/impl/RetrofitBuilder.kt index 2ddadff..fcdc9ea 100644 --- a/app/src/main/java/gq/kirmanak/mealie/data/impl/RetrofitBuilder.kt +++ b/app/src/main/java/gq/kirmanak/mealie/data/impl/RetrofitBuilder.kt @@ -10,13 +10,16 @@ import javax.inject.Inject @ExperimentalSerializationApi class RetrofitBuilder @Inject constructor(private val okHttpBuilder: OkHttpBuilder) { + private val json by lazy { Json { coerceInputValues = true } } + fun buildRetrofit(baseUrl: String, token: String? = null): Retrofit { Timber.v("buildRetrofit() called with: baseUrl = $baseUrl, token = $token") val contentType = "application/json".toMediaType() + val converterFactory = json.asConverterFactory(contentType) return Retrofit.Builder() .baseUrl(baseUrl) .client(okHttpBuilder.buildOkHttp(token)) - .addConverterFactory(Json.asConverterFactory(contentType)) + .addConverterFactory(converterFactory) .build() } } \ No newline at end of file diff --git a/app/src/main/java/gq/kirmanak/mealie/data/recipes/network/GetRecipeSummaryResponse.kt b/app/src/main/java/gq/kirmanak/mealie/data/recipes/network/GetRecipeSummaryResponse.kt index aa64fc2..6a59b25 100644 --- a/app/src/main/java/gq/kirmanak/mealie/data/recipes/network/GetRecipeSummaryResponse.kt +++ b/app/src/main/java/gq/kirmanak/mealie/data/recipes/network/GetRecipeSummaryResponse.kt @@ -11,7 +11,7 @@ data class GetRecipeSummaryResponse( @SerialName("name") val name: String, @SerialName("slug") val slug: String, @SerialName("image") val image: String, - @SerialName("description") val description: String, + @SerialName("description") val description: String = "", @SerialName("recipeCategory") val recipeCategories: List, @SerialName("tags") val tags: List, @SerialName("rating") val rating: Int?,