Play Routes

API Builder generates a play routes file to help ensure that a service written using the Play Framework actually implements all of the methods defined by the API.

Within Play, their are a few features we take advantage for type safety of routes:

Bindables for date times

Within the generated clients, you will find an object Bindables that contains implicits to automatically bind date-iso8601 and date-time-iso8601 data types.

Enums as First Class in Routes

enums are represented as first class objects in routes. In order to use this feature, you must use the appropriate imports. This means that if you declare a route in play where the path or a parameter includes an enumeration, we will automatically be able to validate that the value provided is actually appropriate for the enumeration. If the value provided is NOT a valid type, play will return an error page listing the appropriate types.

  1. Import play keys:
          import play.PlayImport.PlayKeys._
  2. Enable plugin:
  3. Update your build.sbt file to include the bindabables:
            routesImport += "<packageName>.<serviceName>.v<versionNumber>.Bindables._"
    for example:
            routesImport += "io.apibuilder.api.v0.Bindables._"

For a real life example, view API Builder's build.sbt file