Add API scaffolding to the template; fix placeholder description - #5
Merged
Conversation
…on (#37) New modules copied from this template now start API-ready instead of web-only. - composer.json: replace "Description for example-package package" with a real one-line description. - src/Routes/api.php: the api.json + auth:sanctum group under the module slug, matching every other Zerp module, with a sample route wired up. - src/Http/Controllers/Api/ExamplePackageItemApiController: a sample controller returning a typed JsonResource collection, the shape that gives Scramble a real response schema. - src/Http/Resources/ExamplePackageItemResource: the resource whose typed fields Scramble reads. - ServiceProvider: load api.php, plus a commented Scramble::registerApi block to uncomment and rename once real endpoints exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes zerp-pk/package-template#37.
New modules copied from this template now start API-ready instead of web-only.
Changes
composer.json— replaced"Description for example-package package"with a real one-line description.src/Routes/api.php— theapi.json+auth:sanctumgroup under the module slug, matching every other Zerp module (hrm, lead, taskly...), with a sample route wired up.src/Http/Controllers/Api/ExamplePackageItemApiController— a sample controller returning a typedJsonResourcecollection (: AnonymousResourceCollection), the shape that gives Scramble a real response schema rather than an opaque object. Ties into zerp-pk/hrm#34's direction so new modules adopt the rich-OpenAPI pattern from day one.src/Http/Resources/ExamplePackageItemResource— the resource whose typed, one-per-line fields Scramble reads.api.php, plus a commentedScramble::registerApi(...)block to uncomment and rename once real endpoints exist (guarded withclass_exists, exactly as hrm does it).Verification
php -lclean on all new/changed files.composer validatepasses.api.phploaded.The sample controller extends
App\Http\Controllers\Controllerand usesApp\Traits\ApiResponseTrait, which resolve inside the host app (the same as hrm's API controllers); route loading does not autoload the controller, so the isolated testbench suite is unaffected.