feat: schema merging across endpoint observations (GLA-47)#7
Merged
Conversation
Add schema-merger.js that merges per-request schemas into a single enriched schema when the same endpoint is observed multiple times. Header merging: unions header fields across observations, unifies value types into union strings (e.g. "string | integer"), preserves isAuth if any observation had it, marks headers not seen in every observation as optional, and tracks seenCount per header. Body merging: delegates to schema-inferrer's unifySchemas for recursive structural merging — conflicting field types become mixed with variants, fields absent in some observations are marked optional, and array item schemas are unified across all elements. Endpoint export now includes observationCount and mergedSchema per endpoint group instead of the previous requestCount, giving downstream consumers a single enriched schema with confidence proportional to observations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GLA-47 Schema merging
When the same endpoint is observed again, merge the new schema into the existing one rather than overwriting.
Done when multiple observations of the same endpoint produce a single enriched schema. |
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.
Summary
schema-merger.jsmodule that merges per-request schemas into a single enriched schema when the same endpoint is observed multiple timesstring | integer), preservesisAuthif any observation flagged it, marks headers absent from some observations asoptional, tracksseenCountschema-inferrer.unifySchemasfor recursive structural merge — conflicting types becomemixedwithvariants, newly seen fields markedoptional, array item schemas unifiedobservationCountandmergedSchemainstead of justrequestCount, giving downstream consumers confidence proportional to sample sizeTest plan
GET /api/users/123andGET /api/users/456) — verify they group into one endpoint withobservationCount: 2mergedSchemain exported JSON contains unified field types across observationsnullin one observation andstringin another — merged schema should showmixedtype with["null", "string"]variantsoptional: trueAuthorizationheader and some don't — merged header schema should haveisAuth: trueandoptional: trueobservationCountandmergedSchema🤖 Generated with Claude Code