documentation-zero 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.documentation_api/README.md +79 -0
- data/.documentation_api/sections/posts.md +77 -0
- data/Gemfile.lock +19 -0
- data/README.md +6 -2
- data/lib/documentation_zero/version.rb +1 -1
- data/lib/generators/documentation/scaffold/templates/resource.md.tt +13 -5
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2650852c4529a8d663213c01b7c0b492fd81c601247c817ce17cf204a5f44872
|
4
|
+
data.tar.gz: b2eee6d289c54bf1ef547b0e8cf4f52df36bfd6b164ca96523b095daa37e35c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8d1ef81d109b58cab60dd37b06eb9ba310a7fcfc8c59efcd7de8bc14fb907e90820dfeb6aefb62c4dea09326b367ec9f41d70dfab991b69e56608e2e3eb695d
|
7
|
+
data.tar.gz: a8de4dc6df6b59904c9b649fd27f9d443e98e6765234d1348fc55295718522ec638370f8f3b1dc34ffc41111747f99bb615a888d4031a43b6962ea74d013b356
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# The Rails tabler API
|
2
|
+
|
3
|
+
Welcome to the Rails tabler API! If you're looking to integrate your application with Rails tabler or create your own application in concert with data inside of Rails tabler, you're in the right place. We're happy to have you!
|
4
|
+
|
5
|
+
## Making a request
|
6
|
+
|
7
|
+
All URLs start with **`https://example.com/api/`**. URLs are HTTPS only. The path is prefixed with the `/api` prefix.
|
8
|
+
|
9
|
+
To make a request for all the resources on your account, append the `resources` index path to the base URL to form something like `https://example.com/api/resources.json`. In cURL, it looks like this:
|
10
|
+
|
11
|
+
``` shell
|
12
|
+
curl -H "Authorization: Bearer $ACCESS_TOKEN" -H 'User-Agent: MyApp (yourname@example.com)' https://example.com/api/resources.json
|
13
|
+
```
|
14
|
+
|
15
|
+
## Identifying your application
|
16
|
+
|
17
|
+
You must include a `User-Agent` header with **both**:
|
18
|
+
|
19
|
+
* The name of your application
|
20
|
+
* A link to your application or your email address
|
21
|
+
|
22
|
+
We use this information to get in touch if you're doing something wrong (so we can warn you before you're blacklisted) or something awesome (so we can congratulate you). Here are examples of acceptable `User-Agent` headers:
|
23
|
+
|
24
|
+
* `User-Agent: Freshbooks (http://freshbooks.com/contact.php)`
|
25
|
+
* `User-Agent: Fabian's Ingenious Integration (fabian@example.com)`
|
26
|
+
|
27
|
+
If you don't include a `User-Agent` header, you'll get a `400 Bad Request` response.
|
28
|
+
|
29
|
+
## JSON only
|
30
|
+
|
31
|
+
We use JSON for all API data. The style is no root element and snake\_case for object keys. This means that you have to send the `Content-Type` header `Content-Type: application/json; charset=utf-8` when you're POSTing or PUTing data into Rails tabler. All API URLs end in `.json` to indicate that they return JSON. Alternatively you can send `Accept: application/json`.
|
32
|
+
|
33
|
+
You'll receive a `415 Unsupported Media Type` response code if you don't include the `Content-Type` header.
|
34
|
+
|
35
|
+
## Pagination
|
36
|
+
|
37
|
+
Most collection APIs paginate their results. The number of requests that'll appear on each page is variable. In most cases, we use a [geared pagination ratio](https://github.com/basecamp/geared_pagination) with 15 results on page 1, 30 on page 2, 50 on 3, and then 100 on 4 and above. The Rails tabler API follows the [RFC5988 convention](https://tools.ietf.org/html/rfc5988) of using the `Link` header to provide URLs for the `next` page. Follow this convention to retrieve the next page of data—please don't build the pagination URLs yourself!
|
38
|
+
|
39
|
+
Here's an example response header from requesting the third page of some resource:
|
40
|
+
|
41
|
+
```
|
42
|
+
Link: <https://example.com/api/resources.json?page=4>; rel="next"
|
43
|
+
```
|
44
|
+
|
45
|
+
If the `Link` header is blank, that's the last page. The Rails tabler API also provides the `X-Total-Count` header, which displays the total number of resources in the collection you are fetching.
|
46
|
+
|
47
|
+
## Using HTTP caching
|
48
|
+
|
49
|
+
You must use HTTP freshness headers to speed up your application and lighten the load on our servers. Most API responses will include an `ETag` or `Last-Modified` header. When you first request a resource, store these values. On subsequent requests, submit them back to us as `If-None-Match` and `If-Modified-Since`, respectively. If the resource hasn't changed since your last request, you'll get a `304 Not Modified` response with no body, saving you the time and bandwidth of sending something you already have.
|
50
|
+
|
51
|
+
## Handling errors
|
52
|
+
|
53
|
+
API clients must expect and gracefully handle transient errors, such as rate limiting or server errors. We recommend baking 5xx and 429 response handling into your low-level HTTP client so your integration can handle most errors automatically.
|
54
|
+
|
55
|
+
### Rate limiting (429 Too Many Requests)
|
56
|
+
|
57
|
+
You can perform up to 50 requests per 10-second period from the same IP address. If you exceed this limit, you'll get a [429 Too Many Requests](http://tools.ietf.org/html/draft-nottingham-http-new-status-02#section-4) response for subsequent requests. Check the `Retry-After` header to see how many seconds to wait before retrying the request.
|
58
|
+
|
59
|
+
### [5xx server errors](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_errors)
|
60
|
+
|
61
|
+
If Rails tabler is having trouble, you will get a response with a 5xx status code indicating a server error. 500 (Internal Server Error), 502 (Bad Gateway), 503 (Service Unavailable), and 504 (Gateway Timeout) may be retried with [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff).
|
62
|
+
|
63
|
+
### 404 Not Found
|
64
|
+
|
65
|
+
API requests may 404 due to deleted content, an inactive account, missing user permissions, etc. Detect these conditions to give your users a clear explanation about why they can't connect to Rails tabler. Do not automatically retry these requests.
|
66
|
+
|
67
|
+
## API endpoints
|
68
|
+
|
69
|
+
<!-- START API ENDPOINTS -->
|
70
|
+
|
71
|
+
- [Posts](sections/posts.md)
|
72
|
+
|
73
|
+
<!-- END API ENDPOINTS -->
|
74
|
+
|
75
|
+
---
|
76
|
+
|
77
|
+
If you have a specific feature request or find a bug, please open a GitHub issue. We encourage you to fork these docs for local reference and happily accept pull requests with improvements.
|
78
|
+
|
79
|
+
To talk with us and other developers about the API, [post a question on StackOverflow](http://stackoverflow.com/questions/ask) tagged `rails-tabler`. If you need help from us directly, please open a support ticket.
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Posts
|
2
|
+
|
3
|
+
Endpoints:
|
4
|
+
|
5
|
+
- [Get posts](#get-posts)
|
6
|
+
- [Get post](#get-post)
|
7
|
+
- [Create post](#create-post)
|
8
|
+
- [Update post](#update-post)
|
9
|
+
- [Delete post](#delete-post)
|
10
|
+
|
11
|
+
## Get posts
|
12
|
+
|
13
|
+
- `GET /posts.json` will return a [paginated list](../README.md#pagination) of posts.
|
14
|
+
|
15
|
+
<!--
|
16
|
+
_Optional query parameters_:
|
17
|
+
|
18
|
+
* `attribute1` - when set to true, will only return resources that are completed.
|
19
|
+
* `attribute2` - when set to true, will only return resources that are completed.
|
20
|
+
-->
|
21
|
+
|
22
|
+
See the [post](#model) model for more info on the response payload.
|
23
|
+
|
24
|
+
## Get post
|
25
|
+
|
26
|
+
- `GET /posts/1.json` will return the post with an ID of `1`.
|
27
|
+
|
28
|
+
See the [post](#model) model for more info on the response payload.
|
29
|
+
|
30
|
+
## Create post
|
31
|
+
|
32
|
+
- `POST /posts.json` creates post.
|
33
|
+
|
34
|
+
<!--
|
35
|
+
**Required parameters**: `attribute1` and `attribute2`.
|
36
|
+
-->
|
37
|
+
|
38
|
+
_Optional parameters_:
|
39
|
+
|
40
|
+
* `title` - attribute from post.
|
41
|
+
* `content` - attribute from post.
|
42
|
+
* `published` - attribute from post.
|
43
|
+
|
44
|
+
This endpoint will return `201 Created` with the current JSON representation of the post if the creation was a success. See the [post](#model) model for more info on the payload.
|
45
|
+
|
46
|
+
## Update post
|
47
|
+
|
48
|
+
- `PUT /posts/1.json` allows changing the post with an ID of `1`.
|
49
|
+
|
50
|
+
This endpoint will return `200 OK` with the current JSON representation of the post if the update was a success. See the [post](#model) model for more info on the payload.
|
51
|
+
|
52
|
+
<!--
|
53
|
+
**Required parameters**: `attribute1` and `attribute2`.
|
54
|
+
-->
|
55
|
+
|
56
|
+
_Optional parameters_:
|
57
|
+
|
58
|
+
* `title` - attribute from post.
|
59
|
+
* `content` - attribute from post.
|
60
|
+
* `published` - attribute from post.
|
61
|
+
|
62
|
+
## Delete post
|
63
|
+
|
64
|
+
- `DELETE /posts/1.json` will delete the post with an ID of `1`.
|
65
|
+
|
66
|
+
This endpoint will return `204 No Content` if successful. No parameters are required.
|
67
|
+
|
68
|
+
---
|
69
|
+
|
70
|
+
## Model
|
71
|
+
```json
|
72
|
+
{
|
73
|
+
"title": "string",
|
74
|
+
"content": "string",
|
75
|
+
"published": "boolean",
|
76
|
+
}
|
77
|
+
```
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
documentation-zero (0.0.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
rake (13.0.6)
|
10
|
+
|
11
|
+
PLATFORMS
|
12
|
+
x86_64-darwin-21
|
13
|
+
|
14
|
+
DEPENDENCIES
|
15
|
+
documentation-zero!
|
16
|
+
rake (~> 13.0)
|
17
|
+
|
18
|
+
BUNDLED WITH
|
19
|
+
2.3.9
|
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
The purpose of documentation zero is to generate a scaffold for rails api documentations using markdown.
|
4
4
|
|
5
|
+
## Example
|
6
|
+
|
7
|
+
You can see an example of the generated documentation [here](.documentation_api/README.md)
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
@@ -20,11 +24,11 @@ rails generate documentation:readme
|
|
20
24
|
rails generate documentation:scaffold posts title:string body:text published:boolean
|
21
25
|
```
|
22
26
|
|
23
|
-
Add ```- [Posts](
|
27
|
+
Add ```- [Posts](sections/posts.md)``` to API endpoints section.
|
24
28
|
|
25
29
|
## Development
|
26
30
|
|
27
|
-
To
|
31
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
32
|
|
29
33
|
## Contributing
|
30
34
|
|
@@ -10,7 +10,7 @@ Endpoints:
|
|
10
10
|
|
11
11
|
## Get <%= human_name.pluralize.downcase %>
|
12
12
|
|
13
|
-
- `GET /<%= plural_name %>.json` will return a [paginated list](../
|
13
|
+
- `GET /<%= plural_name %>.json` will return a [paginated list](../README.md#pagination) of <%= human_name.pluralize.downcase %>.
|
14
14
|
|
15
15
|
<!--
|
16
16
|
_Optional query parameters_:
|
@@ -55,8 +55,8 @@ This endpoint will return `200 OK` with the current JSON representation of the <
|
|
55
55
|
|
56
56
|
_Optional parameters_:
|
57
57
|
|
58
|
-
<%
|
59
|
-
* `<%= attribute
|
58
|
+
<% attributes_names.each do |attribute| -%>
|
59
|
+
* `<%= attribute %>` - attribute from <%= human_name.downcase %>.
|
60
60
|
<% end -%>
|
61
61
|
|
62
62
|
## Delete <%= human_name.downcase %>
|
@@ -68,10 +68,18 @@ This endpoint will return `204 No Content` if successful. No parameters are requ
|
|
68
68
|
---
|
69
69
|
|
70
70
|
## Model
|
71
|
-
```
|
71
|
+
```json
|
72
72
|
{
|
73
73
|
<% attributes.each do |attribute| -%>
|
74
|
-
|
74
|
+
<% if attribute.password_digest? -%>
|
75
|
+
"password_digest": "string",
|
76
|
+
<% elsif attribute.token? -%>
|
77
|
+
"<%= attribute.column_name %>": "string",
|
78
|
+
<% elsif attribute.reference? -%>
|
79
|
+
"<%= attribute.column_name %>": "integer",
|
80
|
+
<% elsif !attribute.virtual? -%>
|
81
|
+
"<%= attribute.column_name %>": "<%= attribute.type %>",
|
82
|
+
<% end -%>
|
75
83
|
<% end -%>
|
76
84
|
}
|
77
85
|
```
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: documentation-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
@@ -17,9 +17,12 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".documentation_api/README.md"
|
21
|
+
- ".documentation_api/sections/posts.md"
|
20
22
|
- CHANGELOG.md
|
21
23
|
- CODE_OF_CONDUCT.md
|
22
24
|
- Gemfile
|
25
|
+
- Gemfile.lock
|
23
26
|
- LICENSE.txt
|
24
27
|
- README.md
|
25
28
|
- Rakefile
|