Files
divkit/api_generator/tests/references/not_templates_swift/EntityWithJsonProperty.swift
T
booster abd997bf3d Enabled expressions for playerSettingsPayload
commit_hash:a4ed6e0a2df2ae78420a3828da105b083649b129
2026-03-14 22:52:27 +03:00

60 lines
1.7 KiB
Swift

// Generated code. Do not modify.
import CommonCore
import Foundation
import Serialization
public final class EntityWithJsonProperty: @unchecked Sendable {
public static let type: String = "entity_with_json_property"
public let jsonProperty: Expression<[String: Any]> // default value: { "key": "value", "items": [ "value" ] }
public func resolveJsonProperty(_ resolver: ExpressionResolver) -> [String: Any] {
resolver.resolveDict(jsonProperty) ?? (try! JSONSerialization.jsonObject(jsonString: """
{
"key": "value",
"items": [
"value"
]
}
""") as! [String: Any])
}
public convenience init(dictionary: [String: Any], context: ParsingContext) throws {
self.init(
jsonProperty: try dictionary.getOptionalExpressionField("json_property", context: context)
)
}
init(
jsonProperty: Expression<[String: Any]>? = nil
) {
self.jsonProperty = jsonProperty ?? .value((try! JSONSerialization.jsonObject(jsonString: """
{
"key": "value",
"items": [
"value"
]
}
""") as! [String: Any]))
}
}
#if DEBUG
// WARNING: this == is incomplete because of [String: Any] in class fields
extension EntityWithJsonProperty: Equatable {
public static func ==(lhs: EntityWithJsonProperty, rhs: EntityWithJsonProperty) -> Bool {
return true
}
}
#endif
extension EntityWithJsonProperty: Serializable {
@_optimize(size)
public func toDictionary() -> [String: ValidSerializationValue] {
var result: [String: ValidSerializationValue] = [:]
result["type"] = Self.type
result["json_property"] = jsonProperty.toValidSerializationValue()
return result
}
}