Swiftpack.co -  Package - ceperai/APIRequestMock
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
ceperai/APIRequestMock
Allows to mock requests.
.package(url: "https://github.com/ceperai/APIRequestMock.git", from: "1.0.0")

APIRequestMock

Tool to mock api responses. Just register APIRequestMock in url session. ResourceNames is an array of json files with request responses in Bundle.main.

    let configuration = URLSessionConfiguration.default
    APIRequestMock.register(resourceNames: ["responses.json"], in: configuration)

Here is an example of resources.json file:

"""
[
    {
        "enabled": true,
        "uri": ["https://sampleurl.io/api/v1/items"],
        "headers": {"api_token": "123"},
        "comment": "Sample mocked response",
        "value": [
            { "value": 1 },
            { "value": 2 },
            { "value": 3 },
        ]
    }
]
"""

GitHub

link
Stars: 0
Last commit: 1 week ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco