Skip to content

Commit 7911a25

Browse files
committed
Add changelog
1 parent a69397f commit 7911a25

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## URLQueryEncoder 0.x
2+
3+
*Dec 28, 2021*
4+
5+
- Initial version

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# URLQueryEncoder
22

3-
A customizable Swift `Encoder` that encodes instances of data types as URL query items. Supports all [OpenAPI] query parameter [serialization options](https://swagger.io/docs/specification/serialization/).
3+
A customizable Swift `Encoder` that encodes instances of data types as URL query items. Supports all OpenAPI [serialization options](https://swagger.io/docs/specification/serialization/).
44

55
## Examples
66

@@ -77,11 +77,11 @@ encoder.encode(user, forKey: "id", isDeepObject: true)
7777
// Query: "id[role]=admin&id[name]=kean")"
7878
```
7979

80-
> If you are encoding a request body using URL-form encoding, you can use a convenience `URLQueryEncoder.encode(body)` method.
80+
> If you are encoding a request body using URL-form encoding, you can use a convenience `URLQueryEncoder.encode(_:)` method.
8181
8282
## Encoding Options
8383

84-
There are two ways to change the encoding options: settings them directly on `URLQueryEncoder` instance, or passing options in each individual `encode` call. The reason it's designed this way is that in OpenAPI, each parameter can have different serialization options.
84+
There are two ways to change the encoding options. You can set them directly on `URLQueryEncoder` instance.
8585

8686
```swift
8787
let encoder = URLQueryEncoder()
@@ -91,22 +91,23 @@ encoder.delimiter = "|"
9191
encoder.dateEncodingStrategy = .millisecondsSince1970
9292
```
9393

94-
You can use `URLQueryEncoder` to encode more that one parameter are a time:
94+
Or pass options in each individual `encode` call.
9595

9696
```swift
9797
let user = User(role: "admin", name: "kean")
9898
let ids = [3, 4, 5]
9999

100-
let query = URLQueryEncoder()
101-
.encode(ids, forKey: "ids", explode: false)
102-
.encode(ids, forKey: "ids2", explode: true)
103-
.encode(user, forKey: "user", isDeepObject: true)
104-
.encode(2, forKey: "id")
105-
.query
100+
let encoder = URLQueryEncoder()
101+
encoder.encode(ids, forKey: "ids", explode: false)
102+
encoder.encode(ids, forKey: "ids2", explode: true)
103+
encoder.encode(user, forKey: "user", isDeepObject: true)
104+
encoder.encode(2, forKey: "id")
106105

107106
// Query: "ids=3,4,5&ids2=3&ids2=4&ids2=5&user[role]=admin&user[name]=kean&id=2"
108107
```
109108

109+
The reason it's designed this way is that in OpenAPI each parameter can come with different serialization options.
110+
110111
## Accessing Results
111112

112113
You can access the encoding results at any time, and they come in different forms:

0 commit comments

Comments
 (0)