feat: add OpenAPI Overlays support#2059
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Open
Copilot
AI
changed the title
[WIP] Add support for OpenAPI overlays
feat: add OpenAPI Overlays support
May 11, 2026
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
Adds support for OpenAPI Overlays v1.0.0 — a mechanism to apply targeted patches to an OpenAPI document without modifying the original file.
New CLI flag (repeatable, applied in order):
Overlay file format (
my-overlay.yaml):Per-spec overlays in
counterfact.yaml:Overlays are applied in both the code-generation pipeline (
Specification.fromFile) and the runtime server pipeline (OpenApiDocument.load).deepMergeis guarded against prototype pollution.Original Prompt
Overlays
Add support for OpenAPI overlays
Manual acceptance tests
counterfact openapi.yaml ./out --overlay overlay.yamlapplies the overlay'supdateaction (e.g. changesinfo.title) before generating route stubsremoveaction suppresses route stub generation for the removed pathoverlays:in acounterfact.yamlspec entry are applied on startup--overlaymultiple times applies each file in the order givenTasks
src/util/apply-overlay.ts:loadOverlay,applyOverlayActions(JSONPath viajsonpath-plus),applyOverlays;deepMergewith__proto__/constructor/prototypeguardSpecification.fromFile()/load()andOpenApiDocumentconstructor to acceptoverlays?: readonly string[]overlaysthroughConfig,SpecConfig,ApiRunner,CodeGenerator, andloadOpenApiDocument--overlay <path>Commander option torun.ts; per-specoverlaysin multi-spec config entries; single-spec CLI flag falls back toconfig.overlaystest/util/apply-overlay.test.tsdocs/reference.mdwith full Overlays section and CLI flag entry