diff --git a/languages/swift/swift-codegen-reference/Sources/SwiftCodegenReference.swift b/languages/swift/swift-codegen-reference/Sources/SwiftCodegenReference.swift index fe7d1174..d4c0903e 100644 --- a/languages/swift/swift-codegen-reference/Sources/SwiftCodegenReference.swift +++ b/languages/swift/swift-codegen-reference/Sources/SwiftCodegenReference.swift @@ -199,7 +199,7 @@ public struct ObjectWithEveryType: ExampleClientModel { self.uint32 <- map["uint32"] self.int64 <- map["int64"] self.uint64 <- map["uint64"] - self.`enum` <- map["enum"] // TODO + self.`enum` <- map["enum"] is String ? Enumerator(string: map["enum"] as String) : Enumerator.foo // TODO self.object <- map["object"] // TODO self.array <- map["array"] // TODO self.record <- map["record"] // TODO diff --git a/languages/swift/swift-codegen-reference/Tests/ObjectWithEveryTypeTest.swift b/languages/swift/swift-codegen-reference/Tests/ObjectWithEveryTypeTest.swift index a1cdb093..ba521b82 100644 --- a/languages/swift/swift-codegen-reference/Tests/ObjectWithEveryTypeTest.swift +++ b/languages/swift/swift-codegen-reference/Tests/ObjectWithEveryTypeTest.swift @@ -4,9 +4,39 @@ import XCTest final class ObjectWithEveryTypeTests: XCTestCase { let location = "../../../tests/test-files/ObjectWithEveryType.json" - let control = ObjectWithEveryType() + let control = ObjectWithEveryType( + string: "", + boolean: false, + timestamp: targetDate, + float32: 1.5, + float64: 1.5, + int8: 1, + uint8: 1, + int16: 10, + uint16: 10, + int32: 100, + uint32: 100, + int64: 1000, + uint64: 1000, + enum: Enumerator.baz, + object: NestedObject(id: "1", content: "hello world"), + array: [true, false, false], + record: Dictionary(dictionaryLiteral: ("A", true), ("B", false)), + discriminator: Discriminator.c( + DiscriminatorC( + id: "", + name: "", + date: targetDate + ) + ), + any: "hello world") func testFromJson() throws { - + let objectJson = try String(contentsOfFile: location, encoding: .utf8) + let result1 = ObjectWithEveryType(JSONString: objectJson) ?? ObjectWithEveryType() + let result2 = ObjectWithEveryType(JSONString: control.toJSONString() ?? "") ?? ObjectWithEveryType() + XCTAssertEqual(result1, control) + XCTAssertEqual(result2, control) + XCTAssertEqual(result1, result2) } } \ No newline at end of file