A syntactic sugar library for Moya that simplifies API endpoint definitions in Swift.
MoyaSugar is a syntactic sugar library for Moya, a popular networking abstraction layer in Swift. It simplifies the process of defining API endpoints by reducing boilerplate code, allowing developers to declare routes, parameters, and headers more concisely. It solves the problem of Moya's verbose endpoint definitions, which require writing code in multiple places for each endpoint.
Swift developers using Moya for networking in iOS or macOS applications, especially those working on larger projects where Moya's enum-based endpoints become cumbersome to maintain.
Developers choose MoyaSugar because it drastically reduces the amount of code needed per endpoint, improves readability, and maintains full compatibility with Moya's features. Its unique selling point is the elegant syntax that combines HTTP method, path, parameters, and encoding into minimal, clear declarations.
🍯 Syntactic sugar for Moya
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Combines Moya's `method`, `path`, `parameters`, and `parameterEncoding` into a single `route` and `params` property, significantly cutting down repetitive code as demonstrated in the GitHubAPI example.
Uses the custom `=>` operator to inline encoding and parameters, simplifying declarations like `JSONEncoding() => ["title": title]` in one line.
Allows setting headers via a `headers` property on the target type, avoiding the need for custom `endpointClosure` setups mentioned in the README.
Includes `RxMoyaSugarProvider` for reactive programming, seamlessly extending Moya's RxSwift support without extra configuration.
Explicitly stated in the README as unsupported, limiting dependency management options for teams using Carthage over CocoaPods.
Tightly coupled to Moya; any breaking changes or issues in Moya can propagate, and migrating away requires rewriting the network layer.
The non-standard `=>` operator, while concise, adds syntactic overhead that developers must learn and may conflict with other libraries.