Play scala - kanuku/misc GitHub Wiki

Best Configuration resource Tut 1
Tut 2
Annotations-documentation
How-to create a Hateos-client
create-play-module
play-http-client
Handling url parameters
play-json

1. Create a new project

$ > activator new tutorial play-scala

2. Include swagger-ui in the project

Checkout swagger-ui project
$ > git clone [email protected]:swagger-api/swagger-ui.git
Copy swagger-ui dist folder to project
$ > cp -r swagger-ui/dist tutorial/public/swagger
Copy the default swagger landing page to the project
$ > cp swagger-ui/dist/index.html tutorial/app/views/swagger.scala.html
Change the swagger landing page tutorial/app/views/swagger.scala.html
# Add this line to the top of the beginning of the file
@import play.api.Play.current
Include swagger-play2 library into the project like this:
...
libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws,
  "com.wordnik"     %% "swagger-play2"       % "1.3.12"
)
...
Open a route to Swagger-api
# Add next line to conf/routes file
GET     /api-docs               controllers.ApiHelpController.getResources

3. Add a new repository endpoint

Create file tutorial/app/controllers/Repository.scala
$ > touch tutorial/app/controllers/Repository.scala
Add this content to the file app/controllers/Repository.scala
Open a route to this new endpoint
# Add next line to conf/routes file
GET   /v1/repositories               controllers.Repository.list
GET   /api-docs/v1/repositories      controllers.ApiHelpController.getResource(path = "/v1/repositories")
Mocking objects

How to mock WS Client from play

play-json

Handling json errors gracefully

Handling default json object
....
(( JsPath \ "commitId" ) Reads.read[String])
and Reads.pure(None)
and Reads.pure("shop-ui")
....