jekyll-hk-api-doc 0.2.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +67 -110
- data/_includes/api_main_content.html +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 806d12a4a70e3962c2f4ea25d33a7c2c053b2a47f95771a54bdf2f95b4cdfe78
|
4
|
+
data.tar.gz: 6a2c924a09210dffd947d214b92816e26f20706c8a259d2b92d246026e843714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb517671a86061da99e180741836f5be7c9d75604c2d800ac96fcd70ce8eb707ec3cb7145011c611c8c6c833e68d90a155eecac4e0ee260a55d92ea6a97c412
|
7
|
+
data.tar.gz: 2625b14c3d809566dc285ea1e562f451335792f302c4a49f7cf05dcde61dba21414a442ace86525ed68037b4075c856f069cdf08e99642aa35f93d0d330425ba
|
data/README.md
CHANGED
@@ -1,30 +1,83 @@
|
|
1
|
-
# jekyll-hk-api-doc
|
1
|
+
# jekyll-hk-api-doc [v1.0.1]
|
2
2
|
|
3
3
|
A Simple API Doc with YAML powered by Jekyll
|
4
|
-
|
5
4
|
## Installation
|
6
5
|
|
7
|
-
1. Add the line below to your Jekyll site's `Gemfile
|
6
|
+
1. Add the line below to your Jekyll site's `Gemfile`.
|
8
7
|
|
9
8
|
```ruby
|
10
9
|
gem "jekyll-hk-api-doc"
|
11
10
|
```
|
12
11
|
|
13
|
-
2.
|
12
|
+
2. Install the gem with either one of commands below.
|
14
13
|
|
15
|
-
```
|
16
|
-
|
14
|
+
```bash
|
15
|
+
$ bundle install
|
16
|
+
$ gem install jekyll-hk-api-doc
|
17
17
|
```
|
18
18
|
|
19
|
-
3.
|
19
|
+
3. Update your Jekyll site's `_config.yml`. Keys listed below are used by `jekyll-hk-api-doc` theme.
|
20
20
|
|
21
21
|
```yaml
|
22
|
+
theme: jekyll-hk-api-doc
|
23
|
+
assets: /assets
|
22
24
|
data_dir: _api
|
25
|
+
collections_dir: documents
|
26
|
+
collections:
|
27
|
+
api_book_pages:
|
28
|
+
output: true
|
29
|
+
permalink: /:name
|
30
|
+
defaults:
|
31
|
+
- scope:
|
32
|
+
path: ""
|
33
|
+
type: "api_book_page"
|
34
|
+
values:
|
35
|
+
layout: "api"
|
36
|
+
|
37
|
+
title: [Your Jekyll site's title]
|
38
|
+
description: [Your Jekyll site's description]
|
39
|
+
baseurl: [Your Jekyll site's base url. If base url not exists, it should be ""(empty string)]
|
40
|
+
author: [Author's name]
|
41
|
+
email: [Author's email]
|
42
|
+
|
43
|
+
api_baseurl: [API baseurl. This will be prepended on every API's url.]
|
44
|
+
version: [API version]
|
23
45
|
```
|
24
46
|
|
25
|
-
4.
|
47
|
+
4. Create directories: `_api/`, `assets/api/examples/`
|
48
|
+
- `_api/` : Directory where yaml files will be stored
|
49
|
+
- `assets/api/examples/` : Directory where the response examples(in json) of apis's will be stored
|
50
|
+
|
51
|
+
5. Write yaml in `_api/`. Available keys for yaml is listed below:
|
52
|
+
|
53
|
+
```yaml
|
54
|
+
name: [Name of the API sets]
|
55
|
+
description: [Description of the API sets]
|
56
|
+
baseurl: [base_url will be prepended to all APIs in the set.]
|
57
|
+
apis:
|
58
|
+
- name: [Name of the API]
|
59
|
+
url: [URL of the API. The full URL will be (api_baseurl at _config.yml) + (baseurl at yaml) + (url).]
|
60
|
+
method: [Request method. Available values are "get", "post", "put", "delete", "patch", "head", "options".]
|
61
|
+
description: [Description of the API]
|
62
|
+
params:
|
63
|
+
body: [Type of parameters. Available values are "header", "path", "query", "body".]
|
64
|
+
- name: [Name of the parameter]
|
65
|
+
is_required: [Available values are "true", "false". If "true", "required" tag will be displayed for the parameter. If "false", "optional" will be displayed for the parameter.]
|
66
|
+
type: [Type of the parameter]
|
67
|
+
description: [Description of the parameter]
|
68
|
+
response:
|
69
|
+
success:
|
70
|
+
- status_code: [Http response code. If "200", "Success" will be displayed.]
|
71
|
+
description: [Description of the response]
|
72
|
+
example: [Response example. For design purpose, I seperate yaml and example(examples are loaded via ajax, and highlight.js is applied to them). You only have to write the name of the json file in assets/api/examples/ directory(without the extension .json)]
|
73
|
+
fail:
|
74
|
+
- status_code: [Http response code. If "400", "Bad Request" will be displayed. If "401", "Unauthorized" will be displayed. If "403", "Forbidden" will be displayed. If "404", "Not Found" will be displayed.]
|
75
|
+
description: [Description of the response]
|
76
|
+
example: [Response example. For design purpose, I seperate yaml and example(examples are loaded via ajax, and highlight.js is applied to them). You only have to write the name of the json file in assets/api/examples/ directory(without the extension .json)]
|
77
|
+
```
|
26
78
|
|
27
79
|
```yaml
|
80
|
+
# Example
|
28
81
|
name: Auth
|
29
82
|
description: APIs for authentication
|
30
83
|
base_url: /api/auth
|
@@ -34,7 +87,6 @@ apis:
|
|
34
87
|
method: post
|
35
88
|
description: |
|
36
89
|
Issue <code>access token</code> and <code>refresh token</code>
|
37
|
-
* Currently, the api is using <code>http</code> and it does have vulnerability of sending plain password, but it will soon be updated to <code>https</code>.
|
38
90
|
* <code>access token</code>s will be expired 10 minutes after they are issued.
|
39
91
|
* <code>refresh token</code>s will be expired 2 weeks after they are issued.
|
40
92
|
params:
|
@@ -57,87 +109,9 @@ apis:
|
|
57
109
|
- Either one of <code>id</code> or <code>pw</code> is not included in the request.
|
58
110
|
- <code>id</code> is not registered.
|
59
111
|
- <code>id</code> and <code>pw</code> are not matching.
|
60
|
-
- name: ID Duplication Check
|
61
|
-
url: /id-duplicate-check
|
62
|
-
method: get
|
63
|
-
description: Checks if new <code>id</code> is duplicated or not
|
64
|
-
params:
|
65
|
-
query:
|
66
|
-
- name: id
|
67
|
-
is_required: true,
|
68
|
-
type: string
|
69
|
-
description: ID
|
70
|
-
response:
|
71
|
-
success:
|
72
|
-
- status_code: 200
|
73
|
-
description: <code>id</code> is not duplicated(good to use)
|
74
|
-
fail:
|
75
|
-
- status_code: 400
|
76
|
-
description: <code>id</code> is duplicated(not good to use)
|
77
|
-
- name: Sign Up
|
78
|
-
url: /signup
|
79
|
-
method: post
|
80
|
-
description: Create a new account.
|
81
|
-
params:
|
82
|
-
body:
|
83
|
-
- name: id
|
84
|
-
is_required: true
|
85
|
-
type: string
|
86
|
-
description: ID
|
87
|
-
- name: pw
|
88
|
-
is_required: true
|
89
|
-
type: string
|
90
|
-
description: (plain) Password
|
91
|
-
- name: nickname
|
92
|
-
is_required: true
|
93
|
-
type: string
|
94
|
-
description: Nickname
|
95
|
-
- name: email
|
96
|
-
is_required: true
|
97
|
-
type: string
|
98
|
-
description: Email
|
99
|
-
- name: age
|
100
|
-
is_required: true
|
101
|
-
type: int
|
102
|
-
description: Age
|
103
|
-
response:
|
104
|
-
success:
|
105
|
-
- status_code: 200
|
106
|
-
description: New account has been successfully created.
|
107
|
-
fail:
|
108
|
-
- status_code: 400
|
109
|
-
description: |
|
110
|
-
- Either one of <code>id</code>, <code>pw</code>, <code>nickname</code>, <code>email</code> or <code>age</code> is not included in the request or not a proper type.
|
111
|
-
- <code>id</code> already registered(duplicated id)
|
112
|
-
- name: Refresh Token
|
113
|
-
url: /refresh
|
114
|
-
method: get
|
115
|
-
description: |
|
116
|
-
Re-issue an access token with <code>refresh token</code>
|
117
|
-
params:
|
118
|
-
header:
|
119
|
-
- name: x-access-token
|
120
|
-
is_required: true
|
121
|
-
type: string
|
122
|
-
description: (expired) access token
|
123
|
-
- name: x-refresh-token
|
124
|
-
is_required: true
|
125
|
-
type: string
|
126
|
-
description: refresh token
|
127
|
-
response:
|
128
|
-
success:
|
129
|
-
- status_code: 200
|
130
|
-
example: auth-refreshtoken-200
|
131
|
-
fail:
|
132
|
-
- status_code: 401
|
133
|
-
description: |
|
134
|
-
- <code>x-access-token</code> or <code>x-refresh-token</code> is not provided.
|
135
|
-
- <code>x-access-token</code> or <code>x-refresh-token</code> is not valid(not issued by the server, or modified).
|
136
|
-
- <code>x-refresh-token</code> is banned.
|
137
|
-
- <code>x-access-token</code> and <code>x-refresh-token</code> are not matching.
|
138
112
|
```
|
139
113
|
|
140
|
-
|
114
|
+
6. Execute the python code below with Python 3, which creates html files in `documents/_api_book_page` corresponding to yaml files in `_api`.
|
141
115
|
|
142
116
|
```python
|
143
117
|
import os
|
@@ -158,35 +132,18 @@ yamls = sorted([os.path.splitext(x)[0] for x in os.listdir(yaml_path) if x.endsw
|
|
158
132
|
for i, yaml in enumerate(yamls):
|
159
133
|
with open(os.path.join(html_path, f"{yaml}.html"), "w") as html:
|
160
134
|
html.write("---\n")
|
161
|
-
|
162
|
-
if i == 0:
|
163
|
-
redirect_from = "redirect_from:\n - /\n - docs/\n"
|
164
|
-
html.write(redirect_from)
|
165
|
-
|
166
135
|
html.write("---\n")
|
167
136
|
```
|
168
137
|
|
169
|
-
|
170
|
-
|
171
|
-
$ bundle
|
138
|
+
7. Test:
|
172
139
|
|
173
|
-
|
174
|
-
|
175
|
-
|
140
|
+
```bash
|
141
|
+
$ bundle exec jekyll serve
|
142
|
+
```
|
176
143
|
|
177
144
|
## Contributing
|
178
145
|
|
179
146
|
Bug reports and pull requests are welcome on GitHub at https://github.com/HeekangPark/jekyll-hk-api-doc.
|
180
|
-
|
181
|
-
## Development
|
182
|
-
|
183
|
-
To set up your environment to develop this theme, run `bundle install`.
|
184
|
-
|
185
|
-
Your theme is setup just like a normal Jekyll site! To test your theme, run `bundle exec jekyll serve` and open your browser at `http://localhost:4000`. This starts a Jekyll server using your theme. Add pages, documents, data, etc. like normal to test your theme's contents. As you make modifications to your theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.
|
186
|
-
|
187
|
-
When your theme is released, only the files in `_layouts`, `_includes`, `_sass` and `assets` tracked with Git will be bundled.
|
188
|
-
To add a custom directory to your theme-gem, please edit the regexp in `jekyll-hk-api-doc.gemspec` accordingly.
|
189
|
-
|
190
147
|
## License
|
191
148
|
|
192
|
-
The theme is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
149
|
+
The theme is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<div class="api-name-area" id="api-{{ forloop.index }}">
|
11
11
|
<h2 class="api-name">{{ api.name }}</h2>
|
12
12
|
<p class="api-method api-method-{{ api.method | downcase }}">{{ api.method | upcase }}</p>
|
13
|
-
<p class="api-url-area"><span class="api-baseurl">{{ site.api_baseurl | escape }}</span><span class="api-url">{{ yaml.
|
13
|
+
<p class="api-url-area"><span class="api-baseurl">{{ site.api_baseurl | escape }}</span><span class="api-url">{{ yaml.baseurl | escape }}{{ api.url | escape }}</span></p>
|
14
14
|
</div>
|
15
15
|
|
16
16
|
<div class="api-description">{{ api.description | newline_to_br }}</div>
|
@@ -172,8 +172,6 @@
|
|
172
172
|
: Bad Request
|
173
173
|
{% elsif item.status_code == 401 %}
|
174
174
|
: Unauthorized
|
175
|
-
{% elsif item.status_code == 401 %}
|
176
|
-
: Unauthorized
|
177
175
|
{% elsif item.status_code == 403 %}
|
178
176
|
: Forbidden
|
179
177
|
{% elsif item.status_code == 404 %}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-hk-api-doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heekang Park
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|