{"id":15014528,"url":"https://github.com/ajcastro/scribe-tdd","last_synced_at":"2025-04-03T02:12:01.080Z","repository":{"id":38279545,"uuid":"384358397","full_name":"ajcastro/scribe-tdd","owner":"ajcastro","description":"Scribe's test-driven documentation approach.","archived":false,"fork":false,"pushed_at":"2024-10-24T00:09:22.000Z","size":43,"stargazers_count":19,"open_issues_count":5,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-24T13:56:42.413Z","etag":null,"topics":["api","documentation-generator","laravel","php","phpunit"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajcastro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-09T07:31:56.000Z","updated_at":"2024-10-24T00:09:27.000Z","dependencies_parsed_at":"2024-10-24T03:06:38.394Z","dependency_job_id":"4d98ffe9-dafb-4fa5-9f75-bdb1431d4d0c","html_url":"https://github.com/ajcastro/scribe-tdd","commit_stats":{"total_commits":53,"total_committers":3,"mean_commits":"17.666666666666668","dds":0.07547169811320753,"last_synced_commit":"7c98866bea76dbf657ba3d9ee54bf68ec7ab1dbc"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajcastro%2Fscribe-tdd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajcastro%2Fscribe-tdd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajcastro%2Fscribe-tdd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajcastro%2Fscribe-tdd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajcastro","download_url":"https://codeload.github.com/ajcastro/scribe-tdd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246922248,"owners_count":20855345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","documentation-generator","laravel","php","phpunit"],"created_at":"2024-09-24T19:45:44.084Z","updated_at":"2025-04-03T02:12:01.058Z","avatar_url":"https://github.com/ajcastro.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scribe TDD (Test-driven Documentation)\n\n[Scribe](https://github.com/knuckleswtf/scribe)'s test-driven documentation approach.\n\n# Benefits\n\n- Better workflow, instead of writing docblock annotations for parameters in controller, you can auto-generate documentation from the tests performed.\n- Less comments cluttering in controllers. Some annotations are still needed (like @group) but annotations can be put in the test classes instead.\n- Easy to document controllers which methods are inherited from base controllers or traits by putting docblocks in the test methods.\n- Follows the principle \"If it is not tested, it does not exist.\". This makes sure your docs and tests are in sync.\n- It is easy to document responses because it is from the performed tests and does not rely on response calls which sometimes result to errors due to inconsistent database state.\n\n## Installation and Setup\n\n\n### Step 1: Composer Require\n```\ncomposer require --dev ajcastro/scribe-tdd\n```\n\n\n### Step 2: Use ScribeTddSetup trait in TestCase\n\n```php\nuse AjCastro\\ScribeTdd\\Tests\\ScribeTddSetup;\n\nabstract class TestCase extends BaseTestCase\n{\n    use CreatesApplication, ScribeTddSetup;\n\n    public function setUp(): void\n    {\n        parent::setUp();\n\n        $this-\u003esetUpScribeTdd();\n    }\n}\n\n```\n\n### Step 3: Set the necessary strategies\n```php\n    'strategies' =\u003e [\n        'metadata' =\u003e [\n            // ...\n            AjCastro\\ScribeTdd\\Strategies\\Metadata\\GetFromDocBlocksFromScribeTdd::class,\n        ],\n        'urlParameters' =\u003e [\n            // ...\n            AjCastro\\ScribeTdd\\Strategies\\UrlParameters\\GetFromUrlParamTagFromScribeTdd::class,\n        ],\n        'queryParameters' =\u003e [\n            // ...\n            AjCastro\\ScribeTdd\\Strategies\\QueryParameters\\GetFromTestResult::class,\n            AjCastro\\ScribeTdd\\Strategies\\QueryParameters\\AddPaginationParametersFromScribeTdd::class,\n            AjCastro\\ScribeTdd\\Strategies\\QueryParameters\\GetFromQueryParamTagFromScribeTdd::class,\n        ],\n        'headers' =\u003e [\n            // ...\n            AjCastro\\ScribeTdd\\Strategies\\Headers\\GetFromHeaderTagFromScribeTdd::class,\n        ],\n        'bodyParameters' =\u003e [\n            // ...\n            AjCastro\\ScribeTdd\\Strategies\\BodyParameters\\GetFromTestResult::class,\n            AjCastro\\ScribeTdd\\Strategies\\BodyParameters\\GetFromBodyParamTagFromScribeTdd::class,\n        ],\n        'responses' =\u003e [\n            // ...\n            AjCastro\\ScribeTdd\\Strategies\\Responses\\GetFromTestResult::class,\n            AjCastro\\ScribeTdd\\Strategies\\Responses\\UseResponseTagFromScribeTdd::class,\n            AjCastro\\ScribeTdd\\Strategies\\Responses\\UseResponseFileTagFromScribeTdd::class,\n        ],\n        'responseFields' =\u003e [\n            // ...\n            AjCastro\\ScribeTdd\\Strategies\\ResponseFields\\GetFromResponseFieldTagFromScribeTdd::class,\n        ],\n    ],\n```\nIt is up to you if you want to disable existing default strategies or just add these strategies so you can enjoy both worlds.\n\n## Usage\n\n### Step 1: Create and run tests\n\nJust create your usual phpunit tests and run them. This will generate the necessary files that will be\nused for generating scribe documentation later.\n```\nphpunit\n```\n\n### Step 2: Run scribe:generate\nMake sure to use `--force` to remove cached output.\n```\nphp artisan scribe:generate --force\n```\n\n### Step 3: Gitignore auto-generated json files\nAdd the following to your `.gitignore` to ignore auto-generated json files.\nYou should commit your created files, those which are ending in `-@.json`, so that it will always be applied when generating api documentation.\n```\nstorage/scribe-tdd/*/*\n!storage/scribe-tdd/*/*-@.json\n```\n### Step 4: Delete auto-generated files (Optional)\nWhen you run the `phpunit` tests, it creates a lot of files. You can delete these files when you already generated the api documentation by\nrunning the command below. This will not delete your created files.\n```\nphp artisan scribe:tdd:delete\n```\n\n## Sample Usage\n\nHere is a sample project where it uses the tdd approach:\n[https://github.com/ajcastro/TheSideProjectAPI/pull/1](https://github.com/ajcastro/TheSideProjectAPI/pull/1)\n\n## Acknowledgement\nThis package is inspired from [Enlighten](https://github.com/stydeNet/enlighten/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajcastro%2Fscribe-tdd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajcastro%2Fscribe-tdd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajcastro%2Fscribe-tdd/lists"}