mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
[V5] openbb-cli: Modular OpenAPI Refs (#7589)
* follow up to #7585 * add another codegen test
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user