[V5] openbb-cli: Modular OpenAPI Refs (#7589)

* follow up to #7585

* add another codegen test
This commit is contained in:
Danglewood
2026-07-14 12:49:37 -07:00
committed by GitHub
parent 92744a33cd
commit 5b20e24352
13 changed files with 750 additions and 46 deletions

View File

@@ -455,6 +455,14 @@ def _generate_spec(
else:
source_url = server_url.rstrip("/") + "/openapi.json"
spec_doc = build_spec_document(openapi, base_url=server_url, source_url=source_url)
if not spec_doc["commands"]:
sys.stderr.write(
f"generated 0 commands from {source_url} — the document exposes no "
"GET/POST operations OpenBB can map. Multi-file specs that split "
"paths across documents with external $refs must be bundled into "
"a single file first.\n"
)
return 2
write_spec(output_path, spec_doc)
sys.stdout.write(f"wrote {len(spec_doc['commands'])} commands to {output_path}\n")
return 0
@@ -539,6 +547,13 @@ def _generate_extension(
spec_doc = load_spec(spec_path)
original_count = len(spec_doc.get("commands") or {})
if original_count == 0:
sys.stderr.write(
f"--generate-extension: spec at {spec_path} contains 0 commands — "
"nothing to generate. Regenerate the spec against a source that "
"exposes GET/POST operations.\n"
)
return 2
spec_doc = _filter_spec_commands(spec_doc, include=include, exclude=exclude)
filtered_count = len(spec_doc.get("commands") or {})
if (include or exclude) and filtered_count == 0: