Skip to content

Honor documented default: and stop reading route.desc - #990

Merged
numbata merged 1 commit into
masterfrom
fix/default-response-and-drop-route-desc
Nov 11, 2026
Merged

numbata merged 1 commit into
masterfrom
fix/default-response-and-drop-route-desc

Conversation

@numbata

@numbata numbata commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #989. Follow-up from #987.

Summary

The README told users to document a default response with desc ..., default:, but the gem silently ignored that spelling and only honored default_response:. With this change both spellings work, and the README now recommends default_response:. Separately, get '/', desc: '…' no longer produces a swagger summary; that option was never Grape's desc DSL, so users should write desc '…' or summary:.

Root cause

The code read route.default_response, while the README documented default:. route.default cannot serve as a fallback: it resolves to OrderedOptions / Hash#default and answers nil even when the key is set. The fallback therefore reads route.settings[:description][:default], which is where Grape 2.x/3.x keep it. Grape 4 remaps default: onto default_response: itself and deprecates it, so the fallback only matters on Grape < 4.

For route.desc: Grape's desc DSL stores :description, and get '/', desc: is a passthrough onto the route, so reading it as a summary was accidental behavior.

Drawbacks

  • get '/', desc: '…' stops producing a summary with no runtime warning. This is documented in UPGRADING and the CHANGELOG, but users who relied on it will see the summary disappear.
  • default: is read silently on Grape 2.x/3.x until grape-swagger 3.0; there is no warning for that spelling there.

Rejected alternatives

  • Reading route.default: always nil for this key, see above.
  • Warning on desc: or default:: adds code to paths that are being retired, and default: users on Grape 4 already get Grape's own deprecation.
  • Dropping default: outright: would turn a documented spelling into a hard break in a minor release.

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Danger Report

No issues found.

View run

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review found no active issues, with regression coverage and documentation updates supporting the response-option compatibility and route-description behavior changes.

No open issues 🎉

What changed in this PR

Updates grape-swagger to honor the documented default: response option while preserving default_response: compatibility, and stops treating route.desc as a Swagger summary.

Changes:

  • Supports both default_response: and legacy default: response options, preferring default_response:.
  • Removes route.desc summary handling in favor of the desc DSL and summary:.
  • Updates documentation, changelog entries, compatibility helpers, and regression coverage.
File Description
UPGRADING.md Documents default-response spelling and route description behavior changes.
spec/​swagger_v2/​namespaced_api_spec.rb Tests descriptions from the desc DSL and passthrough desc: behavior.
spec/​swagger_v2/​api_swagger_v2_response_with_models_spec.rb Adds coverage for the documented default: spelling.
spec/​support/​grape_version.rb Detects Grape versions that remap default: to default_response:.
README.md Updates default-response documentation and examples.
lib/​grape-swagger/​endpoint.rb Supports both default-response keys and removes route.desc reads.
CHANGELOG.md Records the behavior changes for the upcoming release.

Review effort: Lite

The README documented desc ..., default: but grape-swagger only read
default_response:, so the documented spelling was a silent no-op.
route.default cannot be the fallback: it is OrderedOptions / Hash#default
and answers nil even when the key is set. Read default_response first,
then settings[:description][:default], which is where Grape < 4 keeps it.

Also stop reading route.desc. Grape's desc DSL stores :description;
get '/', desc: is a passthrough onto the route, not that DSL, and is no
longer treated as a swagger summary.

The default: example runs on every supported Grape, with the deprecation
Grape 4 emits for it silenced.
@numbata
numbata force-pushed the fix/default-response-and-drop-route-desc branch from 182aa96 to 87e5b87 Compare November 10, 2026 14:32
@numbata
numbata requested a lite review from Copilot November 10, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical test compatibility issue remains: the spec calls Grape.deprecator unconditionally, causing NoMethodError and CI failures across supported older Grape versions.

1 open issue

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes address the documented response-option compatibility and route-description behavior, with corresponding regression tests and updated documentation showing no active review issues.

No open issues 🎉

1 resolved since last review

Review effort: Lite

@numbata
numbata merged commit ec88f43 into master Nov 11, 2026
35 checks passed
@numbata
numbata deleted the fix/default-response-and-drop-route-desc branch November 11, 2026 15:10
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.

Support default_response and default in 2.3; stop reading route.desc

3 participants