Conversation
### Motivation OpenAPIValueContainer, OpenAPIObjectContainer, and OpenAPIArrayContainer previously exposed var value with an unvalidated public setter. This allowed callers to mutate containers with unsupported types that would have been rejected by the initializers. Resolves apple/swift-openapi-generator#782. ### Modifications - Deprecate direct mutation via the setter on value across OpenAPIValueContainer, OpenAPIObjectContainer, and OpenAPIArrayContainer, backed by a private stored property _value. - Add throwing mutating methods setValidatedValue and setValue(validating:) to replace or update container values with runtime type validation. - On OpenAPIObjectContainer, add setValidatedValue(_:forKey:) and setValue(validating:forKey:) to support validated key-level mutations. - Add comprehensive unit tests in Test_OpenAPIValue.swift verifying accepted values, rejected unsupported types, and preservation of state on failure. - Add tests in Test_Deprecated.swift verifying backward-compatible behavior of the deprecated setters. ### Result Callers have validating mutation APIs to safely update dynamic value containers, and direct assignments to value produce deprecation warnings directing callers to the validating methods. ### Test Plan Executed test suite via swift test: 239 tests executed, 0 failures. Formatted and verified with swift-format lint.
czechboy0
self-requested a review
September 26, 2026 04:21
czechboy0
approved these changes
Oct 2, 2026
czechboy0
left a comment
Contributor
There was a problem hiding this comment.
Thanks, @shubhransh-gupta 🙏
czechboy0
enabled auto-merge (squash)
October 2, 2026 13:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
OpenAPIValueContainer,OpenAPIObjectContainer, andOpenAPIArrayContainerpreviously exposedvar valuewith an unvalidated public setter. This made it possible to mutate containers with unsupported types that would be rejected by their initializers.Resolves apple/swift-openapi-generator#782.
Modifications
valueacrossOpenAPIValueContainer,OpenAPIObjectContainer, andOpenAPIArrayContainer, backed by a private stored property_value.setValidatedValueandsetValue(validating:)to replace container values with runtime type validation.OpenAPIObjectContainer, addsetValidatedValue(_:forKey:)andsetValue(validating:forKey:)to support validated key-level mutations.Test_OpenAPIValue.swiftverifying accepted values, rejected unsupported types, and preservation of state on failure.Test_Deprecated.swiftverifying backward-compatible behavior of the deprecated setters.Result
Callers have validating mutation APIs to safely update dynamic value containers, and direct assignments to
valueproduce deprecation warnings directing callers to the validating methods.Test Plan
Executed test suite via
swift test: 239 tests executed, 0 failures.Formatted and verified with
swift-format lint.