Skip to content

Conversation

@fernando-aviles
Copy link
Contributor

@fernando-aviles fernando-aviles commented Jan 5, 2026

Greptile Summary

This PR enhances the OpenAPI path auto-update feature to intelligently repoint references when entries move between spec files. The implementation adds a new specHasMatch() helper function and extends the resolveSpec() function to detect when an explicitly referenced spec no longer contains a required operation/webhook/schema, then searches for alternatives. When exactly one alternative is found, it automatically repoints the reference with a warning; when multiple alternatives or none exist, it gracefully skips localization. The feature is well-tested with a new comprehensive test case covering the spec-switching scenario. This improves developer experience by automatically correcting stale OpenAPI references in frontmatter when documentation schemas evolve.

Confidence Score: 5/5

  • This PR is safe to merge with no critical issues identified. Changes are well-tested, logically sound, and maintain backward compatibility.
  • Score reflects: (1) Feature is well-designed with clear separation of concerns through the new specHasMatch() helper; (2) Comprehensive test coverage with a new test case validating the spec-repointing behavior; (3) Robust error handling with appropriate warnings for edge cases (missing entries, multiple matches, no matches); (4) No breaking changes to existing logic - new behavior only triggers when explicit specs don't contain referenced entries; (5) Code quality is high with proper type safety and documentation.
  • No files require special attention

Important Files Changed

Filename Overview
packages/cli/src/utils/processOpenApi.ts Added logic to auto-update OpenAPI spec paths in frontmatter when referenced entries move between specs. New helper function specHasMatch checks if a spec contains operations, webhooks, or schemas. Enhanced resolveSpec function now handles spec changes: single alternative repoints, multiple alternatives skip with warning, no alternatives skip with warning. Code quality is high with proper error handling and warnings.
packages/cli/src/utils/tests/processOpenApi.test.ts Added comprehensive test case for spec path repointing behavior. Test 'repoints explicit spec paths when entry moves to another spec' validates that when an entry is found in a different spec than explicitly referenced, the path is correctly updated to the new spec location in both source and localized files.

Sequence Diagram

sequenceDiagram
    participant MD as Markdown File
    participant PR as processOpenApi()
    participant RS as resolveSpec()
    participant SM as specHasMatch()
    participant FM as fileMapping

    MD->>PR: Start processing file
    PR->>RS: Resolve explicit spec path
    RS->>SM: Check if spec contains entry
    SM-->>RS: Entry not in spec
    RS->>RS: Find alternatives in other specs
    RS->>SM: Check each alternative
    SM-->>RS: Found in spec-b only
    RS->>FM: Resolve localized path for spec-b
    FM-->>RS: Return locale-specific path
    RS->>PR: Return alternative spec
    PR->>MD: Update frontmatter with new spec path
    Note over PR: Warnings logged for reference changes
Loading

@fernando-aviles fernando-aviles requested a review from a team as a code owner January 5, 2026 19:57
@fernando-aviles fernando-aviles merged commit ca7b778 into main Jan 5, 2026
20 checks passed
@fernando-aviles fernando-aviles deleted the f/auto-update-openapi-paths branch January 5, 2026 20:07
@github-actions github-actions bot mentioned this pull request Jan 5, 2026
archie-mckenzie pushed a commit that referenced this pull request Jan 5, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## [email protected]

### Patch Changes

- [#929](#929)
[`ca7b778`](ca7b778)
Thanks [@fernando-aviles](https://github.com/fernando-aviles)! -
Auto-update OpenAPI spec paths when specs are modified

## [email protected]

### Patch Changes

- Updated dependencies
\[[`ca7b778`](ca7b778)]:
    -   [email protected]

<!-- greptile_comment -->

<h3>Greptile Summary</h3>


This is an automated release PR created by the Changesets GitHub Action
that bumps package versions and updates changelogs to publish the
OpenAPI spec auto-update feature from PR #929.

**Changes:**
- Bumped `gtx-cli` from 2.5.40 to 2.5.41 (patch release)
- Bumped `locadex` from 1.0.68 to 1.0.69 (dependency update)
- Updated changelogs for both packages
- Removed the consumed changeset file

The release contains a patch feature that automatically updates OpenAPI
spec paths in frontmatter when referenced entries move between spec
files, improving developer experience by correcting stale references.

<details open><summary><h3>Confidence Score: 5/5</h3></summary>


- This PR is safe to merge with no risk - standard automated release
process
- Score reflects: (1) This is an automated release PR generated by the
Changesets GitHub Action with standard version bumps and changelog
updates; (2) All changes follow expected patterns for semantic
versioning (patch release); (3) Version numbers are correctly
incremented in both package.json files; (4) Changelogs properly document
the changes with correct links and commit hashes; (5) The changeset file
is correctly removed after processing; (6) No code changes - only
metadata updates
- No files require special attention
</details>


<details><summary><h3>Important Files Changed</h3></summary>




| Filename | Overview |
|----------|----------|
| packages/cli/package.json | Bumped version from 2.5.40 to 2.5.41 for
patch release |
| packages/locadex/package.json | Bumped version from 1.0.68 to 1.0.69
for dependency update release |
| .changeset/cool-kids-lay.md | Removed consumed changeset file after
processing by changesets release action |

</details>


</details>


<details><summary><h3>Sequence Diagram</h3></summary>

```mermaid
sequenceDiagram
    participant GHA as GitHub Actions
    participant CS as Changesets Action
    participant PKG1 as gtx-cli package
    participant PKG2 as locadex package
    participant CH as Changeset File

    GHA->>CS: Trigger release workflow
    CS->>CH: Read changeset (cool-kids-lay.md)
    CS->>PKG1: Bump version 2.5.40 → 2.5.41
    CS->>PKG1: Update CHANGELOG.md
    CS->>PKG2: Detect dependency update
    CS->>PKG2: Bump version 1.0.68 → 1.0.69
    CS->>PKG2: Update CHANGELOG.md
    CS->>CH: Delete consumed changeset
    CS->>GHA: Create release PR
    Note over GHA: Ready for merge and npm publish
```
</details>


<!-- greptile_other_comments_section -->

<!-- /greptile_comment -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants