Skip to content

Preserve OpenAPI 3.1 type arrays in MCP input schemas - #3428

Open
mariodavid wants to merge 1 commit into
springdoc:mainfrom
mariodavid:fix/mcp-schema-converter-type-arrays
Open

mariodavid wants to merge 1 commit into
springdoc:mainfrom
mariodavid:fix/mcp-schema-converter-type-arrays

Conversation

@mariodavid

Copy link
Copy Markdown

Problem

The MCP schema converter reads a single entry from OpenAPI 3.1's Schema#getTypes(). A request property declared as ["string", "null"] loses one of its allowed types in the generated MCP inputSchema.

Fix

Emit a JSON Schema type array when the OpenAPI schema has multiple types. The existing single-type and OpenAPI 3.0 nullable: true paths still apply.

Tests

  • OpenApiSchemaConverterTest#testOpenApi31TypeArraysInRequestBody parses a request body and verifies both ["string", "null"] and ["integer", "string"]. It fails on the old converter.
  • ./mvnw -pl springdoc-openapi-starter-common-mcp -am test passes, including all 35 MCP module tests.
  • A local Notes API E2E scenario verifies the generated OpenAPI contract and the types advertised over MCP, sends explicit content: null, and reads the saved note back.

Fixes #3427.

This branch has not been deployed

No deployments
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.

MCP: OpenApiSchemaConverter drops types from OpenAPI 3.1 type arrays

1 participant