Skip to content

Commit 2b321ef

Browse files
committed
Re-add Readme-file
1 parent 44eb09e commit 2b321ef

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Honkit API Documentation Plugin
2+
3+
The *Honkit API Documentation Plugin* enables the automatic creation of beautifully designed API documentation. Its design was heavily inspired by [GitBook's old OpenAPI-block](https://web.archive.org/web/20230923080123/https://docs.gitbook.com/content-creation/blocks/api-method).
4+
5+
This plugin is still in its infancy, so expect lots of bugs. However, the basics are covered, and more is to come.
6+
7+
## Installation
8+
9+
```
10+
npm i --save honkit-plugin-api-documentation
11+
```
12+
13+
### Configuration
14+
In your `book.json` or other whatever you have called your configuration-file:
15+
16+
```json
17+
{
18+
"root": ".",
19+
"plugins": ["honkit-plugin-api-documentation"]
20+
}
21+
```
22+
23+
## Getting Started
24+
25+
### Dereferencing Swagger-File
26+
In the first step, we need to dereference our `Swagger` file as we want to work with "Vanilla" JSON. You can achieve this using any of the freely available tools, such as the [Swagger & OpenAPI Online Validator](https://apitools.dev/swagger-parser/online).
27+
28+
Dereferencing basically means that we want to remove the `$ref` from this shape.
29+
30+
```json
31+
"responses": {
32+
"200": {
33+
"description": "pet response",
34+
"schema": {
35+
"type": "array",
36+
"items": {
37+
"$ref": "#/definitions/Pet"
38+
}
39+
}
40+
}
41+
```
42+
43+
Dereferenced:
44+
```json
45+
"responses": {
46+
"200": {
47+
"description": "pet response",
48+
"schema": {
49+
"type": "array",
50+
"items": {
51+
"type": "object",
52+
"allOf": [
53+
{
54+
"type": "object",
55+
"required": [
56+
"name"
57+
],
58+
"properties": {
59+
"name": {
60+
"type": "string"
61+
},
62+
"tag": {
63+
"type": "string"
64+
}
65+
}
66+
},
67+
{
68+
"required": [
69+
"id"
70+
],
71+
"properties": {
72+
"id": {
73+
"type": "integer",
74+
"format": "int64"
75+
}
76+
}
77+
}
78+
]
79+
}
80+
}
81+
},
82+
```
83+
84+
### Creating your .md File
85+
The next step is simple. Just create a new `.md` file and add the dereferenced JSON between two tags:
86+
87+
```
88+
<!-- API_START -->
89+
{...JSON...}
90+
<!-- API_END -->
91+
```
92+
93+
Now `build` and `serve` it!
94+
95+
## Limitations
96+
- The plugin currently only supports the `OpenAPI 2.0` (or `Swagger 2.0`) [Specification](https://swagger.io/specification/v2/)
97+
- Not all Swagger objects are supported or can be displayed.
98+
- *Dereferencing* has to be done manually.

0 commit comments

Comments
 (0)