fix: map JSON Schema enums to EnumSchema - #39
Open
dimabullet wants to merge 1 commit into
Open
Conversation
- resolve the enum keyword before falling back to type based matching - keep enum options nested in array items - cover string enums and array item enums with tests
dimabullet
force-pushed
the
fix/enum-schema-from-json-schema
branch
from
July 29, 2026 11:45
884d93d to
41120c0
Compare
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.
Fixes #38.
getSchemeParameter()resolved a property by matching ontypealone, so a standard JSON Schema enum ({"type": "string", "enum": [...]}) became a plainStringSchemaand the allowed values never reached the model. The existing'enum'branch expects{"type": "enum", "options": [...]}, which is not JSON Schema and which no MCP server emits, so it was unreachable.This resolves the
enumkeyword before the type based matching:Because the method recurses through
$thisforitems, enums nested inside arrays are covered as well, without extra handling.isEnumOptions()guards the case Prism cannot type:EnumSchemaderives its own type from the options and only handles strings and numbers, so anything else falls through to the existing resolution rather than blowing up.The old
'enum'branch is left untouched, so nothing that relied on it changes.Tests
Added an
enum_toolfixture toRelayFakeand two cases toRelayTest: a string enum and an enum nested in array items. Full suite passes (90 tests), Pint and PHPStan are clean.