Repository navigation
feat(generators)!: support single-model endpoints and fix financial-reports-json shape - #375
Merged
Merged
Conversation
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
enabled auto-merge (rebase)
September 30, 2026 08:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
financial-reports-jsonendpoint 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:
single = trueendpoint option across the registry, schema, and return classifier, introducingReturns::Singlealongside the existing binary and dynamic modes, with validation that the flag matches a client method returning one typed model rather than rows.Model::frominstead of collecting aVec).financial_reports_jsonto return oneFinancialReportJsonacross libfmp, fmp-py, and sdk/go, updating the generated stub, the registry entry, and the GoJSONmethod.BREAKING CHANGE: financial_reports_json now returns a single FinancialReportJson instead of a list; drop the [0] / iteration.
Closes #374
close #374