From 3b1402ba7deb0bf3e4f6536887bf99fe7b1b3378 Mon Sep 17 00:00:00 2001 From: Alessio Zurru Date: Wed, 1 Jul 2020 11:15:07 +0200 Subject: [PATCH] Provides a default nil value for optional init parameters 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 bb900d741586..086bf4bce74f 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}}