Skip to content

Instantly share code, notes, and snippets.

@Stickerbox
Created January 24, 2018 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stickerbox/a491df6c312d852a9d7d2efaae03a6fc to your computer and use it in GitHub Desktop.
Save Stickerbox/a491df6c312d852a9d7d2efaae03a6fc to your computer and use it in GitHub Desktop.
{% for struct in types.all.implementing.Codable|struct %}
{% ifnot struct.annotations.ignore %}
extension {{ struct.name }} {
enum CodingKeys: String, CodingKey {
{% for var in struct.storedVariables %}
{% if var.annotations.key %}
case {{ var.name }} = "{{ var.annotations.key }}"
{% endif %}
{% ifnot var.annotations.key %}
case {{ var.name }}
{% endif %}
{% endfor %}
}
}
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment