Skip to main content

Automatic API discovery system for multiple frameworks and VCS platforms

Project description

Code Discovery - Automatic API Discovery System

GitHub release License: MIT Python 3.9+

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:

  1. Triggers on push/PR events
  2. Scans the repository for API frameworks
  3. Extracts API endpoint information
  4. Generates OpenAPI specification
  5. Commits the spec back to the repository
  6. 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

  1. 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
  1. 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

License

MIT License - See LICENSE file for details

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_discovery-0.3.1.tar.gz (93.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_discovery-0.3.1-py3-none-any.whl (118.4 kB view details)

Uploaded Python 3

File details

Details for the file code_discovery-0.3.1.tar.gz.

File metadata

  • Download URL: code_discovery-0.3.1.tar.gz
  • Upload date:
  • Size: 93.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for code_discovery-0.3.1.tar.gz
Algorithm Hash digest
SHA256 201d5a93d81126966bc0701ff83763fd69793a66338405706bb9a542991e0432
MD5 0c0d4273c59a0e03951e665668573be4
BLAKE2b-256 54887a4b0d30c326447acb3e964398db06760b51c80f898c0c840559b8b9b04e

See more details on using hashes here.

File details

Details for the file code_discovery-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: code_discovery-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 118.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for code_discovery-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 59c5d5915e0d9dd54b2ac8bb470e2923b0cae9af3bd8eb3ff30051c2c8f1a3a6
MD5 27854756b37225d3e836b5f9e6082f31
BLAKE2b-256 7376d1af68baca320ce1e761b37fbcf68904bcbfcb3f4374a9bdc6a40ae35ebe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page