feat: add OpenAPI Overlays support#2059
Draft
Copilot wants to merge 5 commits into
Draft
Conversation
Open
Copilot
AI
changed the title
[WIP] Add support for OpenAPI overlays
feat: add OpenAPI Overlays support
May 11, 2026
pmcelhaney
requested changes
May 18, 2026
Collaborator
pmcelhaney
left a comment
There was a problem hiding this comment.
Add some example overlays to fixtures.
pmcelhaney
requested changes
May 18, 2026
Collaborator
pmcelhaney
left a comment
There was a problem hiding this comment.
Add a black box test
Contributor
Author
Done in 5532344. Added three overlay fixtures under
Each fixture is exercised by a new test in |
Contributor
Author
Done in 0ca5b36. Added two black box tests to
|
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
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.ts, including fixture-based integration teststest/fixtures/openapi/overlays/:update-info.yaml— patches the API title, description, and contact blockremove-deprecated.yaml— removes the deprecated/legacy/itemsendpointadd-extensions.yaml— addsx-internal: trueto targeted operationstest-black-box/test_counterfact.py:test_overlay_removes_path_from_generated_routes— runs--generate --overlaywith aremoveaction and asserts the removed path produces no route filetest_overlay_update_changes_served_response— starts a live server with--serve --generate --overlayand verifies the overlay-modified example value is returned at runtimedocs/reference.mdwith full Overlays section and CLI flag entry