{"id":16458493,"url":"https://github.com/pionl/laravel-swagger-test","last_synced_at":"2025-10-27T09:31:08.836Z","repository":{"id":57041865,"uuid":"257870748","full_name":"pionl/laravel-swagger-test","owner":"pionl","description":"Test your routes using Laravel's underlying request testing (without making real request) against your API schema.","archived":false,"fork":false,"pushed_at":"2021-02-04T16:33:01.000Z","size":11,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T04:31:51.317Z","etag":null,"topics":["api","laravel","openapi","phpunit","swagger","testing-tools"],"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/pionl.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}},"created_at":"2020-04-22T10:41:22.000Z","updated_at":"2022-06-13T14:48:15.000Z","dependencies_parsed_at":"2022-08-23T23:40:11.665Z","dependency_job_id":null,"html_url":"https://github.com/pionl/laravel-swagger-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pionl%2Flaravel-swagger-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pionl%2Flaravel-swagger-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pionl%2Flaravel-swagger-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pionl%2Flaravel-swagger-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pionl","download_url":"https://codeload.github.com/pionl/laravel-swagger-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238471997,"owners_count":19478141,"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","laravel","openapi","phpunit","swagger","testing-tools"],"created_at":"2024-10-11T10:45:27.164Z","updated_at":"2025-10-27T09:31:03.576Z","avatar_url":"https://github.com/pionl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Swagger Test\n\n\u003e Underlying logic uses [PHP Swagger Test](https://github.com/byjg/php-swagger-test) from [byjg](https://github.com/byjg)\n\nTest your routes using Laravel's underlying request testing (without making real request) against your API schema.\n\n## Support\n\n\u003e How to make tests and which OpenAPI is supported check the [PHP Swagger Test](https://github.com/byjg/php-swagger-test).\n \n At the time of writing this readme OpenAPI 3 is partially supported.\n \n ## Install\n \n 1. Add a custom repository for php-swagger-test with internal improvements. (In future it could be merged).\n \n    ```\n    \"repositories\": [\n        {\n            \"type\": \"git\",\n            \"url\": \"https://github.com/pionl/php-swagger-test\"\n        }\n    ]\n    ```\n 2. Require the package\n    \n    ```\n    compsoer require pion/laravel-swagger-test\n    ```\n \n ## Usage\n \n Use the Laravel's TestCase and use `AssertRequestAgainstSchema` trait assert request against schema.\n \n Uses same \"request building\" as `ApiRequester`. For more details check the [PHP Swagger Test](https://github.com/byjg/php-swagger-test).\n \n ```php\nuse Tests\\TestCase;\nuse ByJG\\ApiTools\\AssertRequestAgainstSchema;\nuse ByJG\\ApiTools\\Base\\Schema;\nuse ByJG\\ApiTools\\Laravel\\LaravelRequester;\n\nclass GetUsersTest extends TestCase\n{\n    use AssertRequestAgainstSchema;\n    \n    /**\n     * Loaded schema for phpunit instance.\n     *\n     * @var Schema|null\n     */\n    public static $cachedSchema = null;\n\n    protected function setUp()\n    {\n        parent::setUp();\n\n        // Load only once, must be made in setup to be able to use base_path\n        if (null !== $this-\u003eschema) {\n            return;\n        }\n\n        // Load only once per phpunit instance\n        if (null === self::$cachedSchema) {\n            self::$cachedSchema = Schema::getInstance(file_get_contents(base_path('docs/api.json')));\n        }\n\n        // Set the schema\n        $this-\u003esetSchema(self::$cachedSchema);\n    }\n\n    public function testGetUsersWithoutFiltersInElasticSearchAgainstSchema()\n    {\n        // Create data\n        $this-\u003ecreateUser();\n\n        $request = new LaravelRequester($this);\n        $request\n            -\u003ewithMethod('GET')\n            -\u003ewithPath('/v1/users');\n\n        $this-\u003eassertRequest($request);\n    }\n}\n \n``` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpionl%2Flaravel-swagger-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpionl%2Flaravel-swagger-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpionl%2Flaravel-swagger-test/lists"}