{"id":15091357,"url":"https://github.com/swagger-api/swagger-play","last_synced_at":"2025-10-06T10:31:09.423Z","repository":{"id":49464234,"uuid":"39423220","full_name":"swagger-api/swagger-play","owner":"swagger-api","description":null,"archived":true,"fork":false,"pushed_at":"2022-09-14T15:32:00.000Z","size":239,"stargazers_count":330,"open_issues_count":99,"forks_count":180,"subscribers_count":46,"default_branch":"master","last_synced_at":"2024-11-14T14:04:25.916Z","etag":null,"topics":["openapi-specification","play-framework","rest","restful-api","swagger","swagger-api"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swagger-api.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}},"created_at":"2015-07-21T04:06:04.000Z","updated_at":"2024-05-17T20:45:51.000Z","dependencies_parsed_at":"2022-08-24T14:39:25.139Z","dependency_job_id":null,"html_url":"https://github.com/swagger-api/swagger-play","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swagger-api%2Fswagger-play","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swagger-api%2Fswagger-play/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swagger-api%2Fswagger-play/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swagger-api%2Fswagger-play/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swagger-api","download_url":"https://codeload.github.com/swagger-api/swagger-play/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235519935,"owners_count":19003201,"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":["openapi-specification","play-framework","rest","restful-api","swagger","swagger-api"],"created_at":"2024-09-25T10:40:33.952Z","updated_at":"2025-10-06T10:31:04.122Z","avatar_url":"https://github.com/swagger-api.png","language":"Java","readme":"# Archived\n\nThis project is no longer supported. \n\n[![Build Status](https://travis-ci.org/swagger-api/swagger-play.svg?branch=master)](https://travis-ci.org/swagger-api/swagger-play)\n\n# Swagger Play2 Module\n\n## Note\n\nThis branch (`master`) holds the latest version (major version `2.x`) for latest play version supported (`2.7`); branch [play-2.6](https://github.com/swagger-api/swagger-play/tree/play-2.6) holds the swagger-play version for play `2.6` version (major.minor version `1.6.x`).\n\nOlder versions are available though not anymore supported in the [archive](https://github.com/swagger-api/swagger-play/tree/archive) branch.\n\n## Overview\n\nThis is a module to support Swagger annotations within [Play Framework](http://www.playframework.org) controllers. It is based on the library https://github.com/swagger-api/swagger-play with several improvements. This library uses Swagger 1.5 and Play 2.7. It can be used for both Scala and Java based applications.\n\nWe also would like to support Swagger 2.0 in the future and contributions to that end will be gladly accepted.\n\n\n### New and Noteworthy\n \n - Minimal dependencies: only depends on the core Play module, so it won't bring unnecessary dependencies on the Akka HTTP server or anything else from Play.\n - `SwaggerPlugin` no longer depends on on `Application`.\n - Correct `Content-Length` generation for JSON (originally proposed in https://github.com/swagger-api/swagger-play/pull/176)\n - No longer uses deprecated Play configuration methods (proposed in https://github.com/swagger-api/swagger-play/pull/162). Also uses `reference.conf` for default values.\n - Clarifies compile-time DI docs (proposed in https://github.com/swagger-api/swagger-play/pull/157)\n - Handle route delegation properly (https://github.com/swagger-api/swagger-play/pull/132 updated for Play 2.6)\n - Add support for `dataTypeClass` in `ApiImplicitParam` (https://github.com/swagger-api/swagger-play/pull/174)\n - Add support for API keys (https://github.com/swagger-api/swagger-play/pull/117)\n - Add support for OAuth2 (https://github.com/swagger-api/swagger-play/pull/183)\n\n## Usage\n\nYou can depend on pre-built libraries in maven central by adding the following dependency:\n\n```\nlibraryDependencies ++= Seq(\n  \"io.swagger\" %% \"swagger-play2\" % \"2.0.1-SNAPSHOT\"\n)\n```\n\nOr you can build from source.\n\n```\nsbt publishLocal\n```\n\n### Adding Swagger to your Play2 app\n\nThere are just a couple steps to integrate your Play2 app with swagger.\n\n1\\. Add the Swagger module to your `application.conf`\n \n```\nplay.modules.enabled += \"play.modules.swagger.SwaggerModule\"\n```\n \n2\\. Add the resource listing to your routes file (you can read more about the resource listing [here](https://github.com/swagger-api/swagger-core/wiki/Resource-Listing))\n\n```\n\nGET     /swagger.json           controllers.ApiHelpController.getResources\n\n```\n\n3\\. Annotate your REST endpoints with Swagger annotations. This allows the Swagger framework to create the [api-declaration](https://github.com/swagger-api/swagger-core/wiki/API-Declaration) automatically!\n\nIn your controller for, say your \"pet\" resource:\n\n```scala\n  @ApiResponses(Array(\n    new ApiResponse(code = 400, message = \"Invalid ID supplied\"),\n    new ApiResponse(code = 404, message = \"Pet not found\")))\n  def getPetById(\n    @ApiParam(value = \"ID of the pet to fetch\") id: String) = Action {\n    implicit request =\u003e\n      petData.getPetbyId(getLong(0, 100000, 0, id)) match {\n        case Some(pet) =\u003e JsonResponse(pet)\n        case _ =\u003e JsonResponse(new value.ApiResponse(404, \"Pet not found\"), 404)\n      }\n  }\n\n```\n\nWhat this does is the following:\n\n* Tells swagger that the methods in this controller should be described under the `/api-docs/pet` path\n\n* The Routes file tells swagger that this API listens to `/{id}`\n\n* Describes the operation as a `GET` with the documentation `Find pet by Id` with more detailed notes `Returns a pet ....`\n\n* Takes the param `id`, which is a datatype `string` and a `path` param\n\n* Returns error codes 400 and 404, with the messages provided\n\nIn the routes file, you then wire this api as follows:\n\n```\nGET     /pet/:id                 controllers.PetApiController.getPetById(id)\n```\n\nThis will \"attach\" the /api-docs/pet api to the swagger resource listing, and the method to the `getPetById` method above\n\nPlease note that the minimum configuration needed to have a route/controller be exposed in swagger declaration is to have an `Api` annotation at class level.\n\n#### The ApiParam annotation\n\nSwagger for play has two types of `ApiParam`s--they are `ApiParam` and `ApiImplicitParam`.  The distinction is that some\nparamaters (variables) are passed to the method implicitly by the framework.  ALL body parameters need to be described\nwith `ApiImplicitParam` annotations.  If they are `queryParam`s or `pathParam`s, you can use `ApiParam` annotations.\n\n\n## application.conf - config options\n```\napi.version (String) - version of API | default: \"beta\"\nswagger.api.basepath (String) - base url | default: \"http://localhost:9000\"\nswagger.filter (String) - classname of swagger filter | default: empty\nswagger.api.info = {\n  contact : (String) - Contact Information | default : empty,\n  description : (String) - Description | default : empty,\n  title : (String) - Title | default : empty,\n  termsOfService : (String) - Terms Of Service | default : empty,\n  license : (String) - Terms Of Service | default : empty,\n  licenseUrl : (String) - Terms Of Service | default : empty\n}\n```\n\n## Note on Dependency Injection\nThis plugin works by default if your application uses Runtime dependency injection.\n\nNevertheless, the plugin can be initialized using compile time dependency injection. For example, you can add the following to your class that extends `BuiltInComponentsFromContext`:\n```\n// This needs to be eagerly instantiated because this sets global state for swagger\nval swaggerPlugin = new SwaggerPluginImpl(environment, configuration)\nlazy val apiHelpController = new ApiHelpController(controllerComponents, swaggerPlugin)\n```\n\n## Security contact\n\nPlease disclose any security-related issues or vulnerabilities by emailing [security@swagger.io](mailto:security@swagger.io), instead of using the public issue tracker.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswagger-api%2Fswagger-play","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswagger-api%2Fswagger-play","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswagger-api%2Fswagger-play/lists"}