-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
Just fixed Date parsing (my custom template was using a custom DateFormatter). |
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.
Side questions:
-
I'm surprised there were only one unit test to change and not more 😉 I hope we cover all the possible cases
-
For the end user, I wonder what's best:
- To only decode attributes that have their
JSONKey
user-info set, and ignore all the attributes without that key - Or to decode all attributes (and if they have no
JSONKey
, infer thatJSONKey
to be the same name as the attribute itself) and require aJSONIgnored
to explicitly exclude keys
My PoV is:
- Using the new
JSONIgnored
has the advantage of not having to repeat theJSONKeyPath
if 80% of your keys have the same name as your attribute. But that feels like adding a little complexity in the logic / rules and understanding for users of gyro. - OTOH, only decoding attributes which have
JSONKeyPath
explicitly set is more easy to understand as a global logic (and explain in the documentation), but requires to set theJSONKeyPath
also for keys that have the same JSON key and attribute name
Open for discussion
lib/templates/decodable/README.md
Outdated
@@ -34,3 +34,6 @@ extension Shop: Decodable { | |||
} | |||
} | |||
``` | |||
# Specific JSON tasks |
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.
Depending on your markdown interpreter, some Markdown renderers are a little strict and expect an empty line after section titles, otherwise they won't render it as titles. So better add empty newlines after those ;)
As discussed, for now we mostly have the case to parse all the attributes contained in our models. The specific need looks more to be to ignore a specific property during parsing, detected by checking the I think it's more efficient this way, even if the usage could be a little bit more complex to understand ;) |
Ok, fair enough 😉 |
-- Allow to avoid decodable parsing generation for specific attributes