Skip to content

Honor documented default: (and default_response:) in 2.3; stop reading route.desc #991

Closed

Description

@numbata

Parent tracker: #987.

Two leftover reader-migration items we can do in grape-swagger 2.3 without waiting on Grape.

1. Documented default: is ignored

The README "Default response" section documents:

desc 'thing', default: { message: 'the default response' }

The code has only ever read route.default_response. So the documented spelling is a silent no-op, and the spelling that works is undocumented (only in specs).

2.3: read both:

route.try(:default_response) || route.settings.dig(:description, :default)
  • try(:default_response) keeps the working (undocumented) spelling without depending on delegate_missing_to forever (try is nil when respond_to? is false).
  • route.default looks like the matching Grape reader, but it is Hash#default: BaseRoute def_delegators :default onto @options, which is ActiveSupport::OrderedOptions < Hash. It always returns nil. Do not use it. route.settings is a real reader; :description already holds the Hash-form and block-form default: payload.
  • Do not go back to route.options[:…].

Document default_response: as the preferred form; note that default: still works until 3.0. grape-swagger 3.0 can drop the default: fallback once Grape adds default_response as a real desc key and aliases default onto it (see #987).

2. Stop reading route.desc

desc 'text' stores :description. route.desc is almost never set and is one of the four method_missing reads in #987. Drop summary = route.desc if route.desc in summary_object; keep route.description + route.detail + route.summary. No Grape reader for desc.

desc 'This returns something' with no detail/summary already puts that text in swagger description (api_swagger_v2_detail_spec.rb, detail: nil example).

Activity

  1. numbata commented on Sep 6, 2026

    @numbata
    ContributorAuthor

    Duplicate of #989 — that issue already tracks this 2.3 work and is closed by #990.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions