A powerful CLI tool and GitHub Action for working with OpenAPI specifications. Generate specs from code, convert to various formats, merge multiple specs, and sync documentation files.
- Generate: Create OpenAPI specs from Go Echo handler code using AI
- Convert: Transform OpenAPI specs into Nginx configurations and VitePress documentation
- Merge: Combine multiple OpenAPI specifications into one unified spec
- Sync: Synchronize documentation files across repositories using pattern-based mapping
- External reference resolution: Automatically resolves
$refreferences to external files - Batch processing: Process multiple specifications at once
- GitHub Action support: Available as a GitHub Action for CI/CD pipelines
- Strict validation: Ensures OpenAPI specifications meet documentation standards
For detailed information about OpenAPI specification requirements, validation rules, and best practices, see OPENAPI.md.
- Go 1.23 or later
- Git installed
- For
generatecommand: Ollama running locally (default: http://localhost:11434)
go install github.com/nimling/nimo-api@latestFor a specific version:
go install github.com/nimling/nimo-api@v2.0.0git clone git@github.com:nimling/nimo-api.git
cd nimo-api
just build
just installAdd to your workflow:
- uses: nimling/nimo-api@latest
with:
command: 'convert'
openapi-file: './api.yml'
docs-dir: './docs/api'The tool provides four main commands: generate, convert, merge, and sync.
Generate OpenAPI specifications by analyzing Go Echo handler code using AI.
nimo generate -m <main.go> -r <README.md> [flags]Flags:
-m, --main- Path to main.go file (required)-r, --readme- Path to README.md file (required)-a, --ai-endpoint- AI API endpoint (default:http://localhost:11434)-c, --max-concurrent- Maximum concurrent AI API calls (default:5)-o, --output- Output file path (default:openapi.yaml)-f, --format- Output format: yaml or json (default:yaml)
Examples:
# Generate spec from Go handlers
nimo generate -m ./main.go -r ./README.md
# Specify AI endpoint and output format
nimo generate -m ./main.go -r ./README.md -a http://localhost:11434 -f json
# Use environment variables
export AI_ENDPOINT=http://localhost:11434
nimo generate -m ./main.go -r ./README.mdTransform OpenAPI specifications into Nginx configurations and VitePress documentation.
nimo convert [input-files...] [flags]| Flag | Short | Description | Example |
|---|---|---|---|
--output |
-o |
Output directory for Nginx configuration files | -o ./nginx/ |
--docs |
-d |
Output directory for VitePress API documentation | -d ./docs/api/ |
--index |
-i |
Path to generate/update VitePress index.md with features | -i ./docs/index.md |
--file-prefix |
Prefix for generated file names | --file-prefix api- |
|
--common-prefix |
URL path prefix for VitePress documentation links | --common-prefix /api/v1 |
|
--write-introduction |
Generate introduction page for API documentation | --write-introduction |
|
--merge-responses-inline |
Merge allOf response definitions into single inline objects | --merge-responses-inline |
# Convert single file to Nginx config
nimo convert api.yaml -o ./nginx/
# Generate VitePress documentation only
nimo convert api.yaml -d ./docs/api/
# Generate both with all options
nimo convert api.yaml \
-o ./nginx/ \
-d ./docs/api/ \
-i ./docs/index.md \
--file-prefix myapi \
--common-prefix /api/v1 \
--write-introduction \
--merge-responses-inlineCombine multiple OpenAPI specification files into a single unified spec.
nimo merge [spec-files...] [flags]Flags:
-o, --output- Output file path (default:api.spec.json)-f, --force- Force overwrite existing file--title- Override API title--description- Override API description--version- Override API version--contact-name- Override contact name--contact-email- Override contact email--server- Override server URL--format- Output format: yaml or json (default:json)--strategy- Conflict resolution:firstorlast(default:last)--text-format- Text formatting:asis,html, ormarkdown(default:asis)
Examples:
# Merge multiple specs
nimo merge spec1.json spec2.json spec3.json -o merged.json
# Override metadata and server
nimo merge *.json --title "My API" --version "v1.0.0" --server "https://api.example.com" -o api.json
# Convert markdown to HTML in descriptions
nimo merge spec1.json spec2.json --text-format html -f
# Use environment variables
export VERSION=v1.0.0
export API_TITLE="Company API"
export CONTACT_NAME="API Team"
export CONTACT_EMAIL="api@example.com"
nimo merge spec1.json spec2.json spec3.json -fSynchronize documentation files between directories using pattern-based mapping. Supports both individual file copying with renaming and full directory copying when target files exist.
nimo sync -s <sync-map>| Flag | Short | Description | Required |
|---|---|---|---|
--sync-map |
-s |
JSON mapping file or inline JSON for sync command | Yes |
Create a JSON file or inline JSON with your synchronization rules. The destination must always specify a target filename:
{
"output/guides/myproject/index.md": [
".*docs/guide\\.md$",
".*docs/guide$"
],
"output/api/myproject/index.md": [
".*docs/api\\.md$",
".*docs/api$"
],
"output/tutorials/getting-started.md": [
".*tutorials/getting-started\\.md$",
".*docs/getting-started\\.md$"
]
}Behavior:
- If source matches a file: Copies and renames to the destination filename
- If source matches a directory: Checks for a file with the destination filename inside, then copies the entire directory contents
# Sync documentation using mapping file
nimo sync -s ./sync-config.json
# Typical CI/CD usage
nimo sync --sync-map ./docs/mapping.jsonThe tool is available as a GitHub Action supporting all four commands.
- uses: nimling/nimo-api@latest
with:
command: 'convert'
openapi-file: './api.yml'
docs-dir: './docs/api'Generate OpenAPI from Go code:
- uses: nimling/nimo-api@latest
with:
command: 'generate'
main: './main.go'
readme: './README.md'
output: 'openapi.yaml'Convert to documentation:
- uses: nimling/nimo-api@latest
with:
command: 'convert'
openapi-file: 'api.yaml'
docs-dir: './docs/api'
common-prefix: '/api/v1'Merge multiple specs:
- uses: nimling/nimo-api@latest
with:
command: 'merge'
specs: 'spec1.json spec2.json spec3.json'
output: 'merged.json'
title: 'My API'
version: 'v1.0.0'Sync documentation:
- uses: nimling/nimo-api@latest
with:
command: 'sync'
sync-map: './sync-config.json'See action.yml for all available inputs.
The converter generates:
- Location blocks with path patterns
- Method restrictions (GET, POST, PUT, DELETE)
- Upstream proxy configurations
- Security headers and CORS settings
- Markdown files for each endpoint
- Interactive API documentation
- Request/response examples
- Schema definitions
- Navigation structure
The converter enforces strict validation to ensure high-quality API documentation:
- Required fields: All paths must have
summaryanddescription - Operation IDs: Every operation must have a unique
operationId - Path format: Paths must start with
/and have valid segments - External references: All
$refreferences must resolve successfully
For complete validation rules and OpenAPI compliance guidelines, see OPENAPI.md.
- Go 1.23+
- just command runner
- Ollama (for testing generate command)
# Build the binary
just build
# Install to $GOPATH/bin
just install
# Run in development mode
just dev
# Test all commands
just test-all
# Clean build artifacts
just cleannimo-api/
├── cmd/main.go # CLI entry point
├── internal/
│ ├── generate.go # Generate command
│ ├── convert.go # Convert command
│ ├── merge.go # Merge command
│ ├── sync.go # Sync command
│ └── utils.go # Banner and version utils
├── pkg/
│ ├── ai/ # AI client (Ollama)
│ ├── parser/ # Go Echo handler parser
│ ├── merger/ # OpenAPI spec merger
│ └── converter/ # Spec conversion logic
├── action.yml # GitHub Action definition
├── justfile # Build commands
└── .env # Version configuration
Version is read from .env file:
APP_VERSION=v1.0.0-alpha6Update version and deploy:
just deploy # Increments alpha, commits, tags, and pushesIf you get "module not found" errors, configure git:
git config --global url."git@github.com:nimling/".insteadOf "github.com/nimling/"Ensure $GOPATH/bin is in your PATH:
export PATH="$PATH:$(go env GOPATH)/bin"For the generate command, ensure Ollama is running:
# Check if Ollama is running
curl http://localhost:11434/api/tags
# Start Ollama if needed
ollama serveContributions are welcome! Please feel free to submit a Pull Request.
MIT