test(e2e): validate real responses against the OpenAPI schemas - #63
Merged
Conversation
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 gates check only (method, path) — schema bodies had no witness. Now every JSON response the e2e suite already provokes is validated against the spec.
tests/e2e/openapi_check.hpp(~300 lines, nlohmann-only — no new deps): the OpenAPI subset this repo actually uses (typeincl. nullable arrays,required,properties,items,enum,$ref, booladditionalProperties); anything else is a logged SKIP, never a silent pass; an undocumented status is a failure.scripts/gen-openapi-json.sh, committedopenapi.gen.json) with an FNV-1a-64 freshness hash the test re-computes from the yaml — regeneration drift fails with instructions. Runtime YAML parsing rejected honestly: no pyyaml/node in the test image, and a C++ yaml dep rebuilds the vcpkg world.expect_matches_schema(...)wired onto every existing JSON call (17 call sites: auth flows incl. 415/422/401 branches, admin, posts, uploads, idempotency).What it caught (all fixed on the spec side; the code told no lies):
Error/ValidationErrorschemas lacked thestatusfield the server always sends.make lint-openapiis 0-error for the first time.POST /postshad no Post schema at all;Post,PostDetailResponse,RegisterResponse, healthz body added.Gates + selftest 19/19 green; hash parity python↔C++ proven; the e2e run in this CI is the live proof.