Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 16, 2025

Overview

This PR implements 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.

Multi-Protocol Coverage Report

Features Added

🔧 gRPC Support

  • Protocol Buffer Parsing: Automatically parses .proto files to extract service definitions and RPC methods
  • Flexible URL Matching: Supports various gRPC URL patterns including /package.service/method and /service/method
  • gRPC-Web Compatible: Works with both traditional gRPC and gRPC-Web request formats
  • JSON Body Validation: Validates gRPC request bodies in strict mode for protobuf JSON representation

🌐 GraphQL Support

  • Schema Parsing: Automatically parses GraphQL schema files (.graphql, .gql)
  • Operation Detection: Identifies and tracks queries, mutations, and subscriptions separately
  • Field-Level Matching: Precise matching of specific GraphQL operations to Postman requests
  • Query Validation: Validates GraphQL query syntax and field usage in request bodies
  • Custom Root Types: Supports custom query/mutation/subscription type names

🚀 Enhanced Architecture

New Modules:

  • lib/grpc.js - Protocol Buffer parsing and gRPC operation extraction
  • lib/graphql.js - GraphQL schema parsing and operation extraction
  • Enhanced lib/match.js with protocol-aware matching logic

CLI Improvements:

  • Auto-detection by file extension (.proto, .graphql, .gql)
  • Multi-protocol specification support in single command
  • Protocol-specific verbose logging
  • Updated help text and argument descriptions

Usage Examples

# gRPC API coverage analysis
swagger-coverage-cli user-service.proto grpc-collection.json --strict-body

# GraphQL API coverage analysis  
swagger-coverage-cli blog-schema.graphql graphql-collection.json --strict-body

# Mixed protocol analysis in single command
swagger-coverage-cli "api.yaml,service.proto,schema.graphql" collection.json

Technical Implementation

Protocol Detection & Parsing

  • Automatic file type detection by extension
  • Protocol-specific parsers with comprehensive validation
  • Unified operation model across all supported protocols

Smart Matching Logic

  • matchRestRequest() - Traditional HTTP/REST API matching (existing)
  • matchGrpcRequest() - gRPC-specific URL patterns and body validation
  • matchGraphQLRequest() - GraphQL query syntax and field matching
  • Maintains full backward compatibility with existing functionality

Body Validation Enhancements

  • gRPC: JSON structure validation for protobuf data representation
  • GraphQL: Query syntax validation and specific field presence checking
  • REST: Preserves original OpenAPI request body validation logic

Testing & Quality

  • 97 total tests with 100% pass rate
  • 14 new tests covering gRPC and GraphQL functionality
  • Unit tests for all new parsing modules
  • Integration tests for mixed protocol scenarios
  • Comprehensive test fixtures for all supported formats
  • All existing functionality remains fully tested and working

Documentation Updates

  • Updated README with gRPC and GraphQL usage examples
  • Added protocol-specific configuration guidance
  • Enhanced CLI help text and argument descriptions
  • Updated package.json keywords to include new protocols

Backward Compatibility

This implementation maintains complete backward compatibility. All existing OpenAPI/Swagger, CSV, and Postman collection functionality continues to work exactly as before, with no breaking changes to the API or CLI interface.

The tool now provides unified API test coverage analysis across REST, gRPC, and GraphQL protocols, making it ideal for modern microservices architectures and multi-protocol API portfolios.

Files Changed

  • New modules: lib/grpc.js, lib/graphql.js
  • Enhanced: lib/match.js, lib/postman.js, lib/newman.js, cli.js
  • Documentation: readme.md, package.json
  • Tests: 3 new test files with fixtures for gRPC and GraphQL

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits September 16, 2025 17:40
Co-authored-by: dreamquality <130073078+dreamquality@users.noreply.github.com>
Co-authored-by: dreamquality <130073078+dreamquality@users.noreply.github.com>
…ation

Co-authored-by: dreamquality <130073078+dreamquality@users.noreply.github.com>
Copilot AI changed the title [WIP] support of gRPC / GraphQL Add comprehensive gRPC and GraphQL support to swagger-coverage-cli Sep 16, 2025
Copilot AI requested a review from dreamquality September 16, 2025 17:58
@dreamquality
Copy link
Owner

@copilot the new version is in the main branch, resolve conflicts and keep backward campapability with the main branch

@dreamquality
Copy link
Owner

@copilot the new version is in the main branch, resolve conflicts and keep backward campapability with the main branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants