In my project, we have 1000+ fixtures (mock JSON) files. I am required to find a way to remove all these JSON files, and use .mock()
methods instead. Here is an example:
struct Person {
var name: String?
var age: Int
}
The hardcoded JSON (fixture) is as follows:
{
"__typename": "Person",
"name": "Sarthak",
"age": 27
}
I want a mock method such as
static func mockPerson() -> Person? {
.init(name: "Sarthak", age: 27)
}
Now, I can manually change this, but is there a way to automate something like this for 1000+ fixtures that I have/?
Maybe __typename
can be mapped.