{"id":22514444,"url":"https://github.com/zrnik/zweist","last_synced_at":"2025-09-08T00:14:19.298Z","repository":{"id":228396112,"uuid":"773715387","full_name":"Zrnik/zweist","owner":"Zrnik","description":"OpenAPI routing for Slim Framework 4 with `zircote/swagger-php`","archived":false,"fork":false,"pushed_at":"2024-04-13T17:30:09.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-14T08:01:46.996Z","etag":null,"topics":["openapi3","php","routing","slim-framework","slim4","swagger-php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zrnik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-03-18T09:15:10.000Z","updated_at":"2024-04-19T18:31:53.615Z","dependencies_parsed_at":"2024-04-02T10:27:47.040Z","dependency_job_id":"67c077dc-166a-4f0a-ad5e-d7d58c43e980","html_url":"https://github.com/Zrnik/zweist","commit_stats":null,"previous_names":["zrnik/zweist"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/Zrnik/zweist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zrnik%2Fzweist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zrnik%2Fzweist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zrnik%2Fzweist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zrnik%2Fzweist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zrnik","download_url":"https://codeload.github.com/Zrnik/zweist/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zrnik%2Fzweist/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274113636,"owners_count":25224450,"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-07T02:00:09.463Z","response_time":67,"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":["openapi3","php","routing","slim-framework","slim4","swagger-php"],"created_at":"2024-12-07T03:17:55.226Z","updated_at":"2025-09-08T00:14:19.277Z","avatar_url":"https://github.com/Zrnik.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zweist\n\n\u003e \"I'm susperd the mountain zweist\" - Lenka Dusilová\n\n### What is this?\n\nThis is a routing tool for `Slim Framework 4` to generate router\nonly by using `zircote/swagger-php` attributes (or maybe annotations,\ndidn't test it) to generate the router.\n\n```\ncomposer require zrnik/zweist\n```\n\n### What do you mean?\n\n#### 1. You annotate your controller methods with the `zircote/swagger-php` attributes\n\n```php\nclass HelloWorldController\n{\n    public function __construct(\n        private readonly \\Zrnik\\Zweist\\Content\\JsonContentFacade $jsonContentFacade,\n    ) {}\n\n    /**\n     * @param array\u003cstring, string\u003e $arguments\n     * @throws JsonException\n     */\n    #[\n        Get(\n            path: '/api/hello/{name:.*}',\n            operationId: 'Say Hello',\n            description: 'says hello by the request parameter',\n        ),\n        Response(\n            response: 200,\n            description: 'when ok',\n            content: new JsonContent(ref: TestResponse::class)\n        ),\n        Middleware(ExampleMiddleware::class),\n    ]\n    public function sayHello(\n        RequestInterface $request,\n        ResponseInterface $response,\n        array $arguments = []\n    ): ResponseInterface\n    {\n        return $this-\u003ejsonContentFacade-\u003eupdateResponse(\n            $response,\n            new TestResponse(\n                sprintf(\n                    'Hello, %s :)',\n                    $arguments['name']\n                )\n            )\n        );\n    }\n}\n```\n\n#### 2. Add `ZweistConfiguration` to your DI.\n\n```php\n$zweistConfiguration = new ZweistConfiguration(\n    \n    // scan paths for openapi attributes (requests \u0026 schemas)\n    [\n        __DIR__ . '/../../Controllers',\n        __DIR__ . '/../../Model',\n    ], \n    \n    // generated (and committed) files\n    __DIR__ . '/openapi.json', \n    __DIR__ .'/router.json', \n);\n```\n\n#### 3. Generate (and commit) `openapi.json` \u0026 `router.json`\n\n```php\n$zweistOpenApiGenerator = $container-\u003eget(ZweistOpenApiGenerator::class);\n$zweistOpenApiGenerator-\u003egenerate();\n```\n\n#### 4. Let `ZweistRouteService` populate routes in the `\\Slim\\App` instance.\n\n```php\n$zweistRouteService = $container-\u003eget(ZweistRouteService::class);\n$zweistRouteService-\u003eapplyRoutes($app);\n```\n\n## More things you should know\n\nYou will need to create a class with `openapi`\ndescription attributes.\n(see [./tests/ExampleApplication/ExampleApplicationInfo.php](./tests/ExampleApplication/ExampleApplicationInfo.php))\n\nYou want to **generate** `openapi.json` and `router.json` locally when developing,\nand then committing them with your code, because you do not want to scan all the files\nfor the router at runtime for every request.\n\nYou should check on the CI that you didn't forget to generate new files.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzrnik%2Fzweist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzrnik%2Fzweist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzrnik%2Fzweist/lists"}