Skip to content

andre-tirta/auto-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auto-key

A Swift macro that automatically generates CodingKeys enums for Codable structs, classes and actors. It converts property names from camelCase to snake_case by default and supports custom key mapping via the @KeyAlias("custom_key") attribute. No more manual key mapping—just annotate and go.

Usage:

@AutoKey
struct SomeModel: Codable {
    let someString: String?
    let someInt: Int?
    @KeyAlias("some_other_int") let anotherInt: Int?
}

will be expanded to:

struct SomeModel: Codable {
    let someString: String?
    let someInt: Int?
    let anotherInt: Int?
    private enum CodingKeys: String, CodingKey {
      case someString = "some_string"
      case someInt = "some_int"
      case anotherInt = "some_other_int"
    }
}

About

A Swift macro that automatically generates CodingKeys enums for Codable structs, classes and actors.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages