Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty additionalProperties dictionary encoding #103

Conversation

czechboy0
Copy link
Collaborator

@czechboy0 czechboy0 commented Apr 2, 2024

Motivation

Fixes apple/swift-openapi-generator#525.

Turns out that the mere act of creating a decoding container is meaningful and we skipped it as an optimization, causing JSONDecoder to fail for empty dictionaries when used in additional properties.

Modifications

Remove the extra guards that skipped creating a container, even when we already know there are no elements.

Result

No more failures when encoding empty dictionaries in additionalProperties.

Test Plan

Tested manually as this requirement seems to be coming out of JSONDecoder.

@czechboy0 czechboy0 merged commit 634b7eb into apple:main Apr 3, 2024
8 checks passed
@czechboy0 czechboy0 deleted the hd-fix-empty-additional-props-dictionary-encoding branch April 3, 2024 08:43
@czechboy0 czechboy0 added the semver/patch No public API change. label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty Dictionary fails to encode
2 participants