Scout24/sbt-swagger-codegen

Name: sbt-swagger-codegen

Owner: AutoScout24

Owner: AutoScout24

Description: sbt Plugin for Scala code generation for Swagger specs

Forked from: unicredit/sbt-swagger-codegen

Created: 2016-10-21 15:21:38.0

Updated: 2016-11-28 10:51:03.0

Pushed: 2017-04-03 13:15:23.0

Homepage:

Size: 184

Language: Scala

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

SBT Swagger Code Generator

Overview

Like the official swagger-codegen this project aims to generate Scala source code from Swagger Specification compliant API descriptions. Moreover, you can do it directly within an sbt project.

Compatibility

This code generator is designed specifically for Swagger Spec Version 2.0. Moreover, it relies on Play! Framework 2.5 for Json marshalling/unmarshalling, server- and client-side code.

Install

Enable it inside your project\plugins.sbt like this:

addSbtPlugin("eu.unicredit" % "sbt-swagger-codegen" % "0.0.9")

Enable it in your build.sbt like this:

enablePlugins(SwaggerCodegenPlugin)

Quick start

For a super fast hands-on tutorial refer to the related examples and check out sbt-swagger-codegen-examples.

How it works

By default, the plugin will assume that you have put your yaml Swagger specification files under src/main/swagger.

If so, then you can just run swaggerCodeGen and it will generate your model's as case classes under src/main/scala/swagger/codegen and Play Framework Formats for them (for json serialization) under src/main/scala/swagger/codegen/json.

Tasks

All available tasks from the plugin

The swaggerModelCodeGen, swaggerServerCodeGen and swaggerClientCodeGen will run automatically when the swagger sources change.

swaggerRoutesCodeGen will not run automatically because it generates code inside the “src/main/resources” directory instead of in “target/scala-2.12/src_managed”.

Tasks can be chained with other tasks (ex: `(compile in Compile) <<= (compile in Compile) dependsOn swaggerRoutesCodeGen`)

 Keys (and defaults)

These keys influence properties of the generated code itself:

These keys determine where generated files will be put:

These keys can be used to determine what kind of code should be generated:

Moreover, you can extend this plugin by providing alternative implementations of the generators via:

Dependencies
Limitations

At the moment the project is developed to fullfill some internal projects needs, so do not expect it to cover all the corner cases of the Swagger Spec (i.e. some primitive types in body req or resp). Model objects must have less than 22 parameters and could fail with circular referencies(due to the Play Json macro limitaion).

The road ahead

We are actively working with and on this project, trying to overcome any arising limitations and support all Swagger-spec properties we need. PRs are really welcome and please open an Issue if you find that something is not working.

Authors:

This is a work in progress and we are not done with it!


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.