Skip to content

Fix deserialization of enums#268

Merged
Alexis2004 merged 2 commits intomasterfrom
report_api
Mar 13, 2023
Merged

Fix deserialization of enums#268
Alexis2004 merged 2 commits intomasterfrom
report_api

Conversation

@mvgreen
Copy link
Copy Markdown
Contributor

@mvgreen mvgreen commented Mar 12, 2023

Енамы в ответах для Reports API неправильно парсятся, gson не может найти подходящего значения и всегда ставит null.

@mvgreen mvgreen marked this pull request as ready for review March 12, 2023 09:39
@mvgreen mvgreen requested a review from Alexis2004 March 12, 2023 09:40
@mvgreen mvgreen self-assigned this Mar 12, 2023
Copy link
Copy Markdown
Contributor

@Alexis2004 Alexis2004 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так делать нельзя, ты притащил в общий пакет аннотацию SerializedName, которые является специфичной для конкретного сериализатора, а значит должна использоваться только в пакете com.ecwid.apiclient.v3.jsontransformer.gson. Тут у тебя есть две опции, простая и сложная:

  1. простая: поступиться неймингом enum'ов, как это сделано в ряде других мест и назвать enum-константу также как, она названа в API, то есть в camelCase
  2. сложная: сделать то что давно ни у кого не доходят руки – это использовать нашу собственную аннотацию JsonFieldName и написать универсальные сериализатор для enum'ов, который будет учитывать эту аннотацию (как-то вот так))

@Alexis2004 Alexis2004 merged commit 98f1eb0 into master Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants