swagger-api / swagger-api/swagger-codegen
[Swift 5] Model struct initializer should have parameters set to nil by default
Open
@HugoMario is already working on this.
Since Nov 4, 2020.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
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
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.