Skip to content

[BugFix] openbb-cli: Fix Detection of Sub-Routes of a Path - #7794

Merged
deeleeramone merged 3 commits into
developfrom
bugfix/cli-route-with-path
Oct 12, 2026
Merged

deeleeramone merged 3 commits into
developfrom
bugfix/cli-route-with-path

Conversation

@dlee-bq

@dlee-bq dlee-bq commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

This PR fixes router generation for paths that are both a command and a namespace (e.g. /alerts plus /alerts/active), and bundles several other codegen fixes for the CLI's OpenAPI→provider pipeline.

An API you can use to test: https://api.weather.gov

Main fix

Sub-route detection: A path that is simultaneously a command (/alerts) and a namespace (/alerts/active) no longer gets shadowed — it now mounts on its own router instead of the parent's (router_gen.py). Added collision/cycle guards so two routers can never overwrite each other or import themselves (package_gen.py).

Response schema / row detection

New _response_shape logic decides list vs. map vs. single-row responses purely from the schema (handles JSON-LD @context, multiple arrays, scalar-array-as-field vs. rows-as-array).
oneOf/anyOf object variants are now merged into one row type (union of fields/enums, required only if universal) instead of just taking the first variant.
unpack_response can now take schema-derived hints (rows_key, kind) so runtime unpacking matches the generated model.
Excludes 4xx/5xx and bare default error responses from being picked as the row schema; respects a configured Accept header when selecting the response media type.
Non-textual responses (binary/PDF/etc.) are base64-encoded into a value field instead of being force-decoded as text.

Query parameters

Query parameter attribute names are now consistently snake_cased with the original wire name kept as the alias (query_field_name).
List/array query params gained wire-format support (multi, csv, space, pipe) derived from OpenAPI style/explode/collectionFormat, including detecting delimited lists from free-text parameter descriptions.
Lat/lon-style path parameters are no longer coerced to integer.

Headers

Non-credential headers passed via --header are now baked into generated fetchers/post-commands as fixed headers and stripped from the command's visible parameters; credential headers are left for the existing credential mapping.

Docstrings

Refactored docstring_generator.py's type-string formatting into standalone, bracket-aware helpers, fixing a bug where only the last class in a union type had its module path stripped (e.g. list[openbb_x.A | openbb_x.B]).

Misc

URL-to-command naming now drops path segments made only of placeholders (e.g. {x},{y}).
Includes corresponding test coverage across fetcher_gen, pydantic_gen, router_gen, package_gen, openapi_schema, spec, and docstring_generator.

@dlee-bq dlee-bq added bug Bugs and bug fixes cli OpenBB Platform CLI labels Oct 11, 2026
@dlee-bq
dlee-bq force-pushed the bugfix/cli-route-with-path branch from c7a4dce to 833860f Compare October 11, 2026 20:16
@CLAassistant

CLAassistant commented Oct 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@deeleeramone
deeleeramone added this pull request to the merge queue Oct 12, 2026
Merged via the queue into develop with commit 7c9d422 Oct 12, 2026
51 checks passed
@deeleeramone
deeleeramone deleted the bugfix/cli-route-with-path branch October 12, 2026 21:19
@freedom8268

freedom8268 commented Oct 13, 2026 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bugs and bug fixes cli OpenBB Platform CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants