Skip to content

Commit 0fcbf99

Browse files
committed
Fix News schema validation for searchNews
1 parent 63d3436 commit 0fcbf99

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

server.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def should_exclude_operation(path: str, operation: dict) -> bool:
235235

236236
def filter_openapi_spec(spec: dict) -> dict:
237237
filtered = copy.deepcopy(spec)
238+
normalize_known_spec_mismatches(filtered)
238239
paths = filtered.get("paths", {})
239240
new_paths = {}
240241
allow_tags = {tag.lower() for tag in parse_csv_env("X_API_TOOL_TAGS")}
@@ -271,6 +272,25 @@ def filter_openapi_spec(spec: dict) -> dict:
271272
return filtered
272273

273274

275+
def normalize_known_spec_mismatches(spec: dict) -> None:
276+
schemas = spec.get("components", {}).get("schemas", {})
277+
news = schemas.get("News")
278+
if not isinstance(news, dict):
279+
return
280+
281+
required = news.get("required")
282+
if isinstance(required, list) and "rest_id" in required:
283+
required = [field for field in required if field != "rest_id"]
284+
if required:
285+
news["required"] = required
286+
else:
287+
news.pop("required", None)
288+
289+
properties = news.get("properties")
290+
if isinstance(properties, dict) and "id" not in properties and "rest_id" in properties:
291+
properties["id"] = copy.deepcopy(properties["rest_id"])
292+
293+
274294
def print_tool_list(spec: dict) -> None:
275295
tools: list[str] = []
276296
for path, item in spec.get("paths", {}).items():

0 commit comments

Comments
 (0)