You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This preprocessor generates Markdown documentation from [Swagger](https://swagger.io/) spec files . It uses [Jinja2](http://jinja.pocoo.org/) templating engine or [widdershins](https://github.com/mermade/widdershins) for generating Markdown from swagger spec files.
6
+

7
+
8
+
*The static site on the picture was built with [Slate](https://foliant-docs.github.io/docs/backends/slate/) backend together with SwaggerDoc preprocessor*
9
+
10
+
This preprocessor generates Markdown documentation from [Swagger](https://swagger.io/) spec files. It uses [Jinja2](http://jinja.pocoo.org/) templating engine or [Widdershins](https://github.com/mermade/widdershins) for generating Markdown from swagger spec files.
6
11
7
12
## Installation
8
13
9
14
```bash
10
15
$ pip install foliantcontrib.swaggerdoc
11
16
```
12
17
18
+
This preprocessor requires [Widdershins](https://github.com/Mermade/widdershins) to be installed on your system (unless you are using [Foliant with Full Docker Image](https://foliant-docs.github.io/docs/tutorials/full_docker/)):
19
+
20
+
```
21
+
npm install -g widdershins
22
+
```
23
+
13
24
## Config
14
25
15
-
To enable the preprocessor, add `pgsqldoc` to `preprocessors` section in the project config:
26
+
To enable the preprocessor, add `swaggerdoc` to `preprocessors` section in the project config:
16
27
17
28
```yaml
18
29
preprocessors:
@@ -24,24 +35,22 @@ The preprocessor has a number of options:
24
35
```yaml
25
36
preprocessors:
26
37
- swaggerdoc:
27
-
json_url: http://localhost/swagger.json
28
-
json_path: swagger.json
38
+
spec_url: http://localhost/swagger.json
39
+
spec_path: swagger.json
29
40
additional_json_path: tags.json
30
-
mode: 'jinja'
41
+
mode: widdershins
31
42
template: swagger.j2
32
43
environment: env.yaml
33
44
34
45
```
35
46
36
-
`json_url`
47
+
`spec_url`
37
48
: URL to Swagger spec file. If it is a list — preprocessor takes the first url which works.
38
49
39
-
> even though the parameters are called *json*\_url and *json*\_path, yaml format is supported too. Parameters may be softly renamed in future.
40
-
41
-
`json_path`
50
+
`spec_path`
42
51
: Local path to Swagger spec file (relative to project dir).
43
52
44
-
> If both url and path are specified — preprocessor first tries to fetch JSON from url, and then (if that fails) looks for the file on local path.
53
+
> If both url and path are specified — preprocessor first tries to fetch spec from url, and then (if that fails) looks for the file on local path.
45
54
46
55
`additional_json_path`
47
56
: Only for `jinja` mode. Local path to swagger spec file with additional info (relative to project dir). It will be merged into original spec file, *not overriding existing fields*.
@@ -78,12 +87,12 @@ You can also specify some parameters (or all of them) in the tag options:
@@ -95,16 +104,6 @@ This way you can have documentation from several different Swagger spec files in
95
104
96
105
## Customizing output
97
106
98
-
### Jinja
99
-
100
-
> `jinja` mode is deprecated. It may be removed in future
101
-
102
-
In `jinja` mode the output markdown is generated by the [Jinja2](http://jinja.pocoo.org/) template. In this template all fields from Swagger spec file are available under the dictionary named `swagger_data`.
103
-
104
-
To customize the output create a template which suits your needs. Then supply the path to it in the `template` parameter.
105
-
106
-
If you wish to use the default template as a starting point, build the foliant project with `swaggerdoc` preprocessor turned on. After the first build the default template will appear in your foliant project dir under name `swagger.j2`.
107
-
108
107
### Widdershins
109
108
110
109
In `widdershins` mode the output markdown is generated by [widdershins](https://github.com/mermade/widdershins) Node.js application. It supports customizing the output with [doT.js](https://github.com/olado/doT) templates.
@@ -116,7 +115,17 @@ In `widdershins` mode the output markdown is generated by [widdershins](https://
116
115
```yaml
117
116
preprocessors:
118
117
- swaggerdoc:
119
-
json_path: swagger.yml
118
+
spec_path: swagger.yml
120
119
environment:
121
120
user_templates: !path ./widdershins_templates/
122
121
```
122
+
123
+
### Jinja
124
+
125
+
> `jinja` mode is deprecated. It may be removed in future
126
+
127
+
In `jinja` mode the output markdown is generated by the [Jinja2](http://jinja.pocoo.org/) template. In this template all fields from Swagger spec file are available under the dictionary named `swagger_data`.
128
+
129
+
To customize the output create a template which suits your needs. Then supply the path to it in the `template` parameter.
130
+
131
+
If you wish to use the default template as a starting point, build the foliant project with `swaggerdoc` preprocessor turned on. After the first build the default template will appear in your foliant project dir under name `swagger.j2`.
0 commit comments