Skip to content

Updated DTOs for conditional encoding#273

Merged
TestaDiRapa merged 1 commit intomainfrom
feature/add-conditional-encoding
Feb 5, 2026
Merged

Updated DTOs for conditional encoding#273
TestaDiRapa merged 1 commit intomainfrom
feature/add-conditional-encoding

Conversation

@TestaDiRapa
Copy link
Collaborator

@TestaDiRapa TestaDiRapa commented Feb 5, 2026

Scope of the PR:
we want to avoid generating fields that are deprecated on the SDK data model. However this will not work as we use strict deserialization in the SDK, and the current serialization method still puts empty collections because of JsonInclude.Include.NON_NULL.

The proposed solution is:

  • Extend the functionality of the existing custom Spring encoder to accept 2 mappers: one with setSerializationInclusion(JsonInclude.Include.NON_NULL) and the other with setSerializationInclusion(JsonInclude.Include.NON_EMPTY). The latter wil be used only if the header Cardinal-Json-Mode with value NOT_EMPTY is present in the request. This way, we can leverage the non empty serializaztion strategy for the SDK but still allow the previous behavior for the old typescript SDK.

  • Remove the @JsonInclude(JsonInclude.Include.NON_NULL) annotation in DTO classes that have deprecated fields. This has no impact as the current mapper already has the JsonInclude.Include.NON_NULL default behaviour.

  • Add the @param:JsonInclude(JsonInclude.Include.NON_NULL) annotation to fields with nullable collection types.

@TestaDiRapa TestaDiRapa merged commit 767a833 into main Feb 5, 2026
@TestaDiRapa TestaDiRapa deleted the feature/add-conditional-encoding branch February 5, 2026 12:46
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.

1 participant