Skip to content

Generate typed response types for all API groups - #505

Merged
reta merged 2 commits into
opensearch-project:mainfrom
krocky-cooky:feat/typed-responses-all-groups
Nov 5, 2026
Merged

reta merged 2 commits into
opensearch-project:mainfrom
krocky-cooky:feat/typed-responses-all-groups

Conversation

@krocky-cooky

Copy link
Copy Markdown
Contributor

Description

Follow-up to #494, which generated typed response types for search, index, bulk and get only. This PR applies the same generator to every API group of the specification. Nothing about how the types are generated changes; the diff is the selection, the declarations it requires, and two issues that only show up once namespace APIs are typed.

Coverage

  • 456 operation groups are now typed, including the namespaces: client.typed().cluster().health(..), client.typed().indices().create(..), client.typed().cat().indices(..), and so on.
  • The 25 others have no response type, and the generator logs why: 9 are HEAD-only, 13 have no JSON body for 200, and 3 declare no success response.

Changes from #494

  • TYPED_OPERATION_GROUPS is removed. The new read_all_response_models is used both to generate the types and to record each endpoint's typed response, so the two can't disagree.
  • The raw-field declarations (raw_fields/declared.rs) grow from 23 to 167. The 144 new ones reuse the reasons reviewed on the earlier full-API branch; each had the same cause.
  • Typed builders of deprecated APIs (e.g. ml.load_model) allow the deprecated generic builder they wrap, as the generic code already does. Users still get the deprecation warning; the library build no longer does (clippy stays at 42, as on main).
  • The yaml typed check now skips requests the typed client can't send, using the generator's list of omitted options: filter_path, and cat/list requests without format=json (e.g. cat.count answering 2 in plain text).

Verification against a real cluster (OpenSearch 3.9.0)

  • The yaml tests now run 3,721 typed checks across 100 response types. The test results are the same as on main (1,333 passed / 40 failed, the same 40).
  • The typed check reports 101 warnings. Apart from the 16 already known (profile fetch, float rounding), they are spec gaps, not generator issues

Issues Resolved

Part of #481, part of #488

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Generate response types and typed builders for every operation group of
the specification that declares a JSON success response, instead of only
search, index, bulk and get: 456 groups are typed, and the 25 others
(HEAD-only, or without a JSON body) are reported with the reason.

The `TYPED_OPERATION_GROUPS` selection is replaced by
`read_all_response_models`, used both to generate the types and to
record each endpoint's typed response. The raw-field declarations grow
from 23 to 167; the 144 new ones reuse the reasons reviewed on the
earlier full-API branch, with the same causes.

Typed namespace clients (e.g. `client.typed().cluster()`) now carry
the unknown-fields setting of the typed client, so strict mode applies
to namespace APIs too. Typed builders of deprecated APIs allow the use
of their deprecated generic builder, as the generic code does.

The yaml typed check now skips the requests the typed client cannot
send, using the generator's list of omitted options: `filter_path`, and
cat/list requests without `format=json`.

Signed-off-by: Takuo Kuroki <kurotaku9679.sub@gmail.com>
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.15%. Comparing base (a1deb55) to head (a782db2).

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #505       +/-   ##
===========================================
- Coverage   56.12%   44.15%   -11.97%     
===========================================
  Files         523      567       +44     
  Lines      119123   168923    +49800     
===========================================
+ Hits        66859    74595     +7736     
- Misses      52264    94328    +42064     
Flag Coverage Δ
integration 42.40% <ø> (-11.58%) ⬇️
unit 7.56% <ø> (-4.92%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reta

reta commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks @krocky-cooky , went through all (nonetheless it is primarily generated), LGTM except this comment #505 (comment), thank you

The typed client conforms to the specification: it parses the fields the
response types define and ignores the others, as the other OpenSearch
clients do. The opt-in strict mode, which turned those keys into an
error, was a maintainer's tool: it decoded every body twice, made every
typed builder and namespace client carry a setting, and added an error
kind to the public API, while a caller could not read the reported
fields through the typed client anyway.

Remove `TypedOpenSearch::ignore_unknown_fields`, `Error::unknown_fields`
and the detection behind them, and the `Serialize` bound of
`Response::typed`. Gaps in the specification are still reported by the
yaml typed check of the test runner, and an opt-in check can be added
back later without breaking anyone.

Signed-off-by: Takuo Kuroki <kurotaku9679.sub@gmail.com>
@reta
reta merged commit bbff7d2 into opensearch-project:main Nov 5, 2026
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants