update doc, better code format

This commit is contained in:
William Cheng 2019-08-28 21:26:22 +08:00 committed by Daiki Matsudate
parent 0c8481b8c7
commit 8b2e25e4da
2 changed files with 2 additions and 15 deletions

View File

@ -13,7 +13,6 @@ sidebar_label: swift4
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|projectName|Project name in Xcode| |null|
|responseAs|Optionally use libraries to manage response. Currently PromiseKit, RxSwift are available.| |null|
|unwrapRequired|Treat 'required' properties in response as non-optional (which would crash the app if api returns null as opposed to required option specified in json schema| |null|
|objcCompatible|Add additional properties and methods for Objective-C compatibility (default: false)| |null|
|podSource|Source information used for Podspec| |null|
|podVersion|Version used for Podspec| |null|

View File

@ -124,8 +124,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
// Added for Objective-C compatibility
"id", "description", "NSArray", "NSURL", "CGFloat", "NSSet", "NSString", "NSInteger", "NSUInteger",
"NSError", "NSDictionary"
)
);
)
);
reservedWords = new HashSet<>(
Arrays.asList(
@ -847,18 +847,6 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
// The default template code has the following logic for
// assigning a type as Swift Optional:
//
// {{^unwrapRequired}}?{{/unwrapRequired}}
// {{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}
//
// which means:
//
// boolean isSwiftOptional = !unwrapRequired || (unwrapRequired && !property.required);
//
// We can drop the check for unwrapRequired in (unwrapRequired && !property.required)
// due to short-circuit evaluation of the || operator.
boolean isSwiftScalarType = property.isInteger || property.isLong || property.isFloat
|| property.isDouble || property.isBoolean;
if ((!property.required || property.isNullable) && isSwiftScalarType) {