RagnarNetworking

0.2.0

JamesRagnar/RagnarNetworking

What's New

0.2.0

2026-02-07T14:05:23Z
  • Flexible response mapping with ResponseMap (exact status codes + ranges)
  • New response outcomes including .noContent and decoded error-body handling
  • Typed request bodies via RequestBody with stricter Content-Type safety
  • Better debugging through richer response snapshots and decoding diagnostics
  • Custom request construction support with InterfaceConstructor
  • Updated documentation and examples to reflect the new API

This release includes API updates to Interface definitions (responseCases, body, and queryItems). Existing integrations may require small code changes.

Full Changelog: 0.1.0...0.2.0

RagnarNetworking

A modern, type-safe Swift networking library for building API interfaces with compile-time safety and minimal boilerplate.

Quick Example

Define a typed interface and call it with shorthand parameter initialization:

struct GetUserInterface: Interface {
    struct Parameters: RequestParameters {
        let method: RequestMethod = .get
        let path: String
        let queryItems: [String: String?]? = nil
        let headers: [String: String]? = nil
        let body: EmptyBody? = nil
        let authentication: AuthenticationType = .bearer

        init(userId: Int) {
            self.path = "/users/\(userId)"
        }
    }

    typealias Response = User

    static var responseCases: ResponseMap {
        [
            .code(200, .decode),
            .code(404, .error(APIError.userNotFound)),
            .code(401, .error(APIError.unauthorized))
        ]
    }
}

let config = ServerConfiguration(
    url: URL(string: "https://api.example.com")!,
    authToken: token
)

let user = try await URLSession.shared.dataTask(
    GetUserInterface.self,
    .init(userId: 123),
    config
)

Features

  • Type-safe endpoints with explicit status code handling (exact codes + ranges)
  • Automatic request construction from declarative parameters
  • Built-in auth strategies (.none, .bearer, .url)
  • Strict request bodies via RequestBody with intrinsic content types
  • Testable, protocol-based networking
  • Customizable request construction via InterfaceConstructor

Documentation

Requirements

  • Swift 6.2+
  • iOS 13.0+ / macOS 11.0+

License

RagnarNetworking is released under the Apache 2.0 License. See LICENSE for details.

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

Last updated: Wed Jun 24 2026 07:07:48 GMT-0900 (Hawaii-Aleutian Daylight Time)