Skip to content

adenza/sbt-openapi-generator

Repository files navigation

sbt-openapi-generator Download Scala CI

This plugin use OpenApi-Generator(ex Swagger) to generate Models and Controllers for REST services

Installation

Step 1: create project/sbt-openapi-generator.sbt with:

resolvers += Resolver.bintrayIvyRepo("adenza", "sbt-plugins")
addSbtPlugin("com.github.adenza" % "sbt-openapi-generator" % "0.2.0")

Configuration

Most configuration settings is similar to CLI commands

Base configuration is based on project module as recommended way to separate generations by modules.

With the next example module generated will be defined

lazy val generated = project.in(file("generated"))
  .settings(
    inConfig(OpenApiCodegen) {
      Seq(
        inputSpec := "openapi.yaml",
        configFile := "config.yaml",
        // outputPath := (baseDirectory in ThisBuild).value + "/generated"
      )
    }
  )

Settings will be picked up from configFile first if defined and then overwritten with module specified settings

There is an auto helpers to redifine boolean settings to make settings more readable:

        validateSpec := SettingDisabled,
        generateModelTests := SettingEnabled,

Execution

To print list of available languages use

sbt openApiGenerators

To run generation process

sbt openApiGenerate

or per module

sbt generated/openApiGenerate

Contribution and Tests

Write plugin integration tests under /src/sbt-test

To run tests execute

sbt scripted

About

OpenApi Generator Sbt Plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages