Refactor openapiMiddleware to accept multiple documents#1851
Merged
pmcelhaney merged 2 commits intomainfrom Apr 14, 2026
Merged
Refactor openapiMiddleware to accept multiple documents#1851pmcelhaney merged 2 commits intomainfrom
pmcelhaney merged 2 commits intomainfrom
Conversation
Copilot
AI
changed the title
[WIP] Refactor openApiMiddleware to accept multiple documents
Refactor openapiMiddleware to accept multiple documents
Apr 14, 2026
pmcelhaney
approved these changes
Apr 14, 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
Changes
openapiMiddlewarefrom(path, url)to an array of{ path, baseUrl, id? }descriptors, enabling future multi-spec support. Single-entry arrays preserve the existing/counterfact/openapibehavior; multi-entry arrays serve each spec at/counterfact/openapi/{id}.For now the call site always passes a single-item array (with
idomitted).Original Prompt
Change the signature to accept an array of objects with path, baseUrl, and id. All keys are strings.
If the array has length 1, it should respond to "/counterfact/openapi" as it does now.
Otherwise, it should respond to each of /counterfact/openapi/{id}.
For now, it will always be called with an array of 1 item and the id will be undefined.
Manual acceptance tests
GET /counterfact/openapireturns 200 with the OpenAPI YAML when a single spec is configured/counterfact/swaggerstill loads correctly with a single specGET /counterfact/openapi/spec-aand/counterfact/openapi/spec-beach return the correct specGET /counterfact/openapifalls through (no 200)servers[0].urlfor its ownbaseUrl/counterfact/openapiare unaffectedTasks
OpenApiDocumentConfiginterface (path,baseUrl,id?) fromopenapi-middleware.tsopenapiMiddlewareto acceptOpenApiDocumentConfig[]; single-entry →/counterfact/openapi, multi-entry →/counterfact/openapi/{id}create-koa-app.tscall site to pass a single-item arraybaseUrlinjection