Skip to content

Commit

Permalink
Make some required in schema to optionals
Browse files Browse the repository at this point in the history
  • Loading branch information
bblechman-ebay committed Jul 23, 2024
1 parent 7a4b71b commit 7807ccb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Sources/XCResultKit/Schema/TestArgument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Foundation
public struct TestArgument: XCResultObject {
public let parameter: TestParameter?
public let identifier: String?
public let description: String
public let description: String?
public let debugDescription: String?
public let typeName: String?
public let value: TestValue
Expand All @@ -28,7 +28,8 @@ public struct TestArgument: XCResultObject {
do {
parameter = xcOptional(element: "parameter", from: json)
identifier = xcOptional(element: "identifier", from: json)
description = try xcRequired(element: "description", from: json)
//Note schema says that description is required, but I found it to be missing when testing
description = xcOptional(element: "description", from: json)
debugDescription = xcOptional(element: "debugDescription", from: json)
typeName = xcOptional(element: "typeName", from: json)
value = try xcRequired(element: "value", from: json)
Expand Down
8 changes: 4 additions & 4 deletions Sources/XCResultKit/Schema/TestTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
import Foundation

public struct TestTag: XCResultObject {
public let identifier: String
public let identifier: String?
public let name: String
public let anchors: String
public let anchors: String?

public init?(_ json: [String: AnyObject]) {
do {
identifier = try xcRequired(element: "identifier", from: json)
identifier = xcOptional(element: "identifier", from: json)
name = try xcRequired(element: "name", from: json)
anchors = try xcRequired(element: "anchors", from: json)
anchors = xcOptional(element: "anchors", from: json)
} catch {
logError("Error parsing TestTag: \(error.localizedDescription)")
return nil
Expand Down
5 changes: 3 additions & 2 deletions Sources/XCResultKit/Schema/TestValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class TestValue: XCResultObject {
public let typeName: String?
public let fullyQualifiedTypeName: String?
public let label: String?
public let isCollection: Bool
//Required in schema, missing in practice
public let isCollection: Bool?
public let children: TestValue?

required public init?(_ json: [String: AnyObject]) {
Expand All @@ -34,7 +35,7 @@ public class TestValue: XCResultObject {
typeName = xcOptional(element: "typeName", from: json)
fullyQualifiedTypeName = xcOptional(element: "fullyQualifiedTypeName", from: json)
label = xcOptional(element: "label", from: json)
isCollection = try xcRequired(element: "isCollection", from: json)
isCollection = xcOptional(element: "isCollection", from: json)
children = xcOptional(element: "children", from: json)
} catch {
logError("Error parsing TestValue: \(error.localizedDescription)")
Expand Down

0 comments on commit 7807ccb

Please sign in to comment.