Skip to content

Commit 7faa217

Browse files
Update README.md
1 parent 2cc00d8 commit 7faa217

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

README.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
![swift workflow](https://github.com/artemkalinovsky/Kite/actions/workflows/swift.yml/badge.svg)
2-
[![Swift 6](https://img.shields.io/badge/Swift-6.0-orange.svg)](https://swift.org)
2+
[![Swift 6](https://img.shields.io/badge/Swift-6-orange.svg)](https://swift.org)
33
[![macOS](https://img.shields.io/badge/macOS-12%2B-blue.svg)](https://developer.apple.com/macos/)
44
[![iOS](https://img.shields.io/badge/iOS-15%2B-blue.svg)](https://developer.apple.com/ios/)
55
[![tvOS](https://img.shields.io/badge/tvOS-15%2B-blue.svg)](https://developer.apple.com/tvos/)
@@ -12,17 +12,19 @@
1212
<img src="https://github.com/user-attachments/assets/67d7a28c-e45b-4abd-bdf4-86b329c439b5" width="20%" />
1313

1414

15-
# Kite
15+
# Kite
1616

1717
Kite is named after the kite bird, known for its lightness, speed, and agile flight. This Swift Package aims to embody those qualities—offering a lightweight, fast, and flexible networking layer that runs on Apple platforms, Linux, Windows, and Android.
18+
1819
## Features
1920

2021
- `async`/`await`-first request execution
2122
- Small protocol-based request model
2223
- Built-in JSON and XML response deserializers
2324
- Raw-data and no-op deserializers for simple endpoints
2425
- Query-string, JSON body, auth-header, and multipart upload support
25-
- Explicit error behavior for invalid URLs, auth failures, decode failures, and non-2xx responses
26+
- Zero external dependencies
27+
- Explicit error behavior for auth failures, decode failures, and non-2xx responses
2628

2729
## Requirements
2830

@@ -38,12 +40,12 @@ Kite is named after the kite bird, known for its lightness, speed, and agile fli
3840

3941
In Xcode, choose:
4042

41-
`File` -> `Add Package Dependencies...` -> `Up to Next Major Version` starting at `4.0.0`
43+
`File` -> `Add Package Dependencies...` -> `Up to Next Major Version` starting at `5.0.0`
4244

4345
Or add Kite to `Package.swift`:
4446

4547
```swift
46-
.package(url: "https://github.com/artemkalinovsky/Kite.git", from: "4.0.0")
48+
.package(url: "https://github.com/artemkalinovsky/Kite.git", from: "5.0.0")
4749
```
4850

4951
Example:
@@ -61,7 +63,7 @@ let package = Package(
6163
)
6264
],
6365
dependencies: [
64-
.package(url: "https://github.com/artemkalinovsky/Kite.git", from: "4.0.0")
66+
.package(url: "https://github.com/artemkalinovsky/Kite.git", from: "5.0.0")
6567
],
6668
targets: [
6769
.target(
@@ -145,25 +147,41 @@ let (users, _) = try await apiClient.execute(request: FetchRandomUsersRequest())
145147
- `headers` defaults to `[:]`.
146148
- `multipartFormData` defaults to `nil`.
147149

148-
Parameter behavior is built in:
150+
Parameter encoding is determined by the request shape:
149151

150-
- For `.get` requests, `parameters` are encoded as query items.
151-
- For non-GET requests, `parameters` are encoded as a JSON body and `Content-Type` is set to `application/json`.
152+
- For `.get` requests, `parameters` are encoded as URL query items.
153+
- For non-GET requests without `multipartFormData`, `parameters` are encoded as a JSON body and `Content-Type` is set to `application/json`.
154+
- When `multipartFormData` is present, `parameters` are included as text form fields alongside the files in the same multipart body.
152155

153156
## Deserializers
154157

155158
Kite ships with three built-in deserializer styles:
156159

157160
- `VoidDeserializer()` for endpoints where you only care whether the request succeeded
158161
- `RawDataDeserializer()` when you want the raw response bytes
159-
- `JSONDeserializer` for `Decodable` models and `XMLDeserializer` for types that conform to `XMLObjectDeserialization`
162+
- `JSONDeserializer` for `Decodable` models
163+
- `XMLDeserializer` for types that conform to `XMLObjectDeserialization` — built into Kite, no extra import needed
160164

161165
Examples:
162166

163167
```swift
164168
let users = JSONDeserializer<User>.collectionDeserializer(keyPath: "results")
165169
let profile = JSONDeserializer<User>.singleObjectDeserializer()
166-
let feed = XMLDeserializer<FeedUser>.collectionDeserializer(keyPath: "response", "users", "user")
170+
let feed = XMLDeserializer<FeedItem>.collectionDeserializer(keyPath: "response", "items", "item")
171+
```
172+
173+
To use `XMLDeserializer`, conform your model to `XMLObjectDeserialization`:
174+
175+
```swift
176+
import Kite
177+
178+
struct FeedItem: XMLObjectDeserialization {
179+
let title: String
180+
181+
static func deserialize(_ node: XMLIndexer) throws -> Self {
182+
FeedItem(title: try node["title"].value())
183+
}
184+
}
167185
```
168186

169187
## Authenticated Requests
@@ -267,11 +285,6 @@ Kite is production-ready. Pull requests, questions, and suggestions are welcome.
267285

268286
- [PinPlace](https://apps.apple.com/ua/app/pinplace/id1571349149)
269287

270-
## Credits 👏
271-
272-
- @0111b for [JSONDecoder-Keypath](https://github.com/0111b/JSONDecoder-Keypath)
273-
- @drmohundro for [SWXMLHash](https://github.com/drmohundro/SWXMLHash)
274-
275288
## License 📄
276289

277290
Kite is released under the MIT license. See [LICENSE](https://github.com/artemkalinovsky/Kite/blob/master/LICENSE) for details.

0 commit comments

Comments
 (0)