rest-openapi

Annotates OrangeHRM REST endpoints and models with swagger-php OpenAPI v3 docblocks.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill rest-openapi-snow-gift111
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rest-openapi
Source: https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone/tree/main/.agents/skills/rest-openapi
Command: npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill rest-openapi-snow-gift111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? OrangeHRM's CI enforces OpenAPI v3 annotations on every REST endpoint and Model class via generate-open-api-doc --throw, so a PR with missing or malformed swagger-php annotations fails the build. This Skill provides the exact annotation patterns, shared component refs, and debugging steps needed to write correct @OA\* docblocks the first time. ## Core Features & Use Cases - Endpoint Annotation Recipes: Ready-to-adapt templates for @OA\Get, @OA\Post, @OA\Delete blocks on handler methods (getOne, getAll, create, update, delete), including path parameters, query parameters, and request bodies. - Shared Component Refs: Documents the project's reusable #/components/responses/RecordNotFound, ForbiddenResponse, DeleteResponse, DeleteRequestBody, and the sortOrder/limit/offset parameters so you reference instead of redefine. - Model Schema Rules: Explains the <Plugin>-<ModelName> schema naming convention, aligning @OA\Property entries with setAttributeNames(), nested objects, arrays, and oneOf model variants. - Use Case: You add a new /api/v2/x/widgets endpoint and need the annotations to pass CI. Follow the checklist, use PHP class constants inside annotations for enums and max lengths, then verify locally with php devTools/core/console.php generate-open-api-doc --throw before pushing. ## Quick Start Ask the agent to add OpenAPI annotations to your new endpoint handler methods and Model class following the rest-openapi conventions, then run the generate-open-api-doc command with the throw flag to verify.

Frequently Asked Questions about rest-openapi

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

FAQPage Schema
How do I add OpenAPI annotations to a new REST endpoint in OrangeHRM?

Add one @OA\Get, Post, Put, or Delete block above each handler method with path matching routes.yaml, a Plugin/Resource tag, a unique kebab-case operationId, and at least a 200 response. Reference shared components like RecordNotFound and the sortOrder/limit/offset parameters instead of redefining them.

How do I fix a generate-open-api-doc --throw failure in CI?

Run php devTools/core/console.php generate-open-api-doc --throw locally to see the exact file and line. Common causes are unbalanced enum braces, unknown schema refs, paths not matching routes.yaml, duplicated operationIds, or renamed PHP constants referenced inside annotations.

Can I use PHP class constants inside swagger-php annotations?

Yes, swagger-php evaluates class constants written as FQCN or imported short names inside annotation expressions. Use them for maxLength, enum, and default values so the docs stay in sync when the constant changes; a missing or renamed constant fails doc generation.

What naming convention do OrangeHRM Model @OA\Schema blocks follow?

Each Model class gets a @OA\Schema block named <Plugin>-<ModelName>, such as Pim-EmployeeModel, referenced from endpoint responses via #/components/schemas/<Plugin>-<ModelName>. Declare one @OA\Property per entry in setAttributeNames(), keeping names and order aligned.

Why does generate-open-api-doc pass locally but fail in CI?

Without the --throw flag, the command exits 0 even on parse errors, so local runs can appear successful. CI's Lint workflow uses --throw, which fails non-zero on any parse error or missing schema reference; always test locally with the flag.