-
Notifications
You must be signed in to change notification settings - Fork 51
Converter SPI methods for required fields should return non-optional types #20
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
Conversation
### Motivation `getRequiredRequestBodyAsText` currently returns `C?` instead of `C`. As the value should be required an optional in the return is causing issues. The errors are `Cannot convert value of type 'C?' to specified type` and `Cannot infer contextual base in reference to member 'text'` ### Modifications Change the return type of `getRequiredRequestBodyAsText` ### Result Code using a required requestBody now compiles without errors.
Thanks for the fix, this was an oversight on my part. |
getRequiredRequestBodyAsText
@swift-server-bot test this please |
@sikevux this is great, thank you. Is it possible to add a test case for this? Specifically something that uses the code that previously world not compile? |
Agreed, we have tests already, but adding one that does something like
|
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.
Marking as needs work based on the conversation above.
Ugh, I took a quick look and we have the same issue in a few more places:
Can you please fix those too? 🙏 |
### Modifications All `test_get*` tests for the converters now explicitly set the expected type. Fix the original bug for the following functions as well: * `getRequiredHeaderFieldAsText<T: _StringConvertible>` * `getRequiredHeaderFieldAsText` ### Results All tests pass without issue, after applying the fix ### Test plan Made the changes to the unit tests. Observed code not compiling anymore. Applied fixes. Tests now compile and pass.
Yeah. Modified all the |
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.
Great, thank you!
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.
Awesome. Thanks @sikevux!
Motivation
getRequiredRequestBodyAsText
currently returnsC?
instead ofC
. As the value should be required an optional in the return is causing issues.The errors are
Cannot convert value of type 'C?' to specified type
andCannot infer contextual base in reference to member 'text'
Modifications
Change the return type of
getRequiredRequestBodyAsText
Result
Code using a required requestBody now compiles without errors.