Skip to content

Generated docs should fail when response annotations cannot be resolved #157

Description

@DevilsAutumn

What happened?

Generated docs can silently accept a broken response annotation.

If a route has a return annotation like MissingOut, /openapi.json still works and shows a generic object response schema. The MCP docs page also renders an output schema instead of failing.

That means a stale or misspelled response model can look fine in generated docs even though the annotation cannot actually be resolved.

Expected behavior

Generated docs should fail clearly when a response annotation cannot be resolved.

Valid postponed annotations should keep working, but a missing response model should not turn into a generic object schema.

Reproduction

from __future__ import annotations

import asyncio
import json

from quater import Quater, Request


async def main():
    app = Quater()

    @app.get("/bad", tool=True, description="Bad response model repro")
    async def bad() -> MissingOut:
        return {"ok": True}

    openapi_response = await app.handle(Request(method="GET", path="/openapi.json"))
    openapi = json.loads(openapi_response.body)
    schema = openapi["paths"]["/bad"]["get"]["responses"]["200"]["content"]["application/json"]["schema"]

    print("openapi_status", openapi_response.status_code)
    print("openapi_schema", schema)

    mcp_response = await app.handle(Request(method="GET", path="/mcp/docs"))
    html = mcp_response.body.decode("utf-8")

    print("mcp_docs_status", mcp_response.status_code)
    print("mcp_has_output_schema", "Output Schema" in html)
    print("mcp_has_generic_object_schema", '"type": "object"' in html or ""type": "object"" in html)


asyncio.run(main())

Current output:

openapi_status 200
openapi_schema {'type': 'object'}
mcp_docs_status 200
mcp_has_output_schema True
mcp_has_generic_object_schema True

Environment

  • Quater version: main after 0.2.0
  • Python version: 3.11.12
  • OS: macOS 26.3

Extra context

This is different from #141. That issue is about manual reference pages. This one is about runtime generated OpenAPI and MCP docs.

Working on this?

Please wait until a maintainer marks the issue accepted. After that, comment before starting and make sure nobody else is assigned or already working on it.

Metadata

Metadata

Assignees

Labels

acceptedMaintainer accepted this issue for contributionbugSomething isn't workingdocumentationImprovements or additions to documentation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions