rest-endpoints

Implements OrangeHRM REST API v2 endpoints from routes.yaml through Endpoint classes to JSON responses.

Updated Jul 23, 2026
Ready to run
npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill rest-endpoints-snow-gift111
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: rest-endpoints
Source: https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone/tree/main/.agents/skills/rest-endpoints
Command: npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill rest-endpoints-snow-gift111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding or modifying a REST endpoint in OrangeHRM requires understanding a specific dispatch pipeline — routes.yaml, GenericRestController, Endpoint interfaces, validation rules, and response models — and getting any piece wrong produces confusing 404s, 422s, or 500s. This Skill documents that entire request lifecycle so you can wire endpoints correctly the first time. ## Core Features & Use Cases - Endpoint scaffolding: Choose the right interface (CollectionEndpoint, ResourceEndpoint, CrudEndpoint), implement verb handlers and their getValidationRuleFor* methods, and register routes with correct _api, _key, and requirements settings. - Request handling patterns: Read typed params via RequestParams, wire sorting/pagination/filtering through FilterParams DTOs, and handle Base64 file uploads. - Error and access control: Map exceptions to HTTP status codes (400/403/404/422/501) and enforce row-level access with UserRoleManager checks inside handlers. - Use Case: You need a new /api/v2/pim/widgets endpoint with list, create, and delete support. Follow the full CRUD recipe to create the WidgetAPI class, add both collection and resource routes, and seed permissions via migration. ## Quick Start Ask the AI to create a new OrangeHRM REST API v2 endpoint for a resource, including the Endpoint class, routes.yaml entries, and validation rules.

Frequently Asked Questions about rest-endpoints

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a new REST API endpoint in OrangeHRM?▼

Create a class extending OrangeHRM\Core\Api\V2\Endpoint implementing CrudEndpoint, ResourceEndpoint, or CollectionEndpoint, implement the verb methods plus their getValidationRuleFor* methods, then register routes in the plugin's config/routes.yaml with the _api attribute pointing at your class.

What is the difference between CollectionEndpoint, ResourceEndpoint, and CrudEndpoint?▼

CollectionEndpoint handles list/create/bulk-delete on URLs without an ID, ResourceEndpoint handles getOne/update/delete on URLs with an {id} placeholder, and CrudEndpoint combines both so one class backs both the collection and resource routes.

Why does my OrangeHRM API route call getAll instead of getOne?▼

The resource route is missing the _key attribute in its defaults. The _key value tells GenericRestController to dispatch GET requests to getOne() instead of getAll(), and without it the URL parameter is ignored.

Why does my OrangeHRM endpoint return 422 for valid-looking requests?▼

ParamRuleCollection is strict by default, so any query or body parameter without a matching ParamRule is rejected as an unexpected parameter. Check the response body's error.message for the offending key and add a rule for it.

How do I enforce row-level permissions in an OrangeHRM REST endpoint?▼

Gate-level authorization only checks role CRUD bits, so handlers must enforce ownership themselves using UserRoleManager methods like getAccessibleEntityIds or isEntityAccessible, or the IN_ACCESSIBLE_EMP_NUMBERS validation rule, throwing a ForbiddenException when checks fail.