Swiftpack.co - TheInkedEngineer/Espresso-Martini as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by TheInkedEngineer.
TheInkedEngineer/Espresso-Martini 1.0.0
A Vapor-powered, Swift mock server for iOS, macOS applications as well as a local server.
⭐️ 11
🕓 2 weeks ago
iOS macOS linux macOS iOS
.package(url: "https://github.com/TheInkedEngineer/Espresso-Martini.git", from: "1.0.0")

Espresso Martini logo

Twitter SwiftLang badge

Espresso Martini

Espresso Martini is a vapor-powered mock server. It allows you you to mock HTTP requests easily, so you worry about the things that matter, and not have to wait on APIs to be live.

Just configure your request/response pairs, known as NetworkExchange, run the server, and you are good to go. Requests made to the configured hostname and port will be intercepted and the server will return any desired response.

It supports different types of data, response headers and all HTTP response codes.

The library is fully tested and documented.

1. Requirements and Compatibility

  • Xcode 13.2+
  • Swift 5.6+
  • iOS 13+
  • macOS 12+

When running on iOS you will get a threading warning, which is a known issue with NIO and can be safely ignored.

2. Roadmap

  • ☐ Add support for folder based request/response pairs
  • ☐ Add support for customised response based on query parameters
  • ☐ Add support for retry-able request
  • ☑ Add support for a global delay
  • ☑ Add support for a delay on a per networkExchange basis

3. Installation

Swift Package Manager

Package.swift

Open your Package.swift file and add the following as your dependency.

dependencies: [
  .package(url: "https://github.com/TheInkedEngineer/Espresso-Martini", from: "1.0.0")
]

Then add the following to your target's dependency:

targets: [
  .target(
    name: "MyTarget", 
    dependencies: [
      .product(name: "https://github.com/TheInkedEngineer/Espresso-Martini", package: "Espresso-Martini")
    ]
  )
]

Xcode

  1. Open your app in Xcode
  2. In the Project Navigator, click on the project
  3. in the Project panel, click on the project
  4. Go to the Package Dependencies tab
  5. Click on the + button
  6. Insert the https://github.com/TheInkedEngineer/Espresso-Martini url in the search bar and press Enter
  7. Click on the Add Package button
  8. Follow the Xcode's dialog to install the SDK

3. Documentation

The code for Espresso-Martini is fully documented. An DocC documentation will follow :).

4. How to use

As in-app package

  • Start by importing the mock server using import EMMockServer
  • Configure the mock server, either by using SimpleConfigurationProvider or creating your custom implementation of ServerConfigurationProvider
  • call run()

Server running on the mac

  • Download the project
  • Open Package.swift with Xcode
  • Add your requests to try? server.configure(using: ServerConfiguration(networkExchanges: Demo.networkExchanges)) inside of main.swift.
  • Hit run

5. Contribution

Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub

GitHub

link
Stars: 12
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Release Notes

1.0.0 - David Copperfield
2 weeks ago

Added

  • Match requests based on method + path components
  • Support for all response codes, response headers and the following response types:
    • empty
    • string
    • data
    • json
    • fileContent
  • Support for iOS 13+
  • Support for macOS 12+

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