Drop the undocumented formats/content_types produces aliases#984
Open
ericproulx wants to merge 2 commits into
Open
Drop the undocumented formats/content_types produces aliases#984ericproulx wants to merge 2 commits into
ericproulx wants to merge 2 commits into
Conversation
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>
8e0f596 to
9c757cc
Compare
Danger ReportNo issues found. |
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.
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
producesfield three ways viadesc:produces:,formats:, orcontent_types:. Onlyproducesis documented (README#### produces);formats/content_typeswere undocumented aliases that resolved solely throughGrape::Router::BaseRoute#method_missingdelegatingroute.formats/route.content_typestoroute.options[...]— i.e. not real Grape route options.This consolidates on the documented
produces:produces_objectreads onlyroute.produces(a real GrapeDSL_METHODSreader), dropping the%i[formats content_types produces]public_sendloop.api_swagger_v2_format-content_type_spec.rbkeeps theproducescase (plususe_defaultandconsumes); theuse_formats/use_content_typescases are removed.This is the removal I proposed in the #983 discussion: with it, grape-swagger no longer relies on
method_missingfor route metadata.Tests
Full suite: 513 examples, 2 failures (both pre-existing on
master, unrelated), 2 pending — no new failures.🤖 Generated with Claude Code