Skip to content

Conversation

@abutbul
Copy link
Owner

@abutbul abutbul commented May 23, 2025

… improve parameter handling and sanitization

abutbul added 2 commits May 23, 2025 23:52
… improve parameter handling and sanitization
…nd schemas; update generator script execution steps in CI workflow
@abutbul abutbul marked this pull request as ready for review May 23, 2025 21:49
Copilot AI review requested due to automatic review settings May 23, 2025 21:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Enhance the OpenAPI parser to handle directories of JSON-specification files, improve parameter sanitization and code generation, and update tests and CI to validate both YAML and JSON inputs.

  • Extend parser (openapi_mcp_generator/parser.py) with directory traversal, JSON loading, merging logic, and identifier/string sanitization.
  • Update generator (openapi_mcp_generator/generators.py and generator.py) to use new sanitization functions and modular parsing, and refine parameter handling.
  • Revise tests and fixtures to cover multiple generated servers (YAML & JSON) and adjust GitHub Actions to run and verify both workflows.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_generated_server.py Add JSON fixture loader and dynamic import of multiple generated servers; missing imports introduced
tests/test_fixtures/*.json & README.md New fixture files for API info and schemas to validate merged JSON
openapi_mcp_generator/parser.py Support directory input, JSON spec parsing, merging, and sanitizers
openapi_mcp_generator/generators.py Integrate sanitize_identifier, escape_string_literal, and split required/optional params
openapi_mcp_generator/init.py Export new sanitizer functions
generator.py Fallback to modular parser for directories; fix $ref resolution call
.github/workflows/generate-and-test.yml Extend CI steps to test JSON-spec workflows alongside YAML
Comments suppressed due to low confidence (3)

tests/test_generated_server.py:6

  • The test uses os and importlib but neither is imported at the top of the file. Add import os and import importlib alongside the other imports.
import json

openapi_mcp_generator/generators.py:9

  • Optional is used later in this module but is not imported. Add Optional to the import from typing.
from typing import Dict, Any, List, Tuple

generator.py:54

  • USE_MODULAR is referenced here but is not defined in this scope, which will raise a NameError. Define it or guard its usage.
if USE_MODULAR:

🔄 Structure & Organization
Broader scope: Changed from "oneOf Test Case" to comprehensive "Test Suite" documentation
Logical flow: Organized content from overview → setup → detailed test cases → verification
Clear sections: Better categorization of different aspects being tested
📋 New Content Added
Test Coverage overview: Explains what the entire test suite validates
Input Formats section: Documents both YAML and JSON specification testing
Automated Test Details: Explains how the parametrized tests work
CI/CD Integration: Documents how tests integrate with GitHub Actions
Test output examples: Shows what successful test runs look like
🎯 oneOf Test Case Repositioned
Kept the oneOf content but placed it as "Test Case 1" in the detailed section
Added JSON specifications as "Test Case 2" for completeness
Maintained technical details about $ref resolution and oneOf handling
🚀 Enhanced Instructions
Dual generation commands: Shows how to generate both server types
Updated paths: Uses correct tests directory structure
Comprehensive testing: Includes both automated and manual verification steps
CI integration: Explains how the workflow generates and tests both cases
✅ What's Now Covered
Multiple input formats (YAML + JSON directories)
Adaptive testing approach (different tests for different server types)
Comprehensive verification (automated + manual + CI)
Clear examples (test output, commands, expected results)
Technical details (oneOf, $ref, parameter resolution)
The README now properly reflects the current sophisticated test setup that handles both generation sources and provides comprehensive validation of the generator's capabilities! 🎉
@abutbul abutbul merged commit 69f1d3f into main May 23, 2025
1 check passed
@abutbul abutbul deleted the feat-json-dir branch May 23, 2025 21:58
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.

1 participant