Skip to content

Commit

Permalink
Provides a default nil value for optional init parameters (#6827)
Browse files Browse the repository at this point in the history
The following change can be helpful to create Swift model objects more simply, in particular when they have many parameters.
In addition, projects switching from swagger-codegen to OpenAPI will not encounter compilation errors and will not need to refactor old code
  • Loading branch information
alessiozurru authored Jul 1, 2020
1 parent fa97333 commit 1fe7d70
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{{/allVars}}

{{#hasVars}}
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{#required}}{{#isNullable}}?{{/isNullable}}{{/required}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allVars}}) {
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{#required}}{{#isNullable}}?{{/isNullable}}{{/required}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allVars}}) {
{{#allVars}}
self.{{name}} = {{name}}
{{/allVars}}
Expand Down

0 comments on commit 1fe7d70

Please sign in to comment.