Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ extension Optional: ConvertibleToModelOutput where Wrapped: ConvertibleToModelOu
}
}

@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
extension Optional: ConvertibleFromModelOutput where Wrapped: ConvertibleFromModelOutput {
public init(_ content: ModelOutput) throws {
if case .null = content.kind {
self = nil
return
}
self = try Wrapped(content)
}
}

@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
extension Bool: FirebaseGenerable {
public static var jsonSchema: JSONSchema {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public struct ModelOutput: Sendable, CustomDebugStringConvertible, FirebaseGener
return nil
}

if case .null = value.kind {
return nil
}

return try Value(value)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ extension FirebaseGenerableMacro: MemberMacro {

propertySchemas.append(propertySchemaString)

let propertyTypeString = info.type.trimmed.description
var propertyTypeString = info.type.trimmed.description
if let optionalType = info.type.as(OptionalTypeSyntax.self) {
propertyTypeString = optionalType.wrappedType.trimmed.description
}
partiallyGeneratedProperties
.append("var \(info.name): \(propertyTypeString).Partial?")
partiallyGeneratedInits
Expand Down
Loading
Loading