Add sort-handler-registrations flag to opt out of spec-order registra…#2477
Merged
Merged
Conversation
Contributor
Greptile SummaryThis PR adds an opt-out flag for server route registration order. The main changes are:
Confidence Score: 5/5The changed flow looks safe to merge after a small documentation cleanup.
docs/configuration.md
|
| Filename | Overview |
|---|---|
| configuration-schema.json | Adds the new compatibility flag to the JSON schema with a matching boolean shape. |
| pkg/codegen/configuration.go | Adds the Go config field for the new compatibility flag; the config reference still needs the matching documentation update. |
| pkg/codegen/operations.go | Adds the lexicographic ordering helper and routes all server registration generators through the shared dispatch. |
| pkg/codegen/codegen_test.go | Adds a focused test for default spec-order registration and opt-in lexicographic registration. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
pkg/codegen/configuration.go:398
**Compatibility Flag Is Undocumented**
The new `sort-handler-registrations` option is accepted by the Go config and schema, but the hand-maintained configuration reference still omits it from the compatibility options list. Users relying on that reference will not discover the opt-out and can keep generating spec-order route registrations when they need the historical lexicographic order.
Reviews (1): Last reviewed commit: "Add sort-handler-registrations flag to o..." | Re-trigger Greptile
…tion PR oapi-codegen#2465 (issue oapi-codegen#1887) changed generated servers to register route handlers in spec-declaration order, so that routers which match in registration order (Fiber, Gorilla/mux) can disambiguate overlapping paths by ordering them in the spec. This makes that behavior opt-out: the new sort-handler-registrations compatibility flag restores the historical lexicographic (by path, then method) registration order for users who relied on it. The dispatch is a single seam -- operationsInRegistrationOrder picks sortOperationsLexicographically when the flag is set, otherwise the existing sortOperationsBySpecOrder -- and all nine GenerateXServer functions route through it. The lexicographic sort reproduces the historical gather order (SortedMapKeys over paths then methods), so with the flag unset the default output is unchanged. Adds TestSortHandlerRegistrations and documents the flag in configuration-schema.json. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mromaszewicz
force-pushed
the
fix/issue-1887
branch
from
July 17, 2026 13:58
697a837 to
ee37409
Compare
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.
…tion
PR #2465 (issue #1887) changed generated servers to register route handlers in spec-declaration order, so that routers which match in registration order (Fiber, Gorilla/mux) can disambiguate overlapping paths by ordering them in the spec. This makes that behavior opt-out: the new sort-handler-registrations compatibility flag restores the historical lexicographic (by path, then method) registration order for users who relied on it.
The dispatch is a single seam -- operationsInRegistrationOrder picks sortOperationsLexicographically when the flag is set, otherwise the existing sortOperationsBySpecOrder -- and all nine GenerateXServer functions route through it. The lexicographic sort reproduces the historical gather order (SortedMapKeys over paths then methods), so with the flag unset the default output is unchanged.
Adds TestSortHandlerRegistrations and documents the flag in configuration-schema.json.