Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 18, 2025

This PR extends swagger-coverage-cli beyond REST/OpenAPI specifications to provide unified test coverage analysis across multiple API protocols, addressing the need for comprehensive API portfolio management in modern microservices architectures.

New Protocol Support

gRPC Integration

  • Protocol Buffer Parsing: Added support for .proto files using protobufjs library
  • Service Extraction: Automatically extracts gRPC services, methods, and message types
  • Path Matching: Implements gRPC-specific path matching for /package.service/method format
  • Request Validation: Protocol-aware matching for gRPC POST requests with proper content-type validation

GraphQL Integration

  • Schema Parsing: Added support for .graphql and .gql files using graphql library
  • Operation Extraction: Extracts queries, mutations, and subscriptions with argument analysis
  • Endpoint Matching: Handles GraphQL's unified /graphql endpoint with query body inspection
  • Type System: Full support for GraphQL type definitions and field relationships

Enhanced CLI Experience

The CLI now seamlessly handles mixed protocol APIs:

# Single protocol
swagger-coverage-cli user-service.proto collection.json
swagger-coverage-cli schema.graphql collection.json

# Mixed protocols in one command  
swagger-coverage-cli "api.yaml,service.proto,schema.graphql" collection.json

# All existing options work across protocols
swagger-coverage-cli "openapi.yaml,grpc.proto" collection.json --verbose --strict-body

Unified Reporting

  • Protocol Column: Added color-coded protocol identification in HTML reports (gRPC=green, GraphQL=pink, REST=blue)
  • Enhanced Search: Protocol-aware filtering and search functionality
  • Mixed Statistics: Unified coverage metrics across all API protocols
  • Backward Compatible: Existing OpenAPI reports unchanged

Technical Implementation

Core Architecture

  • Modular Design: New lib/grpc.js and lib/graphql.js modules maintain separation of concerns
  • Protocol Detection: Automatic file type detection based on extensions
  • Unified Matching: Enhanced matching engine with protocol-specific logic while preserving existing functionality

Smart Matching Logic

  • Protocol-Aware Paths: Different path matching strategies for each protocol type
  • Content Validation: Protocol-specific request body validation (protobuf vs JSON vs form data)
  • Method Handling: Intelligent HTTP method mapping (gRPC/GraphQL use POST, REST varies)

Quality Assurance

  • Zero Breaking Changes: All existing tests pass without modification
  • Comprehensive Testing: Added 21 new tests covering gRPC/GraphQL functionality, mixed protocol scenarios, and advanced features
  • Total Test Coverage: 161 tests across 20 test suites ensuring robust protocol support
  • CLI Integration: Full end-to-end testing with real protocol buffer and GraphQL schema files
  • Advanced Scenarios: Testing for nested gRPC services, complex GraphQL types, enterprise-scale deployments, and performance validation
  • Error Handling: Robust validation and error reporting for invalid protocol files

Enhanced Documentation

  • Complete README Overhaul: Comprehensive multi-protocol documentation with usage examples for each protocol
  • Protocol-Specific Guides: Detailed sections for REST, gRPC, GraphQL, and CSV usage patterns
  • Enterprise Examples: Real-world microservices scenarios and CI/CD integration examples
  • Visual Enhancements: Added protocol badges and improved formatting for better readability

Release Automation

  • Enhanced GitHub Actions: Updated release.yml workflow with multi-protocol feature highlights
  • Comprehensive Release Notes: Template includes protocol-specific capabilities and testing metrics
  • Quality Metrics: Automated validation of 161 tests across all supported protocols

Dependencies

Added two well-established libraries:

  • protobufjs ^7.2.6 - Industry standard for Protocol Buffer parsing
  • graphql ^16.8.1 - Official GraphQL.js implementation

Multi-Protocol Demo

Generated comprehensive coverage report demonstrating:

  • 4 Protocols in Single Analysis: REST (OpenAPI) + gRPC + GraphQL + CSV
  • 43 Total Operations across all protocol types
  • 30.23% Unified Coverage with protocol-specific breakdown
  • Color-Coded Protocol Column for easy identification and filtering

Multi-Protocol Report Header
Protocol Table with Color Coding

Use Cases

This enhancement enables organizations to:

  • Unified Coverage: Analyze API test coverage across their entire technology stack
  • Microservices Support: Handle mixed protocol architectures in a single tool
  • Team Efficiency: Reduce tooling complexity by using one coverage tool for all API types
  • Enterprise Scale: Support large API portfolios with diverse protocol requirements

The implementation maintains the tool's core philosophy of simplicity and ease of use while dramatically expanding its capabilities for modern API ecosystems.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] implement comprehensive support for gRPC and GraphQL APIs in swagger-coverage-cli, extending it beyond just REST/OpenAPI specifications to provide unified test coverage analysis across multiple API protocols and keep backward compapability Implement comprehensive gRPC and GraphQL API support with unified coverage analysis Sep 18, 2025
Copilot AI requested a review from dreamquality September 18, 2025 13:57
@dreamquality
Copy link
Owner

@copilot add more tests cases, update readme.md and prepare release.yml file. show me a report with multiple APIs

…entation, and enhance release.yml

Co-authored-by: dreamquality <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 18, 2025

@copilot add more tests cases, update readme.md and prepare release.yml file. show me a report with multiple APIs

All requests completed!

📊 Added Comprehensive Test Cases - Created comprehensive-protocol.test.js with 14 additional tests covering:

  • Advanced gRPC features (nested services, streaming methods)
  • Complex GraphQL scenarios (field arguments, type categorization)
  • Mixed protocol enterprise scenarios
  • Performance and scalability validation
  • Protocol-specific edge cases

📖 Updated README.md - Complete documentation overhaul with:

  • Multi-protocol support section with usage examples
  • Protocol-specific features and capabilities
  • Enterprise scenarios and CI/CD integration examples
  • Enhanced visual formatting with protocol badges

🚀 Enhanced release.yml - Updated GitHub Actions workflow with:

  • Multi-protocol feature highlights
  • Comprehensive testing information (161 tests, 20 suites)
  • Protocol-specific release notes template
  • Quality assurance metrics

📈 Multi-Protocol Report Demo - Generated comprehensive report showing:

  • 4 Protocols: REST + gRPC + GraphQL + CSV in single analysis
  • 43 Total Operations across all protocols
  • 30.23% Unified Coverage with protocol identification
  • Color-coded Protocol Column for easy visualization

Screenshots:

Tests: All 161 tests passing ✅ (commit: 4bbcf02)

Copilot finished work on behalf of dreamquality September 18, 2025 14:40
@dreamquality dreamquality marked this pull request as ready for review September 19, 2025 13:56
@dreamquality dreamquality merged commit 36fbc3f into main Sep 19, 2025
2 checks passed
@dreamquality dreamquality deleted the copilot/fix-e002b8c7-1968-41ee-a8c1-6381351d306c branch September 19, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants