Skip to content

NO-ISSUE: Pin behavioral contract of generated clients ahead of openapi-generator 7.22.0#835

Closed
mokuzon wants to merge 2 commits into
line:masterfrom
mokuzon:users/mokuson/NO-ISSUE/add-tests-for-generated-clients
Closed

NO-ISSUE: Pin behavioral contract of generated clients ahead of openapi-generator 7.22.0#835
mokuzon wants to merge 2 commits into
line:masterfrom
mokuzon:users/mokuson/NO-ISSUE/add-tests-for-generated-clients

Conversation

@mokuzon
Copy link
Copy Markdown

@mokuzon mokuzon commented Jun 3, 2026

Background

When openapi-generator is bumped (7.11.0 -> 7.22.0) and the clients are regenerated, the generated code under src/clients/*/lib/ and src/webhook/lib/ changes. This PR adds tests that pin the observable behavior of the parts that get rewritten, so the regeneration can be reviewed/merged with confidence (same spirit as #810 / #823, which are prepared separately).

I verified the exact diff by actually regenerating with 7.22.0 locally. The behaviorally-relevant changes are:

  • Api classes: per-operation response parsing is extracted into a shared handleResponseWithDataType() helper; the catch (ApiException) 200 branch changes break; -> throw $e;.
  • Api classes: createHttpClientOption() gains mTLS support (RequestOptions::CERT / SSL_KEY).
  • Configuration: new certFile / keyFile properties + getters/setters (mTLS).
  • FormDataProcessor: new generated class (used by the form-based ChannelAccessToken endpoints).
  • Model / ObjectSerializer: diff is comment-only (Generator version / PHP version doc strings) — not executable.

What this PR covers (pre-mergeable on the current code)

These tests pass on both the current generated code (7.11.0) and the regenerated code (7.22.0), so they can land ahead of the bump and then guard it:

  • InsightApi, LiffApi, ManageAudienceApi: request shape (method / path / query keys / JSON body keys) + response deserialization.
  • Response-handling invariant: a 2xx response with an undecodable body still raises ApiException (this is exactly the code path the handleResponseWithDataType() extraction refactors).
  • ObjectSerializer: unit tests for the shared serialization helper (regenerated, behavior-identical).

Honest scope note — this does NOT make the regeneration diff 100% covered

Two parts of the diff cannot be covered by an advance, test-only PR:

  1. mTLS (RequestOptions::CERT / SSL_KEY, Configuration::set/getCertFile/KeyFile) — this is new functionality that does not exist on the current code, so a test referencing it cannot compile/run until the regeneration lands. It must be tested together with the regenerated code (i.e. in the generator-bump PR).
  2. responseWithinRangeCode() — generated by 7.22.0 but never called (dead code), so it is unreachable by any test.

Measured on the regenerated 7.22.0 code: handleResponseWithDataType() is covered (happy path + JSON-error path); the mTLS lines and responseWithinRangeCode() are not.

Test plan

  • composer test passes on current code (63 tests)
  • composer test passes on locally-regenerated 7.22.0 code (63 tests)
  • composer cs / composer copyright pass
  • mTLS tests to be added in the generator-bump PR (depends on regenerated code)

mokuzon added 2 commits June 3, 2026 12:08
Add tests that pin the request shape and serialization behavior of the
OpenAPI-generated clients, so that a future openapi-generator bump that
rewrites this code (e.g. the form-param key regression in line#810/line#823) is
caught before release.

- InsightApi: method, path and query keys for all 5 endpoints
- LiffApi: method, path-parameter substitution and JSON body keys
- ManageAudienceApi: method, path, query and JSON body keys
- ObjectSerializer: unit tests for the shared serialization helper
  (sanitizeForSerialization, toQueryValue, buildQuery, serializeCollection,
  deserialize, sanitizeFilename, toPathValue, etc.)
The 7.22.0 regeneration extracts the per-operation response parsing into a
shared handleResponseWithDataType() helper. Add tests that pin the invariant
that a 2xx response with an undecodable body still surfaces as an ApiException,
so the refactor is verified to preserve behavior. Verified to pass on both the
current generated code (7.11.0) and the regenerated code (7.22.0).
@mokuzon mokuzon changed the title NO-ISSUE: Add characterization tests for generated API clients NO-ISSUE: Pin behavioral contract of generated clients ahead of openapi-generator 7.22.0 Jun 3, 2026
@mokuzon mokuzon closed this Jun 3, 2026
@mokuzon mokuzon deleted the users/mokuson/NO-ISSUE/add-tests-for-generated-clients branch June 3, 2026 03:31
@mokuzon
Copy link
Copy Markdown
Author

mokuzon commented Jun 3, 2026

Consolidated into #823 (which contains the openapi-generator 7.22.0 regeneration). Tests now live on the #823 branch so they run against the regenerated code.

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.

1 participant