Import OpenAPI/Swagger specifications into Grav pages for the Helios documentation theme.
- Import from local files (JSON/YAML) or URLs
- Supports OpenAPI 3.x and Swagger 2.x specifications
- Generates structured documentation pages:
- Chapter pages for API tag groups
- API endpoint pages with parameters, examples, and response codes
- Auto-generates request/response examples from schemas
- Preserves manual content additions when updating
- Incremental updates (only update changed endpoints)
- Grav 1.7+
- PHP 8.1+
- Helios Theme 1.0+
Install via GPM:
bin/gpm install api-doc-importOr manually download and extract to user/plugins/api-doc-import.
The primary way to import API documentation is via the CLI:
# Import from local file
bin/plugin api-doc-import import openapi.yaml v3/api-reference
# Import from URL
bin/plugin api-doc-import import https://api.example.com/openapi.json v3/api-reference
# Update existing pages
bin/plugin api-doc-import import openapi.yaml v3/api-reference --update
# Update without preserving manual content
bin/plugin api-doc-import import openapi.yaml v3/api-reference --update --no-preserve
# Flat structure (no tag folders)
bin/plugin api-doc-import import openapi.yaml v3/api-reference --flatGiven an OpenAPI spec with tags "Users" and "Posts", the plugin generates:
pages/
└── v3/
└── api-reference/
├── 01.users/
│ ├── chapter.md
│ ├── 01.create-user/
│ │ └── api-endpoint.md
│ ├── 02.get-user/
│ │ └── api-endpoint.md
│ └── 03.update-user/
│ └── api-endpoint.md
└── 02.posts/
├── chapter.md
└── ...
Each api-endpoint.md contains frontmatter with:
---
title: Create User
template: api-endpoint
taxonomy:
category: docs
api:
method: POST
path: /users
description: Creates a new user account
parameters:
- name: email
type: string
required: true
description: User's email address
- name: name
type: string
required: true
description: User's display name
request_example: |
{
"email": "john@example.com",
"name": "John Doe"
}
response_example: |
{
"id": "usr_abc123",
"email": "john@example.com",
"name": "John Doe"
}
response_codes:
- code: 201
description: User created successfully
- code: 400
description: Invalid request body
---Configure defaults in user/config/plugins/api-doc-import.yaml:
enabled: true
# Default output path
output_path: 'api-reference'
# Organize endpoints by tags
organize_by_tags: true
# Starting number for folder prefixes
folder_prefix_start: 1
# Update existing pages when re-importing
update_existing: false
# Preserve manual content when updating
preserve_content: true- Initial Import: Run the import command to generate pages from your OpenAPI spec
- Customize: Edit generated pages to add additional notes, examples, or documentation
- Update: When your API changes, re-run with
--updateto sync changes while preserving your customizations
MIT License - see LICENSE for details.