Skip to content

Conversation

jlowin
Copy link
Owner

@jlowin jlowin commented Sep 15, 2025

Resolves issue #1815 where FastAPI endpoints with list[T] parameters generated empty input schemas, causing tools to be unusable.

The root cause was that the schema combination logic didn't handle direct array schemas generated by FastAPI. Added support for these schemas with comprehensive test coverage.

🤖 Generated with Claude Code

Resolves issue where FastAPI endpoints with list[T] parameters (e.g., `values: list[str]`)
generated empty input schemas, causing tools to be unusable.

The root cause was that FastAPI generates direct array schemas like:
```json
{
  "type": "array",
  "items": {"type": "string"},
  "title": "Values"
}
```

But the schema combination logic only handled:
1. $ref schemas → single "body" property
2. Object schemas with properties → iterate properties

Added third case to handle direct array/primitive schemas by using the schema title
as the parameter name (e.g., "Values" → "values"), with fallback to generic names.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Jeremiah Lowin <[email protected]>
@marvin-context-protocol marvin-context-protocol bot added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. server Related to FastMCP server implementation or server-side functionality. openapi Related to OpenAPI integration, parsing, or code generation features. labels Sep 15, 2025
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +372 to +375
properties[param_name] = body_schema
if route.request_body.required:
required.append(param_name)
parameter_map[param_name] = {"location": "body", "openapi_name": param_name}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Prevent direct array body names from clobbering other parameters

The new branch that generates a parameter name for direct array/primitive request bodies writes the name straight into properties and parameter_map without checking for collisions with existing query/path/header parameters. When a route already has a parameter called the same as the array title (e.g. a query parameter values and a body schema titled Values), this code replaces the earlier entry so the combined schema loses the query parameter and parameter_map no longer contains it, meaning the request director cannot send that query parameter at all. The previous collision handling covers only object body properties, so this branch needs similar suffixing or uniqueness logic.

Useful? React with 👍 / 👎.

@jlowin
Copy link
Owner Author

jlowin commented Sep 16, 2025

@silb-saxobank this appears to resolve the example you provided in #1815

@silb-saxobank
Copy link

Tried this change locally and it does indeed seem to solve my issue. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. openapi Related to OpenAPI integration, parsing, or code generation features. server Related to FastMCP server implementation or server-side functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants