Skip to content

[hrm] Enrich HRM API with FormRequests + API Resources for richer OpenAPI #34

Closed

Description

@HafizMMoaz

Context. The HRM API (zerp-pk/hrm) is documented via Scramble at /docs/hrm, but its controllers return untyped arrays, so the generated request/response schemas are shallow.

Goal. Add typed FormRequest classes and API Resource classes so Scramble infers rich request bodies and response shapes automatically — no annotations needed.

Checklist.

  • Add a FormRequest per write endpoint (leave-request, clock-in-out, etc.) with rules()
  • Add JsonResource classes for the returned models
  • Type controller return values (: JsonResource / : ResourceCollection)
  • Re-check /docs/hrm — request/response schemas should now be populated

Level. Easy, high-visibility. Same approach then applies to lead/taskly/support-ticket.

Activity

  1. HafizMMoaz commented on Jul 23, 2026

    @HafizMMoaz
    MemberAuthor

    Done across #81 (the shared ApiFormRequest base) and zerp-pk/hrm#5 (HRM FormRequests + Resource).

    Two write endpoints now use typed FormRequests, so /docs/hrm shows real request bodies for leave-request and clock-in-out instead of empty ones. The base lives in the app next to ApiResponseTrait, so lead/taskly/support-ticket reuse the same pattern.

    One honest correction to the checklist: typing controller returns as a JsonResource does not enrich the response schemas here, because every endpoint answers with the shared {success, message, data} envelope that mobile clients depend on, and Scramble cannot see through that helper. Enriching response schemas means either dropping the envelope (breaks clients) or adding Scramble response annotations. That annotation pass is a clean, non-breaking follow-up if we want it; I did not force a breaking change to tick the box.

    The Resource still landed, on its own merit: the leave shape had been hand-copied into the list and create responses and the two had drifted on the missing-attachment fallback (avatar.png vs empty string). They now share one source.

  2. added a commit that references this issue on Jul 23, 2026
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

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions