title: Codable and CodingKeys
body: <p>I'm trying to implement a protocol with similar functionality to how <code>Codable</code> uses the <code>CodingKeys</code> enum.</p>
  
  <p>With <code>Codable</code> and <code>CodingKeys</code>, if you don't implement a case in the <code>CodingKeys</code> enum for every property on the <code>Codable</code> object, it causes a compiler error stating that the object does not conform to the protocol.</p>
  
  <p>I have looked through documentation, and the only thing I can find related to the <code>Codable</code> (<code>Encodable</code> and <code>Decodable</code>) protocol is the requirement to implement the <code>func encode(to encoder: Encoder)</code> and <code>init(from decoder: Decoder)</code> functions.</p>
  
  <p>The closest I've gotten is defining a protocol as follows:</p>
  
  <pre><code>protocol TestProtocol {
      associatedType Keys: CodingKey
  }
  </code></pre>
  
  <p>This requires the implementer to have a <code>Keys</code> property that conforms to <code>CodingKey</code>, but it does not enforce the requirement to have a case for all properties. Additionally, you cannot declare the <code>Keys</code> property as private like you can with <code>Codable</code>.</p>
  
  <p>Are <code>Codable</code> and <code>CodingKeys</code> handled at a deeper level than what is exposed through the APIs?</p>
  
  <p>If not, is there a way to implement the <code>CodingKeys</code> functionality outside of <code>Codable</code>?</p>