{"id":42212927,"url":"https://github.com/foliant-docs/foliantcontrib.swaggerdoc","last_synced_at":"2026-01-27T01:06:57.340Z","repository":{"id":92058860,"uuid":"150753282","full_name":"foliant-docs/foliantcontrib.swaggerdoc","owner":"foliant-docs","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-22T04:43:01.000Z","size":440,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-23T11:27:04.855Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foliant-docs.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-28T14:34:09.000Z","updated_at":"2025-01-22T04:42:18.000Z","dependencies_parsed_at":"2024-12-23T08:25:06.028Z","dependency_job_id":"40191d64-22a5-4efb-a7d5-09874f65d69f","html_url":"https://github.com/foliant-docs/foliantcontrib.swaggerdoc","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/foliant-docs/foliantcontrib.swaggerdoc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.swaggerdoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.swaggerdoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.swaggerdoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.swaggerdoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foliant-docs","download_url":"https://codeload.github.com/foliant-docs/foliantcontrib.swaggerdoc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foliant-docs%2Ffoliantcontrib.swaggerdoc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28794644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T21:49:50.245Z","status":"ssl_error","status_checked_at":"2026-01-26T21:48:29.455Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-27T01:06:55.614Z","updated_at":"2026-01-27T01:06:57.322Z","avatar_url":"https://github.com/foliant-docs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://img.shields.io/pypi/v/foliantcontrib.swaggerdoc.svg)](https://pypi.org/project/foliantcontrib.swaggerdoc/)  [![](https://img.shields.io/github/v/tag/foliant-docs/foliantcontrib.swaggerdoc.svg?label=GitHub)](https://github.com/foliant-docs/foliantcontrib.swaggerdoc)\n\n# Swagger API Docs Generator for Foliant\n\n![](img/swagger.png)\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 — preprocessor takes the first url which works.\n\n`spec_path`\n:    Local path to Swagger spec file (relative to project dir).\n\n\u003e 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.\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\u003e `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 `\u003cswaggerdoc\u003e\u003c/swaggerdoc\u003e` 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\u003cswaggerdoc\u003e\u003c/swaggerdoc\u003e\n```\n\nEach time the preprocessor encounters the tag `\u003cswaggerdoc\u003e\u003c/swaggerdoc\u003e` 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\u003cswaggerdoc spec_url=\"http://localhost/swagger.json\"\n            mode=\"jinja\"\n            template=\"swagger.j2\"\u003e\n\u003c/swaggerdoc\u003e\n\n\u003cswaggerdoc spec_url=\"http://localhost/swagger.json\"\n            mode=\"widdershins\"\n            environment=\"env.yml\"\u003e\n\u003c/swaggerdoc\u003e\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\u003e `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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoliant-docs%2Ffoliantcontrib.swaggerdoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoliant-docs%2Ffoliantcontrib.swaggerdoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoliant-docs%2Ffoliantcontrib.swaggerdoc/lists"}