-
Notifications
You must be signed in to change notification settings - Fork 6k
Open
Milestone
Description
Description
Hi!
As in the title - model struct initializers should have parameters set to nil by default.
Swagger-codegen version
3.0.22
Swagger declaration file content or url
{
"swagger": "2.0",
"definitions": {
"Category": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32",
"description": "category ID"
},
"name": {
"type": "string",
"description": "category name",
"example": "Home"
}
}
}
}
}Command line used for generation
java -jar .../swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l swift5 -i swagger.json -c config.json -o .
Steps to reproduce
Suggest a fix/enhancement
Generated code should look like below:
public struct Category: Codable {
/** category ID */
public var _id: Int?
/** category name */
public var name: String?
public init(_id: Int? = nil, name: String? = nil) {
self._id = _id
self.name = name
}
}But currently looks like this:
public struct Category: Codable {
/** category ID */
public var _id: Int?
/** category name */
public var name: String?
public init(_id: Int?, name: String?) {
self._id = _id
self.name = name
}
}