There is no optional detection in v2 swit templates
Closed this issue · 0 comments
JohnReeze commented
v1 of surfgen could detect that entity object consist of other entities that are optional so the generated file could have been built:
public let anotherModel: AnotherModel?
...
public func toDTO() throws -> MyModel {
return try .init(anotherModel: anotherModel?.toDTO()) // optional sign matters
But current templates and v2 surfgen only generate
public func toDTO() throws -> MyModel {
return .init(anotherModel: anotherModel.toDTO()) // absence of optional sign
which obviously leads to Value of optional type 'AnotherModel?' must be unwrapped to refer to member 'toDTO' of wrapped base type 'AnotherModel'