swift-codable
CommunityEncode and decode Swift models reliably
AuthorDFly7
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Simplifies converting unstructured API payloads into strongly typed Swift data models and reduces runtime decoding errors by providing idiomatic Codable patterns and encoder/decoder configurations.
Core Features & Use Cases
- Automatic and manual conformance: When all properties are Codable the compiler synthesizes conformance, and the guide shows when to use Decodable or Encodable separately.
- Key remapping and nested flattening: Use CodingKeys and nested containers to rename JSON keys and flatten nested objects into model properties.
- Custom encoding/decoding: Implement init(from:) and encode(to:) for timestamp conversions, default values, and validation.
- Date, data, and key strategies: Configure JSONDecoder and JSONEncoder for ISO8601, timestamps, base64 data, and snake_case conversion.
- Robust array handling: Patterns for decoding heterogeneous arrays and lossy array decoding to skip invalid elements.
- Platform integration: Examples for use with URLSession responses, SwiftData composite attributes, PropertyListEncoder/Decoder, and AppStorage via RawRepresentable.
- Best practices and checklist: Common mistakes, deterministic encoder settings for tests, and a review checklist for production-ready models.
Quick Start
Create Swift Codable structs for the provided JSON, mapping snake_case keys to camelCase, decoding ISO8601 dates, and skipping malformed elements in arrays.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: swift-codable Download link: https://github.com/DFly7/iOS-FastAPI-Supabase-AI/archive/main.zip#swift-codable Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.