NO-ISSUE: Pin behavioral contract of generated clients ahead of openapi-generator 7.22.0#835
Closed
mokuzon wants to merge 2 commits into
Closed
Conversation
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).
Author
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.
Background
When
openapi-generatoris bumped (7.11.0 -> 7.22.0) and the clients are regenerated, the generated code undersrc/clients/*/lib/andsrc/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:
handleResponseWithDataType()helper; thecatch (ApiException)200 branch changesbreak;->throw $e;.createHttpClientOption()gains mTLS support (RequestOptions::CERT/SSL_KEY).certFile/keyFileproperties + getters/setters (mTLS).FormDataProcessor: new generated class (used by the form-based ChannelAccessToken endpoints).Generator version/PHP versiondoc 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.ApiException(this is exactly the code path thehandleResponseWithDataType()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:
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).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 andresponseWithinRangeCode()are not.Test plan
composer testpasses on current code (63 tests)composer testpasses on locally-regenerated 7.22.0 code (63 tests)composer cs/composer copyrightpass