quicktype
quicktype copied to clipboard
Feature: Add swift default init()
It would be super cool if for swift there could be a default init option where it would add a default init() to be able to convert the following
struct Sale: Codable {
var code: Int
var desc: String
}
into something like this
struct Sale: Codable {
var code: Int
var desc: String
init(){
self.code = 0
self.desc = ""
}
init(code: Int, desc: String){
self.code = code
self.desc = desc
}
}
I would actually really like it if quicktype would read the "default" from the schema file. Example:
{
"title": "Codable",
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "number"
"default": 0 // <---------- HERE
},
"desc": {
"type": "string"
"default": "" // <---------- HERE
},
}
}
This way, we can control what those default values would be when they are not provided by the json data file.