Closed rainedAllNight closed 6 years ago
You can't within Xcode at the moment, but you can download our CLI or use https://app.quicktype.io
How would you like to customize them?
I am using the framework named ObjectMapper, and I want to generate code that works for it.
Ah, very good.
We have some prelimary work to let you customize the output using handlebars but it's very prelimary. You can find an option for this in our CLI.
Another option is to actually change https://GitHub.com/quicktype/quicktype to add an option to do what you want. This is your best route for now. Would you mind filing an issue on that repo with some sample code for what you'd like the output to look like?
Ok,Here's a simple example.
struct VehicleBrandModel {
var brandName: String = ""
var brandPy: String = ""
var brandImage: URL?
}
extension VehicleBrandModel: Mappable {
init?(map: Map) {
}
mutating func mapping(map: Map) {
brandName <- map["brand_name"]
brandPy <- map["brand_py"]
brandImage <- (map["brand_img"], URLTransform())
}
}
Why do you want to use ObjectMapper? Does it do anything that quicktype doesn't do?
Do you mean Codeable?
Yes. 😄
I found that it had some defects in a particular structure and type. so I keep using ObjectMapper now
Would you mind sharing what those defects are? We'd like to add them to our tests, or help generate a workaround without requiring you to abandon Codables.
And In any case, is it always a more friendly way to support a custom🙂
Alright, we have an upstream issue for this: https://github.com/quicktype/quicktype/issues/223
ok, thanks
How do I customize the generation rules?