Enhance OpenAPI parser to support directory input and JSON API files;…#10
Merged
Enhance OpenAPI parser to support directory input and JSON API files;…#10
Conversation
… improve parameter handling and sanitization
…nd schemas; update generator script execution steps in CI workflow
Contributor
There was a problem hiding this comment.
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.pyandgenerator.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 osandimport importlibalongside the other imports.
import json
openapi_mcp_generator/generators.py:9
Optionalis used later in this module but is not imported. AddOptionalto the import fromtyping.
from typing import Dict, Any, List, Tuple
generator.py:54
USE_MODULARis 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! 🎉
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… improve parameter handling and sanitization