11from __future__ import annotations
22
3+ from fastapi import FastAPI
4+ from fastapi .testclient import TestClient
5+
36from agent_control_server import main as main_module
47from agent_control_server .config import observability_settings , settings
58from agent_control_server .main import lifespan
811 register_control_event_sink_factory ,
912 unregister_control_event_sink_factory ,
1013)
11- from fastapi import FastAPI
12- from fastapi .testclient import TestClient
1314
1415
1516def test_lifespan_initializes_observability_when_enabled (monkeypatch ) -> None :
@@ -156,11 +157,22 @@ def test_lifespan_skips_observability_when_disabled(monkeypatch) -> None:
156157 assert not hasattr (app .state , "event_ingestor" )
157158
158159
159- def test_custom_openapi_replaces_jsonvalue (monkeypatch ) -> None :
160- # Given: a custom openapi generator that includes JSONValue
160+ def test_custom_openapi_replaces_jsonvalue_variants (monkeypatch ) -> None :
161+ # Given: a custom openapi generator that includes Pydantic JSONValue schemas
162+ json_value_schema_names = (
163+ "JSONValue" ,
164+ "JSONValue-Input" ,
165+ "JSONValue-Output" ,
166+ "JsonValue" ,
167+ "JsonValue-Input" ,
168+ "JsonValue-Output" ,
169+ )
170+
161171 def fake_get_openapi (* , title , version , description , routes ):
162172 return {
163- "components" : {"schemas" : {"JSONValue" : {"type" : "object" }}},
173+ "components" : {
174+ "schemas" : {name : {"type" : "object" } for name in json_value_schema_names }
175+ },
164176 "info" : {"title" : title , "version" : version , "description" : description },
165177 "paths" : {},
166178 }
@@ -171,8 +183,10 @@ def fake_get_openapi(*, title, version, description, routes):
171183 # When: generating openapi
172184 schema = main_module .app .openapi ()
173185
174- # Then: JSONValue is replaced with safe description
175- assert schema ["components" ]["schemas" ]["JSONValue" ]["description" ] == "Any JSON value"
186+ # Then: JSONValue schemas are replaced with a non-recursive schema
187+ schemas = schema ["components" ]["schemas" ]
188+ for schema_name in json_value_schema_names :
189+ assert schemas [schema_name ] == {"description" : "Any JSON value" }
176190
177191
178192def test_custom_openapi_is_cached (monkeypatch ) -> None :
0 commit comments