lagom / sbt-lagom-descriptor-generator

Lagom API code generator
Apache License 2.0
23 stars 12 forks source link
grpc lagom openapi

Build Status

sbt-lagom-descriptor-generator

An sbt plugin to generate Lagom Service Descriptor code (and related entities) provided a Swagger/OpenAPI specification.

Usage

Include the plugin dependency on your project/plugins.sbt file:

addSbtPlugin("com.lightbend.lagom" % "lagom-descriptor-generator-sbt-plugin" % "0.0.2")

and enable the plugin on your project in build.sbt:

lazy val ``service-api = (project in file("service-api"))
  .enablePlugins(LagomJava && LagomOpenApiPlugin)
  .settings(
    libraryDependencies ++=
      Seq(
        lagomJavadslApi
      )
  )

The plugin will trigger the Java or Scala code generation depending on the dependencies included in your code.

Project Status

DISCLAIMER Currently the build job in Travis fails. Solve #20 to fix that.

This plugin is not ready for production. It currently works in most happy scenarios when given one or many JSON or YAML OpenAPI V2 specification files. There is a minimal set of scripted tests (1, 2, 3) demonstrating the basic functionality available.

Project Structure

This project provides an sbt plugin that will generate the Lagom Service Descriptor given a 3rd party API specification. It works by detecting the dependency of the project on Lagom and also the Java vs Scala API. Once the plugin is activated it will locate all 3rd party specification files and proceed with the code genreations.

Supported Specs

OpenAPI V2 placing JSON or YAML OpenAPI V2 files in a project's src/main/openapi will generate the required code to represent that spec using Lagom code. See the scripted tests for an example.

Supporting new spec formats would require:

Contributions & Maintainers

This project does not have contributors, it only has maintainers—frequent and infrequent—and everyone helps out. This repo loves new maintainers as well as old maintainers. :-) The Lagom core team keeps an eye on the project to assure its overall coherence but does not fully support this sbt plugin.

Contributions are very welcome, see CONTRIBUTING.md or skim existing tickets to see where you could help out.