Skip to content

Commit

Permalink
Update docs and fix a build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuawright11 committed Nov 6, 2023
1 parent 3e2baf0 commit c18f57b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Example/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct Todo: Codable {

// MARK: 1. Create a Provider with any custom configuration.

let provider = Provider(baseURL: "http://127.0.0.1:3000", urlSession: .shared)
let provider = Provider(baseURL: "http://127.0.0.1:3000")
.intercept { req, next in
let start = Date()
let res = try await next(req)
Expand Down
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ protocol Users {
## Features

- [x] Turn REST APIs into Swift protocols
- [x] Generate Swift Concurrency _or_ completion handler based APIs
- [x] Swift Concurrency _or_ completion handler based APIs
- [x] JSON, URLForm and Multipart encoding
- [x] Easy to configure key mapping
- [x] Sensible parameter defaults so you can write less code
- [x] Automatically decode responses with `Codable`
- [x] Custom Interceptors & Builders
- [x] Generate mock APIs for testing
- [x] iOS / macOS support powered by [Alamofire](https://github.com/Alamofire/Alamofire)
- [x] Optional, automatic API mocks for testing
- [x] Out of the box powered by `URLSession` or [Alamofire](https://github.com/Alamofire/Alamofire)
- [x] Swift on Server support powered by [async-http-client](https://github.com/swift-server/async-http-client)

## Table of Contents

1. [Getting Started](#getting-started)
2. [Defining APIs](#defining-apis)
3. [Handling the Response](#handling-the-response)
2. [Requests](#requests)
3. [Responses](#responses)
4. [Configuration](#configuration)
5. [Testing](#testing)
6. [Acknowledgements](#acknowledgements)
Expand All @@ -76,11 +76,11 @@ Documentation examples use [Swift concurrency](https://docs.swift.org/swift-book

While using concurrency is recommended, if you haven't yet migrated and need a closure based API, see the section on [closure based APIs](#closure-based-apis).

### Swift on the Server
### Alamofire & Linux drivers

Out of the box, Papyrus is powered by [Alamofire](https://github.com/Alamofire/Alamofire).
Out of the box, Papyrus is powered by `URLSession`.

If you're using Linux / Swift on Server, use [PapyrusAsyncHTTPClient](https://github.com/joshuawright11/papyrus-async-http-client) which is driven by the [swift-nio](https://github.com/apple/swift-nio) backed [async-http-client](https://github.com/swift-server/async-http-client).
If you're using Linux / Swift on Server, use the separate package [PapyrusAsyncHTTPClient](https://github.com/joshuawright11/papyrus-async-http-client). It's driven by the [swift-nio](https://github.com/apple/swift-nio) backed [async-http-client](https://github.com/swift-server/async-http-client).

### Installation

Expand All @@ -92,7 +92,35 @@ dependencies: [
]
```

## Defining APIs
#### URLSession driver

Out of the box, Papyrus is powered by `URLSession`.

```swift
.product(name: "Papyrus", package: "papyrus")
```

```swift
import Papyrus
```

#### Alamofire driver

If you'd prefer to use [Alamofire](https://github.com/Alamofire/Alamofire), use the `PapyrusAlamofire` library in this package.

```swift
.product(name: "PapyrusAlamofire", package: "papyrus")
```

```swift
import PapyrusAlamofire
```

#### Linux driver

If you're using Linux / Swift on Server, use the separate package [PapyrusAsyncHTTPClient](https://github.com/joshuawright11/papyrus-async-http-client). It's driven by the [swift-nio](https://github.com/apple/swift-nio) backed [async-http-client](https://github.com/swift-server/async-http-client).

## Requests

Each API you need to consume is represented by a _protocol_.

Expand Down Expand Up @@ -268,7 +296,7 @@ protocol Todos {
}
```

## Handling the Response
## Responses

The return type of your function represents the response of your endpoint.

Expand Down

0 comments on commit c18f57b

Please sign in to comment.