Replace StrictHashConfiguration by simpler Grape::Util::ApiDescription #2575
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.
Refactor: Replace StrictHashConfiguration with ApiDescription
This pull request refactors the mechanism for handling API endpoint descriptions by replacing the overly complex
Grape::Util::StrictHashConfiguration
with a new, more straightforward class,Grape::Util::ApiDescription
.Problem
The previous implementation,
StrictHashConfiguration
, used significant metaprogramming (class_eval
,define_method
,const_set
) to dynamically build configuration containers. This made the code:desc
block.Solution
The new
Grape::Util::ApiDescription
class provides a clear and explicit DSL for defining endpoint metadata.Key Changes:
Grape::Util::ApiDescription
: A simple PORO (Plain Old Ruby Object) that uses aninstance_eval
block to provide a clean DSL for setting description attributes. All available attributes (:summary
,:detail
,:params
, etc.) are explicitly defined.Grape::DSL::Desc
: Thedesc
method in the DSL now instantiatesApiDescription
instead of using theStrictHashConfiguration
module.Grape::Util::StrictHashConfiguration
: The complex, metaprogrammed module and its specs have been completely removed from the codebase.Benefits
This change makes a core part of Grape's DSL significantly more robust and easier to maintain for the future.