A Python script to extract API endpoint details from Swagger/OpenAPI YAML files and convert them into a structured CSV format. This tool is perfect for API documentation, analysis, and review workflows.
- Supports Swagger/OpenAPI 3.0 specifications.
- Extracts and organizes:
- Tags: API categories for grouping endpoints.
- Methods: HTTP methods (GET, POST, PUT, DELETE, etc.).
- Paths: API endpoint paths.
- Summary: Short API descriptions.
- Description: Detailed API documentation.
- Outputs a clean CSV file for further processing or review.
- Python 3.x
- PyYAML library (for reading YAML files)
Install the required dependency using pip:
pip3 install pyyamlgit clone https://github.com/gobind-singh/api-spec-toolkit.git
cd api-spec-toolkitRun the script with the following command:
python3 extractor.py <input_swagger.yaml> <output_file.csv>Parameters:
- <input_swagger.yaml>: Path to your Swagger/OpenAPI YAML file.
- <output_file.csv>: Path where the resulting CSV file will be saved.
openapi: 3.0.0
info:
title: Sample API
version: "1.0"
paths:
/users:
get:
tags:
- Users
summary: Get Users
description: Fetch a list of users.
/users/{id}:
get:
tags:
- Users
summary: Get User by ID
description: Fetch a user by their ID.
/orders:
post:
tags:
- Orders
summary: Create Order
description: Create a new order.| Tag | Method | Path | Summary | Description |
|---|---|---|---|---|
| Users | GET | /users | Get Users | Fetch a list of users. |
| Users | GET | /users/{id} | Get User by ID | Fetch a user by their ID. |
| Orders | POST | /orders | Create Order | Create a new order. |