GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add sort-handler-registrations flag to opt out of spec-order registra… by mromaszewicz · Pull Request #2477 · oapi-codegen/oapi-codegen

Conversation

@mromaszewicz

@mromaszewicz mromaszewicz commented Jul 17, 2026

Copy link
Copy Markdown
Member

…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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@mromaszewicz mromaszewicz added the bug Something isn't working label Jul 17, 2026
@mromaszewicz
mromaszewicz requested a review from a team as a code owner July 17, 2026 13:51
@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an opt-out flag for server route registration order. The main changes are:

  • New sort-handler-registrations compatibility config and schema entry.
  • Shared registration-order helper for all generated server backends.
  • Regression coverage for default spec order and opt-in lexicographic order.

Confidence Score: 5/5

The changed flow looks safe to merge after a small documentation cleanup.

  • The config field, schema entry, default behavior, and generation dispatch line up.
  • All server registration generators use the same ordering helper.
  • The remaining issue is discoverability for the new flag in the configuration reference.

docs/configuration.md

Important Files Changed

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot]
greptile-apps Bot reviewed Jul 17, 2026
View reviewed changes
Comment thread pkg/codegen/configuration.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mromaszewicz @claude
Add sort-handler-registrations flag to opt out of spec-order registra…
ee37409
…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) <[email protected]>
@mromaszewicz
mromaszewicz force-pushed the fix/issue-1887 branch from 697a837 to ee37409 Compare July 17, 2026 13:58
@mromaszewicz
mromaszewicz merged commit de2d8b2 into oapi-codegen:main Jul 17, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mromaszewicz
mromaszewicz deleted the fix/issue-1887 branch September 26, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@mromaszewicz
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.