[Swift] Add optional parameters to init when unwrapRequired is true#3813
Conversation
|
@mwgray thanks for the PR. Would it be possible to keep the existing
|
|
It's possible, but having both generated at the same time creates ambiguity for the compiler. I'm using Swift 2.3, and it causes a compiler error if both are generated(not sure about 2.2, or 3.0): It's not clear to me what this change does to prevent backwards compatibility. The signature is the same as the previously generated code(hence the ambiguity) If you don't set optionals in a init, they are set to the default values, which in this case is nil. In both init functions, all values are being set, it's just the compiler sets password for you in init(username:). |
|
OK. Thanks for the explanation. |
Upgrade NoteWhen |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)2.3.0branch for breaking (non-backward compatible) changes.Description of the PR
Previously when running with unwrapRequired=true, the init function would only list required parameters. I added the optional ones with default values to nil.