{"id":17626607,"url":"https://github.com/osteel/openapi-httpfoundation-testing-laravel-example","last_synced_at":"2025-09-13T08:45:40.820Z","repository":{"id":80630740,"uuid":"310355921","full_name":"osteel/openapi-httpfoundation-testing-laravel-example","owner":"osteel","description":"OpenAPI HttpFoundation Testing: a Laravel Example","archived":false,"fork":false,"pushed_at":"2023-06-19T15:34:27.000Z","size":266,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T17:54:53.197Z","etag":null,"topics":["api","http","httpfoundation","laravel","openapi","testing","validation"],"latest_commit_sha":null,"homepage":"https://tech.osteel.me/posts/openapi-backed-api-testing-in-php-projects-a-laravel-example","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/osteel.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":"2020-11-05T16:24:20.000Z","updated_at":"2022-06-13T15:20:11.000Z","dependencies_parsed_at":"2024-10-23T05:10:42.191Z","dependency_job_id":"0a6c1bf7-8919-4757-bd68-b62215e9f2be","html_url":"https://github.com/osteel/openapi-httpfoundation-testing-laravel-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/osteel/openapi-httpfoundation-testing-laravel-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osteel%2Fopenapi-httpfoundation-testing-laravel-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osteel%2Fopenapi-httpfoundation-testing-laravel-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osteel%2Fopenapi-httpfoundation-testing-laravel-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osteel%2Fopenapi-httpfoundation-testing-laravel-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osteel","download_url":"https://codeload.github.com/osteel/openapi-httpfoundation-testing-laravel-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osteel%2Fopenapi-httpfoundation-testing-laravel-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274941334,"owners_count":25378204,"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","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","http","httpfoundation","laravel","openapi","testing","validation"],"created_at":"2024-10-22T23:07:15.989Z","updated_at":"2025-09-13T08:45:40.758Z","avatar_url":"https://github.com/osteel.png","language":"PHP","readme":"# OpenAPI HttpFoundation Testing – a Laravel Example\n\nThis repository demonstrates how to use the [OpenAPI HttpFoundation Testing](https://github.com/osteel/openapi-httpfoundation-testing) package in a Laravel project.\n\nIt uses [L5 Swagger](https://github.com/DarkaOnLine/L5-Swagger) to expose an OpenAPI-based documentation through [Swagger UI](https://swagger.io/tools/swagger-ui/).\n\nPlease refer to [this blog post](https://tech.osteel.me/posts/openapi-backed-api-testing-in-php-projects-a-laravel-example \"OpenAPI-backed API testing in PHP projects – a Laravel example\") for a detailed explanation.\n\n## Installation\n\nClone the repository:\n\n```bash\n$ git clone git@github.com:osteel/openapi-httpfoundation-testing-laravel-example.git\n```\n\nInstal the project's dependencies from the root folder:\n\n```bash\n$ composer install\n```\n\n## Usage\n\nStart the PHP development server using Laravel's Artisan command:\n\n```bash\n$ php artisan serve\n```\n\nSwagger UI should now be available at [localhost:8000/api/documentation](http://localhost:8000/api/documentation) (you might need to replace `api-docs.json` with `api-docs.yaml` in the \"explore\" bar at the top, so it loads the [YAML definition](https://github.com/osteel/openapi-httpfoundation-testing-laravel-example/blob/main/storage/api-docs/api-docs.yaml) instead of the JSON one, that we haven't provided).\n\nThere is an [example test](https://github.com/osteel/openapi-httpfoundation-testing-laravel-example/blob/main/tests/ExampleTest.php) which you can run:\n\n```bash\n$ ./vendor/bin/phpunit tests/Feature\n```\n\nThis test queries the `/api/test` endpoint and validates the response against the provided YAML OpenAPI definition.\n\nNow alter that endpoint's behaviour by changing its route in `routes/api.php` for this one:\n\n```php\nRoute::get('/test', function (Request $request) {\n    return response()-\u003ejson(['baz' =\u003e 'bar']);\n});\n```\n\nRun the test again – it should now fail because the response contains a `baz` key where `foo` is expected, as per the OpenAPI definition.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosteel%2Fopenapi-httpfoundation-testing-laravel-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosteel%2Fopenapi-httpfoundation-testing-laravel-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosteel%2Fopenapi-httpfoundation-testing-laravel-example/lists"}