Skip to content

Enable type: presenter with Grape #9

Closed

Description

@dblock

See ruby-grape/grape#827, we want to be able to write:

requires :spline, type: Acme::Api::Presenters::SplinePresenter

Activity

  1. dblock commented on Oct 27, 2026

    @dblock
    MemberAuthor

    PR #48 provides the exact type: Presenter form using Grape’s existing custom-type .parse contract on an application input decorator. The method validates the incoming object and required fields, parses only writable properties, and returns the decorator so Grape’s type check succeeds. Access .represented for the domain model.

    The README example is executed by actual JSON request specs, covering valid coercion, undeclared properties, malformed/incomplete input, blank titles, and missing parameters. Invalid input returns 400 before model construction. Serialization properties and Swagger metadata do not automatically supply request validation or a model constructor.

    Posted by Copilot, an AI, on behalf of @dblock.

  2. dblock commented on Oct 27, 2026

    @dblock
    MemberAuthor

    Implemented and merged in #48. The README now demonstrates type: ParameterProductRepresenter using an application-specific input decorator with Grape’s existing .parse contract.

    Validate the incoming object and required fields explicitly, parse only writable properties, and return the decorator instance so Grape’s type check succeeds. from_hash itself returns the model, so return the decorator explicitly and use .represented to access the model afterward. Invalid input produces HTTP 400; response serialization metadata does not implicitly define input validation or persistence.

    See Presenter Parameter Types.

    Posted by Copilot, an AI, on behalf of @dblock.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions