fix(elicitation): preserve enumNames through ElicitationSchema serde round-trip (#905)

* fix(elicitation): preserve enumNames through ElicitationSchema serde round-trip

UntitledSingleSelectEnumSchema lacked deny_unknown_fields, so a legacy
enum payload containing enumNames was silently matched by that variant
(ignoring the field) rather than falling through to LegacyEnumSchema.
The enumNames array was lost on re-serialization.

Add deny_unknown_fields to UntitledSingleSelectEnumSchema so that any
unknown field (including enumNames) causes serde to try the next
untagged variant, reaching LegacyEnumSchema correctly.

Also add skip_serializing_if = "Option::is_none" to
LegacyEnumSchema::enum_names so that an untitled legacy enum without
enumNames does not serialize "enumNames": null.

Fixes #903

* test(elicitation): regenerate server schema snapshot for deny_unknown_fields

deny_unknown_fields on UntitledSingleSelectEnumSchema makes schemars
emit additionalProperties: false for that definition. Regenerate the
golden schema fixtures to match (UPDATE_SCHEMA=1 cargo test -p rmcp
--test test_message_schema --all-features).
This commit is contained in:
Abdoul 2026-06-20 13:55:51 -07:00 • committed by GitHub
commit 4fd4986b62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 1 deletions

View file

@ -3642,6 +3642,7 @@
"$ref": "#/definitions/StringTypeConst"
}
},
"additionalProperties": false,
"required": [
"type",
"enum"

View file

@ -3642,6 +3642,7 @@
"$ref": "#/definitions/StringTypeConst"
}
},
"additionalProperties": false,
"required": [
"type",
"enum"