Skip to content

feat(generators)!: support single-model endpoints and fix financial-reports-json shape - #375

Merged
benbenbang merged 5 commits into
mainfrom
fix/financial-reports-json
Sep 30, 2026
Merged

benbenbang merged 5 commits into
mainfrom
fix/financial-reports-json

Conversation

@benbenbang

@benbenbang benbenbang commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

The financial-reports-json endpoint actually returns a single bare object, but the generators and client bindings only knew how to produce lists of rows, so the response was mis-shaped and silently took the first row of an array. This adds a first-class single-model return mode to the generators and applies it to correct the affected endpoint end to end.

What changed:

  • Add a single = true endpoint option across the registry, schema, and return classifier, introducing Returns::Single alongside the existing binary and dynamic modes, with validation that the flag matches a client method returning one typed model rather than rows.
  • Render single-model returns in Go (bare model with a zero-value fallback) and in the Python namespace layer (mapping one row via Model::from instead of collecting a Vec).
  • Correct financial_reports_json to return one FinancialReportJson across libfmp, fmp-py, and sdk/go, updating the generated stub, the registry entry, and the Go JSON method.
  • Replace the mis-shaped test fixture with a trimmed live AAPL 2023 Q1 capture and update Rust, Go, and Python tests to decode a single object and reject arrays, adding an object-fixture parity helper and single-flag validation coverage.
  • Refresh module docs, README, and endpoint-coverage documentation to describe the single-model mode and the reclassified endpoint.

BREAKING CHANGE: financial_reports_json now returns a single FinancialReportJson instead of a list; drop the [0] / iteration.

Closes #374

close #374

Add a `single = true` endpoint option that returns one typed model instead
of a `Vec` of rows, alongside the existing `binary` and `dynamic` modes.

**Registry and schema:**
* Added the `single` flag to `Endpoint` and the schema entry, defaulting to
  false and deserialized from the registry TOML.
* Introduced `Returns::Single` in the return classifier so `Result<R>` is
  recognized as one typed object distinct from `Vec<R>` and `BinaryResponse`.
* Validated exclusivity: `single = true` needs a typed `response` model and
  must match a `Client` method that returns one model rather than rows.

**Go and namespace generation:**
* Added `ResponseKind::Single` and rendered it as a bare model return with a
  `Model{}` zero value instead of a slice and `nil`.
* Emitted a single-model Python method that maps one row via `Model::from`
  rather than collecting a `Vec`.

**Docs and tests:**
* Documented the `single = true` mode in the module comments and README.
* Added coverage for single-model rendering and the schema exclusivity error.
The `financial-reports-json` endpoint returns a single bare object, not an
array. Correct the shape across libfmp, fmp-py, and sdk/go so the endpoint
decodes into one `FinancialReportJson` value and rejects arrays.

* libfmp: change `financial_reports_json` to yield `FinancialReportJson`
  instead of `Vec<FinancialReportJson>`, and update the registry entry with
  `single = true`.
* fmp-py: return one `FinancialReportJson` from `json` rather than a list.
* sdk/go: `StatementsReportsNamespace.JSON` now returns `FinancialReportJSON`,
  with a new `assertObjectFixtureParity` helper that proves a bare-object
  fixture round-trips and ignores unknown members.
* Replace the mis-shaped documented fixture with a trimmed live AAPL 2023 Q1
  capture (three headers plus three sections) that proves the object shape,
  and update the Rust and Go tests to decode one object and reject arrays.

BREAKING CHANGE: financial_reports_json now returns a single
FinancialReportJson instead of a list; drop the [0] / iteration.
Update the generated type stub for the dynamic JSON financial report to
return a single `FinancialReportJson` object instead of a bare array,
along with the matching docstring.
Update the `reports.json` test to assert the endpoint returns one typed
`FinancialReportJson` object rather than a list, checking symbol, period,
year, and section contents. Add a test confirming that a bare array body
is rejected with `FmpDecodeError` instead of silently taking the first
row.

Refresh the endpoint coverage docs and generator note to describe
`statements.reports.json` as returning one typed object (not a list)
whose `sections` are dynamic JSON.

close #374
Add a `single_mismatch` fixture and registry test that assert the
`single` flag must match the client return shape, reporting errors when
a rows-returning method sets `single = true` and when a single-model
method omits it.

Also extend the scan test to verify that only `financial_reports_json`
is classified as a `Single` return among the recovered methods.
@benbenbang
benbenbang enabled auto-merge (rebase) September 30, 2026 08:11
@github-actions github-actions Bot added documentation Improvements or additions to documentation enhancement New feature or request workflows ci/cd, configs relative build labels Sep 30, 2026
@benbenbang
benbenbang merged commit 4367c4c into main Sep 30, 2026
9 of 16 checks passed
@benbenbang
benbenbang deleted the fix/financial-reports-json branch September 30, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build documentation Improvements or additions to documentation enhancement New feature or request workflows ci/cd, configs relative

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix!: financial-reports-json returns one object, SDK decodes a list

1 participant