Add "Multiple API Versions" pattern and restructure patterns index#1962
Open
Add "Multiple API Versions" pattern and restructure patterns index#1962
Conversation
Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/654afd5d-c14a-489f-a4ab-952172bb99f7 Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Create a pattern for working with multiple versions of API
Add "Multiple API Versions" pattern and restructure patterns index
Apr 26, 2026
pmcelhaney
requested changes
Apr 26, 2026
|
|
||
| ## Solution | ||
|
|
||
| Configure each versioned spec as a separate entry in the `specs` array passed to `counterfact()`. Give them the same `group` and different `version` labels. Counterfact generates a shared route file per path and injects two helpers into the handler's `$` argument at runtime: |
Collaborator
There was a problem hiding this comment.
Explain in terms of the config file, not the API.
Contributor
Author
There was a problem hiding this comment.
Done in 4e3d1d2. The Solution section now says to list specs under the spec key in counterfact.yaml, and the Configuration example is a YAML block instead of a TypeScript counterfact() call.
…act.yaml Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/df1055e4-121f-4f26-83a8-53b139fc3caf Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
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 a new
$.minVersion()pattern page and rewrites the patterns index introduction, which had grown into a single unwieldy run-on paragraph.docs/patterns/multiple-versions.md(new)groupusingcounterfact.yaml$.minVersion()branching in a single shared handler across v1/v2/v3minVersioncheckdocs/patterns/index.mdOriginal Prompt
Create a pattern that describes working with multiple versions of an API and using $.minVersion().
Also rewrite the patterns index introduction. It's gotten very long. It should be broken up into multiple paragraphs, and possible even have section headers.
Manual acceptance tests
docs/patterns/multiple-versions.mdrenders correctly and all Related Patterns links resolve to existing filesdocs/patterns/index.mdintroduction displays as distinct labelled sections rather than one long paragraphindex.mdstill resolve correctly$.minVersion()example in the new pattern matches the runtime semantics:truewhen current version ≥minin declaration order, absent on unversioned runnerscounterfact.yamlconfiguration example inmultiple-versions.mduses the correct YAMLspecarray format withsource,group, andversionkeysTasks
docs/patterns/multiple-versions.mdwith full pattern structure covering configuration (viacounterfact.yaml), runtime helpers, TypeScript narrowing, and consequencesdocs/patterns/index.mdintroduction into six sectioned paragraphs; added new pattern to All patterns table.changeset/multiple-versions-pattern.md(patch bump)multiple-versions.mdto usecounterfact.yamlYAML format instead of the programmaticcounterfact()API