Automatic API discovery system for multiple frameworks and VCS platforms
Project description
Code Discovery - Automatic API Discovery System
Overview
Code Discovery is an automated system that discovers API endpoints in code repositories and generates OpenAPI specifications. It supports multiple version control systems and frameworks, running entirely within your VCS runners for maximum security.
โก Quick Start
# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/code-discovery.git
cd code-discovery
# 2. Install
pip install -r requirements.txt
pip install -e .
# 3. Run on your project
code-discovery --repo-path /path/to/your/api/project
โ
That's it! Your OpenAPI spec is generated at openapi-spec.yaml
๐ Documentation: See docs/ directory for detailed guides
Features
- Multi-VCS Support: GitHub, GitLab, Jenkins, CircleCI, Harness
- Multi-Framework Support:
- Java: Spring Boot, Micronaut
- Python: FastAPI, Flask
- .NET: ASP.NET Core
- Automatic OpenAPI Generation: Discovers endpoints, inputs, outputs, and authentication requirements
- Secure Execution: Runs entirely on your infrastructure - code never leaves your VCS environment
- Extensible Architecture: Easy to add new frameworks and VCS platforms
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VCS Platform โ
โ (GitHub/GitLab/Jenkins/CircleCI/Harness) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Orchestrator โ
โ - Coordinates the discovery workflow โ
โ - Manages VCS interactions โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Detectorsโ โ Parsers โ โGenerator โ
โ โ โ โ โ โ
โFramework โ โAPI Info โ โ OpenAPI โ
โDetection โ โExtractionโ โ Spec โ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
Installation
Method 1: Install from GitHub (Recommended)
# Clone the repository
git clone https://github.com/YOUR_USERNAME/code-discovery.git
cd code-discovery
# Install dependencies and package
pip install -r requirements.txt
pip install -e .
# Verify installation
code-discovery --version
๐ Installation: Install from PyPI: pip install code-discovery
Method 2: CI/CD Integration
GitHub Actions - Add to .github/workflows/api-discovery.yml:
- name: Install Code Discovery
run: |
git clone https://github.com/YOUR_USERNAME/code-discovery.git /tmp/code-discovery
cd /tmp/code-discovery
pip install -r requirements.txt
pip install -e .
- name: Run Discovery
run: code-discovery --repo-path .
GitLab CI - Add to .gitlab-ci.yml:
before_script:
- git clone https://github.com/YOUR_USERNAME/code-discovery.git /tmp/code-discovery
- cd /tmp/code-discovery && pip install -r requirements.txt && pip install -e .
- cd $CI_PROJECT_DIR
script:
- code-discovery --repo-path .
See example configurations in .github/workflows/, .gitlab-ci.yml, Jenkinsfile, etc.
Configuration
API Security Configuration (.apisec)
Create a .apisec file for API authentication:
code-discovery --create-apisec
Edit the file with your API endpoint and token:
[api-discovery]
endpoint = https://api.your-service.com/v1/discovery
token = your-api-token-here
See docs/APISEC_CONFIGURATION.md for details.
Project Configuration (.codediscovery.yml)
Create a .codediscovery.yml file in your repository root (optional):
# API Discovery Configuration
api_discovery:
enabled: true
# Frameworks to scan (leave empty to auto-detect all)
frameworks:
- spring-boot
- micronaut
- fastapi
- flask
- aspnet-core
# OpenAPI specification settings
openapi:
version: "3.0.0"
output_path: "openapi-spec.yaml"
include_examples: true
# External API endpoint (optional)
external_api:
enabled: true
endpoint: "https://api.example.com/openapi/upload"
auth_token_env: "API_DISCOVERY_TOKEN"
Usage
Automatic (Recommended)
Once installed as a VCS app, the system automatically:
- Triggers on push/PR events
- Scans the repository for API frameworks
- Extracts API endpoint information
- Generates OpenAPI specification
- Commits the spec back to the repository
- Notifies your external API endpoint
Manual Execution
# Run discovery on current directory
python -m src.main
# Specify repository path
python -m src.main --repo-path /path/to/repo
# Dry run (don't commit back)
python -m src.main --dry-run
Extending the System
Adding a New Framework
- Create a detector in
src/detectors/your_framework.py:
from src.detectors.base import BaseDetector
class YourFrameworkDetector(BaseDetector):
def detect(self) -> bool:
# Detection logic
pass
- Create a parser in
src/parsers/your_framework_parser.py:
from src.parsers.base import BaseParser
class YourFrameworkParser(BaseParser):
def parse(self) -> List[APIEndpoint]:
# Parsing logic
pass
Adding a New VCS Platform
Implement the BaseVCSAdapter interface in src/vcs/your_platform.py:
from src.vcs.base import BaseVCSAdapter
class YourPlatformAdapter(BaseVCSAdapter):
def get_repository_path(self) -> str:
pass
def commit_file(self, file_path: str, message: str):
pass
Security Considerations
- Code never leaves your VCS environment
- Runs on your own runners/agents
- Supports secret management via environment variables
- OpenAPI specs are committed to your repository under your control
Documentation
- State Management - How state management works
- GitHub Actions - Publishing and using GitHub Actions
- API Security Configuration - .apisec file setup
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code_discovery-0.2.2.tar.gz.
File metadata
- Download URL: code_discovery-0.2.2.tar.gz
- Upload date:
- Size: 78.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c796296eee044c04e3f9a0b9de814e1da3b726d635f2673ed7bcc25f9ec6056
|
|
| MD5 |
5a3a72f3f788bcfdcf6f3bfc78282807
|
|
| BLAKE2b-256 |
8b746110bd7e427aa48887a11d273c9445ca3c2ccf5ad39cd67ab7589ed8055a
|
File details
Details for the file code_discovery-0.2.2-py3-none-any.whl.
File metadata
- Download URL: code_discovery-0.2.2-py3-none-any.whl
- Upload date:
- Size: 100.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37fa2cb98bbecbf873f44f0bba5a0c9950b4f9a307f2ed2c1b4967692dc4d8f5
|
|
| MD5 |
3c262ea00e2aec022dcd354835155080
|
|
| BLAKE2b-256 |
d26392be917e4b9d6d4e5f81c77c00221bdd7af4009a246e8ebc714c06a346f7
|