This guide explains how to use the generate-docs.sh script to create a complete, standalone documentation website for the Customer Management API.
The generate-docs.sh script creates a self-contained documentation website that includes:
- Interactive API Documentation (Swagger UI)
- Landing Page with navigation
- Technical Writing Guides converted from Markdown to HTML
- Postman Collections and testing resources
- Custom Styling and responsive design
- Bash shell (macOS, Linux, or WSL on Windows)
- curl (for downloading Swagger UI)
- sed (for text processing)
- pandoc (for converting Markdown to HTML)
- macOS:
brew install pandoc - Ubuntu/Debian:
sudo apt install pandoc - Windows: Download from https://pandoc.org/installing.html
- macOS:
Note: Without pandoc, the script will copy Markdown files as-is instead of converting them to HTML.
chmod +x generate-docs.sh./generate-docs.shImportant: The generated documentation must be served via HTTP (not opened as files) because Swagger UI needs to fetch the OpenAPI specification via AJAX, which browsers block with file:// protocol.
cd docs-site
python3 -m http.server 8081Press Ctrl+C in the terminal where the server is running, or if you need to kill it from another terminal:
# Find the process ID
lsof -i :8081
# Kill the process (replace PID with the actual process ID from above)
kill <PID>- Landing Page: http://localhost:8081/landing.html
- Interactive API: http://localhost:8081/index.html
- Technical Guides: http://localhost:8081/tech-writer-reference/
The script creates a docs-site/ directory with the following structure:
docs-site/
├── index.html # Swagger UI (Interactive API)
├── landing.html # Professional homepage
├── customer-api.yaml # OpenAPI specification
├── swagger-ui*.js/css # Swagger UI assets
├── style.css # Custom styling for documentation
├── navigation.html # Navigation component
├── tech-writer-reference/ # Converted documentation
│ ├── TECH_WRITER_GUIDE.html
│ ├── 01-generated-documentation-guide.html
│ ├── 02-manual-yaml-writing-guide.html
│ ├── 03-testing-validation-guide.html
│ ├── 04-api-documentation-publishing-guide.html
│ └── reference/ # Reference materials
│ ├── openapi-examples.html
│ ├── annotation-reference.html
│ └── tools-comparison.html
└── api-assets/ # Testing resources
├── postman/ # Postman collections
└── openapi/ # OpenAPI examples
- Creates output directory (
docs-site/) - Downloads Swagger UI from GitHub (latest master)
- Extracts Swagger UI assets to the docs-site directory
- Copies OpenAPI specification from
docs/tech-writer-reference/api-assets/openapi/customer-api.yaml - Configures Swagger UI to load your API instead of the petstore demo
- Updates
swagger-initializer.jswith the correct API path
- Detects pandoc availability
- If pandoc is available:
- Removes Jekyll front matter from Markdown files
- Extracts first heading as HTML title
- Removes duplicate headings from content
- Converts Markdown to styled HTML with custom CSS
- If pandoc is not available:
- Copies Markdown files as-is
- Copies custom landing page from
docs-template/index.html - Creates directory structure for assets
- Copies Postman collections and OpenAPI examples
- Generates navigation components
- Creates custom CSS for converted documentation
- Applies consistent styling across all pages
- Ensures responsive design for mobile compatibility
Symptom: Swagger UI shows "NetworkError when attempting to fetch resource"
Cause: Opening files with file:// protocol instead of HTTP
Solution: Start the Python HTTP server as described in Step 3
Symptom: Pages show the same title twice Cause: Both Jekyll front matter and first heading being processed Solution: The script now automatically handles this by extracting and removing duplicate headings
Symptom: Landing page link to Swagger UI doesn't work
Cause: Incorrect path in landing page template
Solution: The script now correctly links to index.html
Symptom: Interactive documentation shows petstore API
Cause: Swagger UI configuration not updated
Solution: The script now properly configures swagger-initializer.js
To use a different OpenAPI specification:
- Replace
docs/tech-writer-reference/api-assets/openapi/customer-api.yaml - Run
./generate-docs.sh
To customize the landing page:
- Edit
docs-template/index.html - Run
./generate-docs.sh
To add new documentation files:
- Add Markdown files to appropriate directories under
docs/ - Update the script to include them in the conversion process
- Run
./generate-docs.sh
The generated docs-site/ folder is completely self-contained and can be deployed to:
- GitHub Pages: Push to repository, enable Pages
- Netlify: Drag and drop
docs-site/folder - Vercel: Deploy via CLI or web interface
- AWS S3: Upload and enable static website hosting
- Apache: Copy to document root
- Nginx: Copy to web directory
- Any HTTP server: The folder contains only static files
# Create a new branch for GitHub Pages
git checkout -b gh-pages
git add docs-site/
git commit -m "Add generated documentation"
git push origin gh-pages
# Enable GitHub Pages in repository settings
# Point to gh-pages branch, docs-site/ folderWhen you update your documentation or API:
- Make changes to source files (Markdown docs, OpenAPI spec)
- Regenerate documentation:
rm -rf docs-site ./generate-docs.sh
- Test locally:
cd docs-site python3 -m http.server 8081 # Visit http://localhost:8081/landing.html # Stop with Ctrl+C when done
- Deploy updated files to your hosting platform
The generate-docs.sh script can be customized by modifying these sections:
# Line 9: Change output directory name
mkdir -p my-custom-docs
cd my-custom-docs# Around line 60: Modify the CSS section
cat > style.css << 'EOF'
/* Your custom CSS here */# Around line 36: Add more pandoc conversion commands
convert_md_to_html "../path/to/your/file.md" "output/path.html" "../style.css"Check internet connection and try again:
curl -L https://github.com/swagger-api/swagger-ui/archive/master.zipInstall pandoc or run without it:
- The script works without pandoc but copies Markdown files instead of converting to HTML
- Install pandoc for better HTML output with styling
Make script executable:
chmod +x generate-docs.shCheck what's using the port and kill it:
# Find what's using port 8081
lsof -i :8081
# Kill the process (replace PID with the actual process ID)
kill <PID>
# Then start the server normally
python3 -m http.server 8081Or use a different port:
python3 -m http.server 8082
# Then visit http://localhost:8082/landing.htmlIf you have the Spring Boot application running (./mvnw spring-boot:run):
- API runs on: http://localhost:8080
- Documentation runs on: http://localhost:8081
- Test endpoints directly from Swagger UI by clicking "Try it out"
The Swagger UI will make requests to your running API, allowing full integration testing.
- With pandoc: ~10-15 seconds (includes Markdown conversion)
- Without pandoc: ~5-8 seconds (copies files only)
- Swagger UI download: ~2-5 seconds (cached after first run)
- Complete site: ~2-3 MB
- Swagger UI assets: ~1.7 MB
- Documentation: ~300-500 KB
- Custom assets: ~100-200 KB
- The HTTP server is only accessible from your machine
- No authentication or security headers needed for local use
- Consider adding HTTPS
- Implement proper security headers
- Use CDN for better performance
- Add authentication if documentation is private
The generate-docs.sh script provides a complete solution for creating professional, interactive API documentation. It combines the power of Swagger UI for API testing with beautifully formatted technical documentation, all in a self-contained package ready for deployment anywhere.
For questions or issues, refer to the troubleshooting section or check the script source code for detailed implementation.