from __future__ import annotations from fastapi.testclient import TestClient from pyMCPBroker.app import create_app from pyMCPBroker.broker import Broker from pyMCPBroker.config import load_config from test_broker_end_to_end import make_config def test_openapi_descriptions_and_examples(tmp_path): cfg = load_config(make_config(tmp_path)) broker = Broker(cfg) app = create_app(broker) with TestClient(app) as client: schema = client.get('/openapi.json').json() info_desc = schema['info']['description'] assert 'hides business tools' in info_desc assert 'meta_tree first' in info_desc tree_post = schema['paths']['/meta_tree']['post'] assert tree_post['summary'] == 'Discover tool paths' assert 'not exposed directly in OpenAPI' in tree_post['description'] tree_examples = tree_post['requestBody']['content']['application/json']['examples'] assert tree_examples['basic']['value']['path'] == '/' desc_post = schema['paths']['/meta_desc']['post'] assert desc_post['summary'] == 'Inspect a discovered path' assert 'exact argument schema' in desc_post['description'] call_post = schema['paths']['/meta_call']['post'] assert call_post['summary'] == 'Call a discovered tool path' assert 'hidden business tool' in call_post['description'] call_examples = call_post['requestBody']['content']['application/json']['examples'] assert call_examples['tool_call']['value']['path'] == '/repo/read/get_file'