Skip to content

feat: improve schema simplification with composition support and cycle detection - #303

Open
VarunAthreya wants to merge 2 commits into
mainfrom
feat/schema-composition-support
Open

VarunAthreya wants to merge 2 commits into
mainfrom
feat/schema-composition-support

Conversation

@VarunAthreya

@VarunAthreya VarunAthreya commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Refactor schema simplification to handle allOf, anyOf, and oneOf composition keywords properly
  • Add cycle detection for recursive/circular schema types to prevent infinite expansion
  • Implement node counting with a configurable limit (10,000) to bound schema output size
  • Improve type inference with fillImpliedTypes to infer missing type declarations
  • Add comprehensive test coverage for complex schema scenarios
  • Fixes: deck file openapi2mcp command not handling $ref and allOf / anyOf correctly deck#2200

Changes

Code Changes

  • openapi2mcp.go:
    • Replace simple simplifySchema() function with schemaSimplifier struct for stateful schema traversal
    • Track in-progress references to detect cycles and log them at debug level
    • Implement maxSchemaNodes limit to prevent exponential expansion in dense schema graphs
    • Add inlineSchema() as the public API with logging for truncated schemas
    • Improve handling of composition keywords per OpenAPI spec semantics

Tests

  • Add 4 new test fixtures covering complex schema scenarios:
    • 10-schema-allof.yaml: Test allOf member merging
    • 11-schema-oneof-anyof.yaml: Test anyOf/oneOf branch preservation
    • 12-schema-circular.yaml: Test recursive/circular schema truncation
    • 13-schema-params.yaml: Test parameters with complex composed schemas
  • Refactor common test pattern into assertFixtureConversions helper

Documentation

  • Expand README.md with detailed explanation of:
    • Composition keyword handling (allOf, anyOf, oneOf)
    • Recursive schema truncation and node limits
    • Type inference behavior for simplified schemas

- Introduced new test files for schema parameters to validate conversion.
- Added YAML and JSON representations for the Parameter Composition API.
- Enhanced the schema simplification logic to handle complex schemas with allOf, anyOf, and oneOf constructs.
- Updated the OpenAPI to MCP conversion logic to ensure self-contained schemas without external references.
- Implemented tests to verify schema composition edge cases and ensure no schema pointers are leaked in the output.
@codecov-commenter

codecov-commenter commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.88372% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.65%. Comparing base (afc605e) to head (cabd0c2).

Files with missing lines Patch % Lines
openapi2mcp/openapi2mcp.go 94.88% 6 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #303      +/-   ##
==========================================
+ Coverage   58.82%   60.65%   +1.82%     
==========================================
  Files          36       36              
  Lines        3869     4059     +190     
==========================================
+ Hits         2276     2462     +186     
- Misses       1380     1382       +2     
- Partials      213      215       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

deck file openapi2mcp command not handling $ref and allOf / anyOf correctly

2 participants