Skip to content

Drop the undocumented formats/content_types produces aliases#984

Open
ericproulx wants to merge 2 commits into
ruby-grape:masterfrom
ericproulx:drop_formats_content_types_aliases
Open

Drop the undocumented formats/content_types produces aliases#984
ericproulx wants to merge 2 commits into
ruby-grape:masterfrom
ericproulx:drop_formats_content_types_aliases

Conversation

@ericproulx

Copy link
Copy Markdown
Contributor

Follow-up to #983 (stacked on it — until #983 merges, the diff here also shows #983's reader migration; it narrows to just this change once #983 is in).

grape-swagger let you set the swagger produces field three ways via desc: produces:, formats:, or content_types:. Only produces is documented (README #### produces); formats / content_types were undocumented aliases that resolved solely through Grape::Router::BaseRoute#method_missing delegating route.formats / route.content_types to route.options[...] — i.e. not real Grape route options.

This consolidates on the documented produces:

  • produces_object reads only route.produces (a real Grape DSL_METHODS reader), dropping the %i[formats content_types produces] public_send loop.
  • api_swagger_v2_format-content_type_spec.rb keeps the produces case (plus use_default and consumes); the use_formats / use_content_types cases are removed.
  • UPGRADING note added.

This is the removal I proposed in the #983 discussion: with it, grape-swagger no longer relies on method_missing for route metadata.

Tests

Full suite: 513 examples, 2 failures (both pre-existing on master, unrelated), 2 pending — no new failures.

🤖 Generated with Claude Code

ericproulx and others added 2 commits July 8, 2026 08:39
grape-swagger reached into the route's options Hash for metadata. Replace
every route.options[...] read with the equivalent reader method —
including the success/failure aliases of entity/http_codes and the
dynamic producer lookup (via public_send) — so grape-swagger consumes
routes through their public method interface rather than the internal
options Hash. This lets Grape restructure route.options (reserving it for
user custom keys) without breaking grape-swagger.

build_body_parameter now takes a resolved body_name value rather than the
options Hash. The readers resolve on supported Grape (verified on 2.4.0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
grape-swagger let you set the swagger `produces` field via desc's
`formats:` or `content_types:` in addition to the documented `produces:`.
Those two aliases were never documented (only `produces` is in the
README) and worked only because BaseRoute#method_missing delegated
`route.formats` / `route.content_types` to `route.options[...]`.

Consolidate on `produces`: `produces_object` reads only `route.produces`,
and the format/content_type spec keeps just the produces (plus default
and consumes) cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ericproulx ericproulx force-pushed the drop_formats_content_types_aliases branch from 8e0f596 to 9c757cc Compare July 8, 2026 06:47
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@dblock dblock requested a review from numbata July 12, 2026 15:41
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.

1 participant