MCP: OpenApiSchemaConverter drops types from OpenAPI 3.1 type arrays

Aperta
#3,427 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mariodavid ci sta già lavorando.

Dal 7/11/2026.

  • #3428 di @mariodavid — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
java, openapi, spring
Ambito
api

Direzione di ricerca

Start with OpenApiSchemaConverter.buildInputSchema(...) in the springdoc-openapi-starter-common-mcp module and inspect how it handles Schema#getTypes(). Check the existing converter tests for multi-type OpenAPI 3.1 schemas. Done means emitted JSON Schema preserves all declared types while single-type schemas and OpenAPI 3.0 nullable: true still work; linked pull request #3428 is already open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

OpenApiSchemaConverter in springdoc-openapi-starter-common-mcp converts a multi-type OpenAPI 3.1 schema into a single JSON Schema type. It reads only one entry from Schema#getTypes(). This narrows the published MCP tool input schema, so a client can reject a value that the REST API contract permits.

To Reproduce

  • Springdoc: 3.2.0, module springdoc-openapi-starter-common-mcp
  • Convert an operation with this OpenAPI 3.1 request body using OpenApiSchemaConverter.buildInputSchema(...):
requestBody:
  content:
    application/json:
      schema:
        type: object
        properties:
          content:
            type: [string, 'null']

The emitted body.properties.content.type is a string containing only one declared type. If the converter retains "string", a tool call with content: null fails input validation.

Expected behavior

The emitted property schema retains the complete type array:

{ "type": ["string", "null"] }

This also applies to type arrays without null, for example ["integer", "string"]. Existing single-type schemas and OpenAPI 3.0 nullable: true should continue to work.

Lingua principale
Java
Stelle
3.7k
Fork
605
Merge medio
2g 11h
PR unite (30g)
17

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di springdoc/springdoc-openapi

Tutte le issue di springdoc/springdoc-openapi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.