Template wildcard route segments in exported OpenAPI - #29
Open
VSN2015 wants to merge 1 commit into
Open
Conversation
VSN2015
commented
Sep 5, 2026
| next if requirements[:controller].nil? || requirements[:action].nil? || verb.empty? | ||
|
|
||
| path = route.path.spec.to_s.sub("(.:format)", "").gsub(/:(\w+)/) { "{#{Regexp.last_match(1)}}" } | ||
| path = route.path.spec.to_s.sub("(.:format)", "").gsub(/[:*](\w+)/) { "{#{Regexp.last_match(1)}}" } |
Owner
Author
There was a problem hiding this comment.
Updating the substitution regex to /[:*](\w+)/ cleanly handles both :id parameter segments and *path wildcard segments (such as /files/:bucket/*path).
rails_routes templated the :id form of a Rails path parameter but not
the *rest wildcard, so an ordinary route
get "files/*path", to: "files#show"
exported the path /files/*path — which is not a valid OpenAPI path
template. An invalid path makes the whole document fail validation, so
one glob route silently broke the export for the entire app.
Both forms are now templated, including a route mixing them:
/files/:bucket/*path becomes /files/{bucket}/{path}.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
VSN2015
force-pushed
the
fix/openapi-glob-routes
branch
from
September 11, 2026 22:01
ec56873 to
6f661e4
Compare
This was referenced Sep 12, 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.
The bug
OpenAPI.rails_routestemplated the:idform of a Rails path parameter but not the*restwildcard. So an ordinary route:exported as:
/files/*pathis not a valid OpenAPI path template, and an invalid path makes the whole document fail validation — so one glob route silently breaks the export for the entire app.The fix
files/*path/files/*path/files/{path}files/:bucket/*path/files/{bucket}/*path/files/{bucket}/{path}Verification
.rails_routesspec is unchanged and still passes, so:idtemplating and the skipping of internal/verbless routes are unaffected