{"id":45094278,"url":"https://github.com/appserver-io/restapi","last_synced_at":"2026-02-19T18:09:43.970Z","repository":{"id":62486440,"uuid":"148650536","full_name":"appserver-io/restapi","owner":"appserver-io","description":"Servlet based library that provides basic functionality to implement an API that is compatible with the OpenAPI 2.0 specification.","archived":false,"fork":false,"pushed_at":"2021-05-03T10:28:28.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"2.0.x","last_synced_at":"2024-11-24T17:28:15.063Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/appserver-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-09-13T14:30:17.000Z","updated_at":"2021-02-27T12:46:45.000Z","dependencies_parsed_at":"2022-11-02T10:01:08.833Z","dependency_job_id":null,"html_url":"https://github.com/appserver-io/restapi","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/appserver-io/restapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Frestapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Frestapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Frestapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Frestapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appserver-io","download_url":"https://codeload.github.com/appserver-io/restapi/tar.gz/refs/heads/2.0.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appserver-io%2Frestapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29626892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T18:02:07.722Z","status":"ssl_error","status_checked_at":"2026-02-19T18:01:46.144Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-02-19T18:09:43.399Z","updated_at":"2026-02-19T18:09:43.961Z","avatar_url":"https://github.com/appserver-io.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RESTFul API\n\n[![Latest Stable Version](https://poser.pugx.org/appserver-io/restapi/v/stable.png)](https://packagist.org/packages/appserver-io/restapi)\n [![Total Downloads](https://poser.pugx.org/appserver-io/restapi/downloads.png)](https://packagist.org/packages/appserver-io/restapi)\n [![License](https://poser.pugx.org/appserver-io/restapi/license.png)](https://packagist.org/packages/appserver-io/restapi)\n [![Build Status](https://travis-ci.org/appserver-io/restapi.png)](https://travis-ci.org/appserver-io/restapi)\n [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/appserver-io/restapi/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/appserver-io/restapi/?branch=master)\n [![Code Coverage](https://scrutinizer-ci.com/g/appserver-io/restapi/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/appserver-io/restapi/?branch=master)\n\n## Introduction\n\nRESTFul API provides a simple framework that makes the implemention of a OpenApi 2 (verion 3 is still to come) server pretty simple.\n\nActually the library only supports a subset of the OpenApi 2 functionality, but we'll add additional during the time.\n\n## Installation\n\nIf you want to write an application that uses RESTFul API, you have to install it using Composer. To do this, simply add it to the dependencies in your `composer.json`\n\n```sh\n{\n    \"require\": {\n        \"appserver-io/restapi\": \"~1.0\"\n    }\n}\n```\n\n## Configuration\n\nSimply register the two servlets `AppserverIo\\RestApi\\Servlets\\SwaggerServlet` and `AppserverIo\\RestApi\\Servlets\\ApiServlet` in the `WEB-INF/web.xml` file. The main\ndescription of your webservices can be done through the annotations of Rob Allens library [zircote/swagger-php](https://github.com/zircote/swagger-php/tree/2.x).\n \n### The Servlet Configuration\n\nThe configuration has to be done in the `WEB-INF/web.xml` file as shown in this example\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cweb-app xmlns=\"http://www.appserver.io/appserver\"\u003e\n\n    \u003cdisplay-name\u003emy-api\u003c/display-name\u003e\n    \u003cdescription\u003eMy API web application\u003c/description\u003e\n\n    \u003csession-config\u003e\n        \u003csession-name\u003emy-api/session-name\u003e\n        \u003csession-file-prefix\u003emy-api_session_\u003c/session-file-prefix\u003e\n    \u003c/session-config\u003e\n\n    \u003cservlet\u003e\n        \u003cdescription\u003eA servlet that handles DHTML files.\u003c/description\u003e\n        \u003cdisplay-name\u003eThe DHTML Servlet\u003c/display-name\u003e\n        \u003cservlet-name\u003edhtml\u003c/servlet-name\u003e\n        \u003cservlet-class\u003eAppserverIo\\Appserver\\ServletEngine\\Servlets\\DhtmlServlet\u003c/servlet-class\u003e\n    \u003c/servlet\u003e\n\n    \u003cservlet\u003e\n        \u003cdescription\u003eA servlet that renders the content of the Swagger definition.\u003c/description\u003e\n        \u003cdisplay-name\u003eThe Swgger Servlet\u003c/display-name\u003e\n        \u003cservlet-name\u003eswagger\u003c/servlet-name\u003e\n        \u003cservlet-class\u003eAppserverIo\\RestApi\\Servlets\\SwaggerServlet\u003c/servlet-class\u003e\n    \u003c/servlet\u003e\n\n    \u003cservlet\u003e\n        \u003cdescription\u003eA servlet that handles the RESTFul API requests.\u003c/description\u003e\n        \u003cdisplay-name\u003eThe API Servlet\u003c/display-name\u003e\n        \u003cservlet-name\u003eapi\u003c/servlet-name\u003e\n        \u003cservlet-class\u003eAppserverIo\\RestApi\\Servlets\\ApiServlet\u003c/servlet-class\u003e\n        \u003cbean-ref\u003e\n            \u003cbean-ref-name\u003eRequestHandlerFactory\u003c/bean-ref-name\u003e\n            \u003cbean-link\u003eRequestHandlerFactory\u003c/bean-link\u003e\n            \u003cinjection-target\u003e\n                \u003cinjection-target-class\u003eAppserverIo\\RestApi\\Servlets\\ApiServlet\u003c/injection-target-class\u003e\n                \u003cinjection-target-property\u003erequestHandlerFactory\u003c/injection-target-property\u003e\n            \u003c/injection-target\u003e\n        \u003c/bean-ref\u003e\n        \u003cinit-param\u003e\n          \u003cparam-name\u003eapi\u003c/param-name\u003e\n          \u003cparam-value\u003eOA2\u003c/param-value\u003e\n        \u003c/init-param\u003e\n    \u003c/servlet\u003e\n\n    \u003cservlet-mapping\u003e\n        \u003cservlet-name\u003edhtml\u003c/servlet-name\u003e\n        \u003curl-pattern\u003e*.dhtml\u003c/url-pattern\u003e\n    \u003c/servlet-mapping\u003e\n\n    \u003cservlet-mapping\u003e\n        \u003cservlet-name\u003eswagger\u003c/servlet-name\u003e\n        \u003curl-pattern\u003e/swagger.do\u003c/url-pattern\u003e\n    \u003c/servlet-mapping\u003e\n\n    \u003cservlet-mapping\u003e\n        \u003cservlet-name\u003eapi\u003c/servlet-name\u003e\n        \u003curl-pattern\u003e/api.do\u003c/url-pattern\u003e\n    \u003c/servlet-mapping\u003e\n\n    \u003c!-- ================================================================== --\u003e\n    \u003c!-- Error Page Configuration                                           --\u003e\n    \u003c!-- ================================================================== --\u003e\n\n    \u003cerror-page\u003e\n        \u003cerror-code-pattern\u003e500\u003c/error-code-pattern\u003e\n        \u003cerror-location\u003e/dhtml/500.dhtml\u003c/error-location\u003e\n    \u003c/error-page\u003e\n\n\u003c/web-app\u003e\n```\n\n### Annotate the Beans\n\nAfter the web application has been configured, simple annotate the classes that you want to expose as\nwebserver with the necessary annotations like\n\n```php\n/**\n * A SLSB implementation providing some API functionality.\n *\n * @EPB\\Stateless\n *\n * @SWG\\Info(\n *     title=\"My API\",\n *     version=\"1.0.0\"\n * )\n *\n * @SWG\\Swagger(\n *   schemes={\"http\"},\n *   host=\"127.0.0.1:9080\",\n *   basePath=\"/my-api/api.do\"\n * )\n */\nclass SomeProcessor\n{\n\n    /**\n     * Returns the DTO with the passed ID.\n     *\n     * @param integer $id The ID of the DTO to return\n     *\n     * @return \\Ma\\Api\\Dtos\\MyDto The DTO with the data\n     *\n     * @SWG\\Get(\n     *     path=\"/traveltaxpackages/{id}\",\n     *     operationId=\"find\",\n     *     produces={\"application/json\"},\n     *     @SWG\\Parameter(\n     *         name=\"id\",\n     *         in=\"path\",\n     *         description=\"The ID of the DTO to return\",\n     *         required=true,\n     *         type=\"integer\"\n     *     ),\n     *     @SWG\\Response(\n     *         response=\"200\",\n     *         description=\"The DTO\",\n     *         @SWG\\Schema(\n     *             ref=\"#/definitions/MyDto\"\n     *         )\n     *     )\n     * )\n     */\n    public function find($id)\n    {\n        // return an array with serializable DTOs here\n    }\n}\n```\n\n## Usage\n\nOpen the browser and enter the URL [http://127.0.0.1:9080/my-api/swagger.do](http://127.0.0.1:9080/my-api/swagger.do) which should result in \nrendering the Swagger configuration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappserver-io%2Frestapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappserver-io%2Frestapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappserver-io%2Frestapi/lists"}