Pet store application to demonstrate OpenAPI support in Lagom.
A Lagom port of the famous Open API Pet Store example. The relevant contents are:
./build.sbt
./petService
./petService/src/main/openapi/petService.json
./petService/src/main/java/com/example/pet/impl/
./storeService
./storeService/src/main/openapi/storeService.json
./petService/src/main/scala/com/example/store/impl/
./web
./web/src/main/java/controllers
./web/src/main/java/Module.java
./web/src/main/openapi
./web/src/main/openapi/petService.json
./web/src/main/openapi/storeService.json
./web/src/main/...
./build.sbt
: in the project build we include theLagomOpenApiPlugin
on a project to make it scan itssrc/main/openapi
forjson
oryaml
files. The detected files are then converted into source code managed bysbt
You can inspect the genreated code browsing thetarget/scala-2.11/openapi/
folder. Any code undertarget/
will be overwriten in future compilations and should not be edited or committed. Note that there's nopetService-api
separate frompetService
, this is just a convenience approach assuming that onlypetService.json
will be shared with consumers../petService
: a Lagom service implemented in java. Once the code is compiled aPetserviceApi.java
file exists with the Lagom descriptor. We can then work on the implementation normally (seePetServiceImpl.java
)../petService/src/main/openapi/petService.json
: an OpenAPI specification of the pet service../petService/src/main/java/com/example/pet/impl/
: the lagom implementation of the specification. This is an in-memory hardcoded service to keep the source code to a minimum../storeService
: a Lagom service implemented in scala../storeService/src/main/openapi/storeService.json
: an OpenAPI specification of the store service../web
: a Play application using the Java API that will consume both pet service and store service../web/src/main/java/Module.java
: using the Play Guice DI API we bind the clients to consume the Lagom services../web/src/main/openapi
: contains copies of the swagger specifications of the services it wants to consume.