-
-
Notifications
You must be signed in to change notification settings - Fork 6
Improve 'Any?' Unwrap #74
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
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.
Looks fine
Thanks for this
|
You need to run swift format on your code |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #74 +/- ##
==========================================
+ Coverage 89.86% 89.90% +0.03%
==========================================
Files 18 19 +1
Lines 1382 1387 +5
==========================================
+ Hits 1242 1247 +5
Misses 140 140 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
swift format modified code that I didn't change - so I changed those parts back for clarity - I can rerun it full if you want - I'm assuming the swift format version got bumped and now wants "return" removed in certain cases... |
oh ok. Something must have got merged without the formatting done. Are you happy adding those changes back in even if they are unrelated |
|
Done - see: 204b0c2 |
An object passed to swift-mustache may contain something of the type:
[String: Any?], which is good, as this is what libraries such as swift-openapi-generator return for things like their "additionalProperties" property, which contains a "catch all" of properties that are available, but were not actually specified in the openapi schema file.swift-mustache accepts these objects, but doesn't handle them well: swift-mustache needs to unwrap the optionals before passing them to
String(describing: )so thatString(describing: )doesn't output "Optional("foobar") - and this it does already correctly. But when you unwrap anAny?, you get anAny- in swift, anAnycan still contain a wrapped optional. So if you take this codeThen the test will fail, because
String(describing: )will returnOptional("Test")and notTest, because what is describing is still a wrapped value, and not the actual value itself.This PR addresses the problem by checking if a value is still wrapped and unwrapping it before passing it to
String( describing: )and adds a test for this isue.