fix(schema): remove AddNullable from draft2020_12 settings#664
fix(schema): remove AddNullable from draft2020_12 settings#664alexhancock merged 3 commits intomodelcontextprotocol:mainfrom
Conversation
|
@mwotton Thanks for the fix. |
|
Added a second follow-up commit (
This was not visible in the original CI failure because |
|
Hey @mwotton, thanks for the fix! The code change looks good. The CI failures aren't related to your changes. All five failing checks hit the same compilation error: This happened because your branch is based on an older main that still used reqwest 0.12, which depends on native-tls. Since then, PR #669 upgraded to reqwest 0.13, which uses rustls by default and doesn't pull in native-tls, so the main CI is green now. To fix the CI, please rebase your branch onto the latest main. I think that should resolve all five failures. The code changes themselves look correct. |
The `nullable` keyword is an OpenAPI 3.0 extension, not part of
JSON Schema 2020-12. Using AddNullable with draft2020_12 settings
causes validation failures with strict JSON Schema validators.
JSON Schema 2020-12 represents nullable types using:
- {"type": ["string", "null"]} (type array with null)
- {"anyOf": [{"type": "string"}, {"type": "null"}]}
Fixes modelcontextprotocol#663
70011f9 to
84ac0ed
Compare
Problem
The
schema_for_type()function usesAddNullable::default()as a transform when generating JSON Schema 2020-12 schemas. However, thenullablekeyword is an OpenAPI 3.0 extension, not part of JSON Schema 2020-12. This causes validation failures with strict JSON Schema validators.Solution
Remove the
AddNullabletransform from the draft2020_12 settings. JSON Schema 2020-12 represents nullable types using:{"type": ["string", "null"]}(type array with null){"anyOf": [{"type": "string"}, {"type": "null"}]}Before
An optional string field produced:
{ "nullable": true, "type": "string" }After
An optional string field produces:
{ "type": ["string", "null"] }Fixes #663