What support does lagom provide to create documentation for REST API/services created ? Like Spring has support for Swagger, is there some lagom specific tool/component that we need to use to create the documentation for developers. Can swagger be integrated with Lagom ? Is there an example that I can see and use ?
Lagom REST API documentation
ihostage
(Sergey Morgunov)
#2
Until Lagom does not support integration with Swagger.
And https://github.com/lagom/sbt-lagom-descriptor-generator doesn’t stable.
For our services, we create swagger docs manually and use https://github.com/taymyr/lagom-openapi-java/ for share docs.
vimalmishrra
(Vimal Mishrra)
#3
So if I have to use https://github.com/taymyr/lagom-openapi-java/ to generate documentation for my Lagom REST services, I simply download this code and run it as a lagom service locally ?
ihostage
(Sergey Morgunov)
#4
No, this library does not generate documentation. It just finding it in the classpath and create a route to share it. For example:
- You have a service with name
myservice
. - Add dependencies for api and implementation:
val lagomOpenApiJavaApi = "org.taymyr.lagom" % "lagom-openapi-java-api" % "0.0.2"
val lagomOpenApiJavaImpl = "org.taymyr.lagom" % "lagom-openapi-java-impl" % "0.0.2"
- Add file
myservice.yml
tomyservice-api/src/main/resources/
- Service descriptor must extend interface
OpenAPIService
and use methodwithOpenAPI
for wrap descriptor:
public interface MyService extends OpenAPIService {
@Override
default Descriptor descriptor() {
return withOpenAPI(named("myservice"))
.withCalls(
...
)
.withAutoAcl(true);
}
}
- Service implementation must extend
AbstractOpenAPIService
:
public class MyServiceImpl extends AbstractOpenAPIService implements MyService {
...
}
After, you can get swagger docs by path /_myservice/openapi
and use this route in Swagger UI.