fix(clients): handle empty xml tags #3623
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Resolves: #3585
Follow up to: #885 #914 #919 #955
Description
The underlying xml parser used by the SDK(fast-xml-parser) parses the self-closing tags(e.g.
<Filter/>
) to empty string(e.g.{ "Filter": "" }
). The mentioned PRs(#914 #919 #955) adds early return to the parser. If the parsed value of the member is empty string, it will return default empty value. If the member is aMap
, then the empty value is{}
; If the member is aCollection(List)
, then the empty value is[]
.However the generated code has 2 issues:
The early if statement was not effective as the later if statement will still attempt to parse the subordinary shape out of
""
. For examplefix:
The Union shape as a special type of structure that requires exactly one member, should also be skipped if serialized in empty tag, just like
Map
andCollection
.This change fixes both issues.
Testing
Unit-test
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.