-
Notifications
You must be signed in to change notification settings - Fork 43
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
Refactor URIDecoder/URIParser to improve handling of the deepObject style #127
Refactor URIDecoder/URIParser to improve handling of the deepObject style #127
Conversation
PR is in draft as I need to add missing doc comments and a few polishing steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really glad we're pushing this feature along. I've left some comments. Can I assume that all the new tests you added previously didn't work? If not, could you indicate which of them previously failed as I'd like to give those a little extra attention.
Sources/OpenAPIRuntime/URICoder/Decoding/URIValueFromNodeDecoder+Single.swift
Outdated
Show resolved
Hide resolved
Sources/OpenAPIRuntime/URICoder/Decoding/URIValueFromNodeDecoder+Unkeyed.swift
Outdated
Show resolved
Hide resolved
Sources/OpenAPIRuntime/URICoder/Decoding/URIValueFromNodeDecoder+Unkeyed.swift
Outdated
Show resolved
Hide resolved
Sources/OpenAPIRuntime/URICoder/Decoding/URIValueFromNodeDecoder+Unkeyed.swift
Outdated
Show resolved
Hide resolved
Sources/OpenAPIRuntime/URICoder/Decoding/URIValueFromNodeDecoder.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Si Beaumont <[email protected]>
Co-authored-by: Si Beaumont <[email protected]>
…er+Single.swift Co-authored-by: Si Beaumont <[email protected]>
All the previous tests passed previously, we just changed the tested abstractions which forced me to refractor the tests too. The only new functionality is the deepObject support, so tests related to that style are new. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! I left one more comment but it's not a requirement.
Motivation
As part of apple/swift-openapi-generator#259, adding deepObject parameter style support, the initial PR wasn't complete.
And once we dug more into it, turns out the original implementation of the URIDecoder/URIParser didn't really lend themselves well for handling deepObject, and the recent additions of supporting arrays within dictionaries (#120) further confused the implementation.
Modifications
Refactored URIParser/URIDecoder with a clearer understanding of the current requirements. It's now much easier to follow and embraces the fact that each of the 7 variants of URI coding we support (form exploded, form unexploded, simple exploded, simple unexploded, form data exploded, form data unexploded, and now deepObject exploded) are similar, but still different in subtle ways.
This new implementation doesn't try as hard to share code between the implementations, so might at first sight appear to duplicate code. The original implementation had many methods with many configuration parameters and utility methods with a high cyclomatic complexity, which made it very hard to reason about. We did away with that.
While there, I also made some minor improvements to the serialization path, which allows cleaner round-tripping tests.
Result
A more maintainable and more correct URI decoder/parser implementation.
Test Plan
Added many more unit tests that test the full matrix of supported styles and inputs.