Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation. #113

Merged
merged 1 commit into from
Mar 9, 2018
Merged

Update documentation. #113

merged 1 commit into from
Mar 9, 2018

Conversation

sidraval
Copy link
Contributor

@sidraval sidraval commented Mar 2, 2018

  • Updates Documentation/Basics.md to include the removal of Argo, and working examples via Codable.
  • Adds SwishExamples.playground that contains the code in Documentation/Basics.md.
  • Documents the playground in README.md with instructions on how to use it.

If you checkout this branch, the URL in SwishExamples.playground needs to be set to https://raw.githubusercontent.com/thoughtbot/Swish/sr-update-documentation/Documentation/example.json for the example to work; the URL that is in there now will work once this branch is merged to master.

Copy link
Contributor

@sharplet sharplet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 👍 just a few thoughts

# Basic Usage #

Let's say you have an endpoint, `GET https://www.example.com/comments/1`, that returns the following JSON:
Let's say we have an endpoint, `https://raw.githubusercontent.com/thoughtbot/Swish/master/Documentation/example.json`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave GET in here?

"commentText": "Pretty good. Pret-ty pre-ty pre-ty good.",
"username": "LarryDavid"
}
```

We'll model this with the following struct, and implement Argo's `Decodable` protocol to tell it how to deal with JSON:
We will model the data with the following struct,
and implement the `Codable` protocol so we can
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implement -> conform to

}
```

We can then use the Swish's default `APIClient` to make the request:
We can then use the Swish's default APIClient to make the request:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to leave the backticks in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

func build() -> URLRequest {
let url = URL(string: "https://raw.githubusercontent.com/thoughtbot/Swish/master/Documentation/example.json")!
return URLRequest(url: url)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's necessary to reindent these examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope!

README.md Outdated
| 2.X | 1.X |
| Swift Version | Swish Version |
| ------------- | ------------ |
| 4.X | >= 2.0.3 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we bump the major version for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely!


PlaygroundPage.current.needsIndefiniteExecution = true

// Let's say we have an endpoint, https://raw.githubusercontent.com/thoughtbot/Swish/master/Documentation/example.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to use playground markup instead of regular comments? Or does it automatically render these as Markdown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 👍

Copy link
Contributor

@sharplet sharplet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple more comments, but :shipit:

<*> j <| "commentText"
<*> j <| "username"
enum CodingKeys: String, CodingKey {
case id = "id"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, you can leave off the explicit = "id" if the string value is the same as the case name. (Same goes for username below.)

README.md Outdated

You can see an example of Swish in action via the included `SwishExamples.playground`.

To use that, clone this repository and run `carthage bootstrap`. When that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carthage used to build for all platforms by default — if this is still the case, could we add --platform iOS to match the platform the playground targets?

struct CommentRequest: Request {
typealias ResponseObject = Comment


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra newline

- Documentation/Basics.md
- Added SwishExamples.playground playground file,
  with the contents of Basics.md
@sidraval sidraval merged commit 87ea748 into master Mar 9, 2018
@sidraval sidraval deleted the sr-update-documentation branch March 9, 2018 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants