Skip to content

feat: add OpenAPI Overlays support#2059

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/add-openapi-overlays-support
Draft

feat: add OpenAPI Overlays support#2059
Copilot wants to merge 3 commits into
mainfrom
copilot/add-openapi-overlays-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

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):

counterfact openapi.yaml ./out --overlay base.yaml --overlay env-override.yaml

Overlay file format (my-overlay.yaml):

overlay: 1.0.0
info:
  title: My Overlay
  version: 1.0.0
actions:
  - target: $.info
    update:
      description: Injected by overlay
  - target: $.paths['/internal']
    remove: true

Per-spec overlays in counterfact.yaml:

spec:
  - source: openapi.yaml
    group: ""
    overlays:
      - base-overlay.yaml
      - env-overlay.yaml

Overlays are applied in both the code-generation pipeline (Specification.fromFile) and the runtime server pipeline (OpenApiDocument.load). deepMerge is guarded against prototype pollution.

Original Prompt

Overlays

Add support for OpenAPI overlays

Manual acceptance tests

  • counterfact openapi.yaml ./out --overlay overlay.yaml applies the overlay's update action (e.g. changes info.title) before generating route stubs
  • An overlay remove action suppresses route stub generation for the removed path
  • Overlays specified under overlays: in a counterfact.yaml spec entry are applied on startup
  • Repeating --overlay multiple times applies each file in the order given
  • A missing overlay file exits with a clear error message rather than a silent crash
  • Routes unaffected by an overlay continue to serve responses unchanged

Tasks

  • Added src/util/apply-overlay.ts: loadOverlay, applyOverlayActions (JSONPath via jsonpath-plus), applyOverlays; deepMerge with __proto__/constructor/prototype guard
  • Extended Specification.fromFile()/load() and OpenApiDocument constructor to accept overlays?: readonly string[]
  • Propagated overlays through Config, SpecConfig, ApiRunner, CodeGenerator, and loadOpenApiDocument
  • Added repeatable --overlay <path> Commander option to run.ts; per-spec overlays in multi-spec config entries; single-spec CLI flag falls back to config.overlays
  • Added 17 unit tests in test/util/apply-overlay.test.ts
  • Updated docs/reference.md with full Overlays section and CLI flag entry
  • Added minor changeset

Copilot AI linked an issue May 11, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add support for OpenAPI overlays feat: add OpenAPI Overlays support May 11, 2026
Copilot AI requested a review from pmcelhaney May 11, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overlays

2 participants