From 1fe7d703d7785a3e2a87bb88ceab926f160b355f Mon Sep 17 00:00:00 2001 From: Alessio Zurru Date: Wed, 1 Jul 2020 18:13:08 +0200 Subject: [PATCH] Provides a default nil value for optional init parameters (#6827) 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 --- .../src/main/resources/swift5/modelObject.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/swift5/modelObject.mustache b/modules/openapi-generator/src/main/resources/swift5/modelObject.mustache index bb900d74158..086bf4bce74 100644 --- a/modules/openapi-generator/src/main/resources/swift5/modelObject.mustache +++ b/modules/openapi-generator/src/main/resources/swift5/modelObject.mustache @@ -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}}