-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Decode response header data from Codable userInfo #565
Merged
Conversation
This file contains 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
Now we pass the response via uesrInfo to the decoder and decode header, body and payload in the init(from) function, we can use the JSONDecoder for decoding responses.
Codecov Report
@@ Coverage Diff @@
## 7.x.x #565 +/- ##
==========================================
+ Coverage 77.38% 78.87% +1.49%
==========================================
Files 71 71
Lines 7447 6292 -1155
==========================================
- Hits 5763 4963 -800
+ Misses 1684 1329 -355
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
0xTim
approved these changes
Jul 18, 2023
Co-authored-by: Tim Condon <[email protected]>
adam-fowler
added a commit
that referenced
this pull request
Jul 24, 2023
* Rename HTTPBody to AWSHTTPBody * Add AWSResponse to Codable userInfo * Add decode functions for AWSResponse * ResponseContainer for decoding * Fix tests after userInfo changes * Remove DictionaryDecoder Now we pass the response via uesrInfo to the decoder and decode header, body and payload in the init(from) function, we can use the JSONDecoder for decoding responses. * Fix tests * Re-organise root element code * Fix after merge * Update Sources/SotoCore/Encoder/ResponseContainer.swift Co-authored-by: Tim Condon <[email protected]> --------- Co-authored-by: Tim Condon <[email protected]>
adam-fowler
added a commit
that referenced
this pull request
Jul 29, 2023
* Rename HTTPBody to AWSHTTPBody * Add AWSResponse to Codable userInfo * Add decode functions for AWSResponse * ResponseContainer for decoding * Fix tests after userInfo changes * Remove DictionaryDecoder Now we pass the response via uesrInfo to the decoder and decode header, body and payload in the init(from) function, we can use the JSONDecoder for decoding responses. * Fix tests * Re-organise root element code * Fix after merge * Update Sources/SotoCore/Encoder/ResponseContainer.swift Co-authored-by: Tim Condon <[email protected]> --------- Co-authored-by: Tim Condon <[email protected]>
adam-fowler
added a commit
that referenced
this pull request
Aug 12, 2023
* Rename HTTPBody to AWSHTTPBody * Add AWSResponse to Codable userInfo * Add decode functions for AWSResponse * ResponseContainer for decoding * Fix tests after userInfo changes * Remove DictionaryDecoder Now we pass the response via uesrInfo to the decoder and decode header, body and payload in the init(from) function, we can use the JSONDecoder for decoding responses. * Fix tests * Re-organise root element code * Fix after merge * Update Sources/SotoCore/Encoder/ResponseContainer.swift Co-authored-by: Tim Condon <[email protected]> --------- Co-authored-by: Tim Condon <[email protected]>
adam-fowler
added a commit
that referenced
this pull request
Dec 24, 2023
* Rename HTTPBody to AWSHTTPBody * Add AWSResponse to Codable userInfo * Add decode functions for AWSResponse * ResponseContainer for decoding * Fix tests after userInfo changes * Remove DictionaryDecoder Now we pass the response via uesrInfo to the decoder and decode header, body and payload in the init(from) function, we can use the JSONDecoder for decoding responses. * Fix tests * Re-organise root element code * Fix after merge * Update Sources/SotoCore/Encoder/ResponseContainer.swift Co-authored-by: Tim Condon <[email protected]> --------- Co-authored-by: Tim Condon <[email protected]>
adam-fowler
added a commit
that referenced
this pull request
Apr 5, 2024
* Rename HTTPBody to AWSHTTPBody * Add AWSResponse to Codable userInfo * Add decode functions for AWSResponse * ResponseContainer for decoding * Fix tests after userInfo changes * Remove DictionaryDecoder Now we pass the response via uesrInfo to the decoder and decode header, body and payload in the init(from) function, we can use the JSONDecoder for decoding responses. * Fix tests * Re-organise root element code * Fix after merge * Update Sources/SotoCore/Encoder/ResponseContainer.swift Co-authored-by: Tim Condon <[email protected]> --------- Co-authored-by: Tim Condon <[email protected]>
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.
One of the things that has bugged me most about Soto is we had to copy our own version of JSONDecoder(), to extract the DictionaryDecoding from it. This means we were dependent on an old version of the decoder which hasn't kept up with changes being made to the original. This'll be more important as we move to the swift foundation which has introduced more optimisations.
This PR gets rid of our dependency on DictionaryDecoder and allows us to use the latest JSONEncoder. It creates a container that holds the raw response which is passed to the decoder via userInfo. It is then the responsibility of the individual
init(decoder:)
functions to extract the values from the correct place. Because the individual response shapes are now responsible for extracting their data from the correct placegenerateOutputShape
is considerably simplified.See companion commits soto-project/soto-codegenerator#73 and soto-project/soto#685