Name | foliantcontrib.swaggerdoc JSON |
Version |
1.2.6
JSON |
| download |
home_page | None |
Summary | Documentation generator for Swagger API |
upload_time | 2025-01-22 04:43:35 |
maintainer | None |
docs_url | None |
author | Daniil Minukhin |
requires_python | None |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[](https://pypi.org/project/foliantcontrib.swaggerdoc/) [](https://github.com/foliant-docs/foliantcontrib.swaggerdoc)
# Swagger API Docs Generator for Foliant

*The static site on the picture was built with [Slate](https://foliant-docs.github.io/docs/backends/slate/) backend together with SwaggerDoc preprocessor*
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.
## Installation
```bash
$ pip install foliantcontrib.swaggerdoc
```
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/)):
```
npm install -g widdershins
```
## Config
To enable the preprocessor, add `swaggerdoc` to `preprocessors` section in the project config:
```yaml
preprocessors:
- swaggerdoc
```
The preprocessor has a number of options:
```yaml
preprocessors:
- swaggerdoc:
spec_url: http://localhost/swagger.json
spec_path: swagger.json
additional_json_path: tags.json
mode: widdershins
template: swagger.j2
environment: env.yaml
strict: false
```
`spec_url`
: URL to Swagger spec file. If it is a list — preprocessor takes the first url which works.
`spec_path`
: Local path to Swagger spec file (relative to project dir).
> 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.
`additional_json_path`
: 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*.
`mode`
: Determines how the Swagger spec file would be converted to markdown. Should be one of: `jinja`, `widdershins`. Default: `widdershins`
> `jinja` mode is deprecated. It may be removed in future
`template`
: Only for `jinja` mode. Path to jinja-template for rendering the generated documentation. Path is relative to the project directory. If no template is specified preprocessor will use default template (and put it into project dir if it was missing). Default: `swagger.j2`
`environment`
: Only for `widdershins` mode. Parameters for widdershins converter. You can either pass a string containing relative path to YAML or JSON file with all parameters (like in example above) or specify all parameters in YAML format under this key. [More info](https://github.com/mermade/widdershins) on widdershins parameters.
`strict`
: If the `strict` option is enabled, then if a critical error is detected, the build will be aborted after applying the preprocessor.
## Usage
Add a `<swaggerdoc></swaggerdoc>` tag at the position in the document where the generated documentation should be inserted:
```markdown
# Introduction
This document contains the automatically generated documentation of our API.
<swaggerdoc></swaggerdoc>
```
Each time the preprocessor encounters the tag `<swaggerdoc></swaggerdoc>` it inserts the whole generated documentation text instead of it. The path or url to Swagger spec file are taken from foliant.yml.
You can also specify some parameters (or all of them) in the tag options:
```markdown
# Introduction
Introduction text for API documentation.
<swaggerdoc spec_url="http://localhost/swagger.json"
mode="jinja"
template="swagger.j2">
</swaggerdoc>
<swaggerdoc spec_url="http://localhost/swagger.json"
mode="widdershins"
environment="env.yml">
</swaggerdoc>
```
Tag parameters have the highest priority.
This way you can have documentation from several different Swagger spec files in one foliant project (even in one md-file if you like it so).
## Customizing output
### Widdershins
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.
1. Clone the original widdershins [repository](https://github.com/mermade/widdershins) and modify the templates located in one of the subfolders in the **templates** folder.
2. Save the modified templates somewhere near your foliant project.
3. Specify the path to modified templates in the `user_templates` field of the `environment` configuration. For example, like this:
```yaml
preprocessors:
- swaggerdoc:
spec_path: swagger.yml
environment:
user_templates: !path ./widdershins_templates/
```
### Jinja
> `jinja` mode is deprecated. It may be removed in future
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`.
To customize the output create a template which suits your needs. Then supply the path to it in the `template` parameter.
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`.
## Tests
To run the tests locally, you will need to install NodeJS.
If you have NodeJS installed, then run:
```bash
./test.sh
```
Alternatively, you can also use a Docker to run the tests. To do so, run:
```bash
./test_in_docker.sh
```
Raw data
{
"_id": null,
"home_page": null,
"name": "foliantcontrib.swaggerdoc",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Daniil Minukhin",
"author_email": "ddddsa@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ca/e1/161f9cd2dd82aac9ada831943977915e903fa297498680baebc9b4014a8f/foliantcontrib_swaggerdoc-1.2.6.tar.gz",
"platform": "any",
"description": "[](https://pypi.org/project/foliantcontrib.swaggerdoc/) [](https://github.com/foliant-docs/foliantcontrib.swaggerdoc)\n\n# Swagger API Docs Generator for Foliant\n\n\n\n*The static site on the picture was built with [Slate](https://foliant-docs.github.io/docs/backends/slate/) backend together with SwaggerDoc preprocessor*\n\nThis 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.\n\n## Installation\n\n```bash\n$ pip install foliantcontrib.swaggerdoc\n```\n\nThis 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/)):\n\n```\nnpm install -g widdershins\n```\n\n## Config\n\nTo enable the preprocessor, add `swaggerdoc` to `preprocessors` section in the project config:\n\n```yaml\npreprocessors:\n - swaggerdoc\n```\n\nThe preprocessor has a number of options:\n\n```yaml\npreprocessors:\n - swaggerdoc:\n spec_url: http://localhost/swagger.json\n spec_path: swagger.json\n additional_json_path: tags.json\n mode: widdershins\n template: swagger.j2\n environment: env.yaml\n strict: false\n```\n\n`spec_url`\n: URL to Swagger spec file. If it is a list \u2014 preprocessor takes the first url which works.\n\n`spec_path`\n: Local path to Swagger spec file (relative to project dir).\n\n> If both url and path are specified \u2014 preprocessor first tries to fetch spec from url, and then (if that fails) looks for the file on local path.\n\n`additional_json_path`\n: 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*.\n\n`mode`\n: Determines how the Swagger spec file would be converted to markdown. Should be one of: `jinja`, `widdershins`. Default: `widdershins`\n\n> `jinja` mode is deprecated. It may be removed in future\n\n`template`\n: Only for `jinja` mode. Path to jinja-template for rendering the generated documentation. Path is relative to the project directory. If no template is specified preprocessor will use default template (and put it into project dir if it was missing). Default: `swagger.j2`\n\n`environment`\n: Only for `widdershins` mode. Parameters for widdershins converter. You can either pass a string containing relative path to YAML or JSON file with all parameters (like in example above) or specify all parameters in YAML format under this key. [More info](https://github.com/mermade/widdershins) on widdershins parameters.\n\n`strict`\n: If the `strict` option is enabled, then if a critical error is detected, the build will be aborted after applying the preprocessor.\n\n## Usage\n\nAdd a `<swaggerdoc></swaggerdoc>` tag at the position in the document where the generated documentation should be inserted:\n\n```markdown\n# Introduction\n\nThis document contains the automatically generated documentation of our API.\n\n<swaggerdoc></swaggerdoc>\n```\n\nEach time the preprocessor encounters the tag `<swaggerdoc></swaggerdoc>` it inserts the whole generated documentation text instead of it. The path or url to Swagger spec file are taken from foliant.yml.\n\nYou can also specify some parameters (or all of them) in the tag options:\n\n```markdown\n# Introduction\n\nIntroduction text for API documentation.\n\n<swaggerdoc spec_url=\"http://localhost/swagger.json\"\n mode=\"jinja\"\n template=\"swagger.j2\">\n</swaggerdoc>\n\n<swaggerdoc spec_url=\"http://localhost/swagger.json\"\n mode=\"widdershins\"\n environment=\"env.yml\">\n</swaggerdoc>\n```\n\nTag parameters have the highest priority.\n\nThis way you can have documentation from several different Swagger spec files in one foliant project (even in one md-file if you like it so).\n\n## Customizing output\n\n### Widdershins\n\nIn `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.\n\n1. Clone the original widdershins [repository](https://github.com/mermade/widdershins) and modify the templates located in one of the subfolders in the **templates** folder.\n2. Save the modified templates somewhere near your foliant project.\n3. Specify the path to modified templates in the `user_templates` field of the `environment` configuration. For example, like this:\n\n```yaml\npreprocessors:\n - swaggerdoc:\n spec_path: swagger.yml\n environment:\n user_templates: !path ./widdershins_templates/\n```\n\n### Jinja\n\n> `jinja` mode is deprecated. It may be removed in future\n\nIn `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`.\n\nTo customize the output create a template which suits your needs. Then supply the path to it in the `template` parameter.\n\nIf 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`.\n\n## Tests\n\nTo run the tests locally, you will need to install NodeJS.\nIf you have NodeJS installed, then run:\n```bash\n./test.sh\n```\nAlternatively, you can also use a Docker to run the tests. To do so, run:\n```bash\n./test_in_docker.sh\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Documentation generator for Swagger API",
"version": "1.2.6",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "fac60d5a72ee3305a6c29a8421cec057c683452c2310449c0f4d373840e8f556",
"md5": "270526fca4ef878d4ecce3bda5a57d92",
"sha256": "ad9c58789d730884a8b9b4672b398963e37ade16eb4ff4f4355142289ddc563e"
},
"downloads": -1,
"filename": "foliantcontrib.swaggerdoc-1.2.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "270526fca4ef878d4ecce3bda5a57d92",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9536,
"upload_time": "2025-01-22T04:43:33",
"upload_time_iso_8601": "2025-01-22T04:43:33.754230Z",
"url": "https://files.pythonhosted.org/packages/fa/c6/0d5a72ee3305a6c29a8421cec057c683452c2310449c0f4d373840e8f556/foliantcontrib.swaggerdoc-1.2.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cae1161f9cd2dd82aac9ada831943977915e903fa297498680baebc9b4014a8f",
"md5": "9cfcbfbabcba2b528023b15e151c61be",
"sha256": "32f223e3fa39443a7ffa89058f011da6f9bd55e55ade86f9287deec687bd1cbd"
},
"downloads": -1,
"filename": "foliantcontrib_swaggerdoc-1.2.6.tar.gz",
"has_sig": false,
"md5_digest": "9cfcbfbabcba2b528023b15e151c61be",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11830,
"upload_time": "2025-01-22T04:43:35",
"upload_time_iso_8601": "2025-01-22T04:43:35.477961Z",
"url": "https://files.pythonhosted.org/packages/ca/e1/161f9cd2dd82aac9ada831943977915e903fa297498680baebc9b4014a8f/foliantcontrib_swaggerdoc-1.2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-22 04:43:35",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "foliantcontrib.swaggerdoc"
}