https://github.com/meetup/sbt-openapi
Plugin for generating managed code from OpenAPI specifications
https://github.com/meetup/sbt-openapi
openapi sbt-plugin
Last synced: 2 months ago
JSON representation
Plugin for generating managed code from OpenAPI specifications
- Host: GitHub
- URL: https://github.com/meetup/sbt-openapi
- Owner: meetup
- License: mit
- Created: 2017-03-08T01:06:01.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-20T22:23:16.000Z (over 3 years ago)
- Last Synced: 2024-04-13T08:11:39.106Z (almost 2 years ago)
- Topics: openapi, sbt-plugin
- Language: Scala
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 26
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sbt-openapi
## Overview
`sbt-openapi` is an sbt plugin that will automatically generate source code from your OpenAPI specifications.
The generated code is managed, which makes it available to your project but does not need to be checked in to your
code repository.
## Usage
### Install the plugin
Add the following code to your `project/plugins.sbt` file:
```
addSbtPlugin("com.meetup" % "sbt-swagger" % "{pluginVersion}" ) // TODO
```
Add the following code to your `build.sbt` file:
```
com.meetup.sbtopenapi.Plugin.openapiSettings
```
### Use the plugin
The current OpenAPI specification is identical to the Swagger 2.0 specification and, as such, the sbt-openapi plugin
is merely a simplified interface to the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) tool.
This plugin treats specification files as providers of [managed source code](http://www.scala-sbt.org/0.13/docs/Classpaths.html#Unmanaged+vs+managed).
Thus, at compile time, the plugin invokes a code generator using a specification file as input, and emits the resulting
code as managed source code. If you merely want to use a code generator to create a standalone library, you are better
off using [swagger-codegen](https://github.com/swagger-api/swagger-codegen) directly.
The plugin uses the on-disk organization of specification files to drive code generation, with specification files
rooted under `src/main/openapi/[generator]/[spec].yaml`. For example, consider this project structure:
```
|
+- src
|
+- main
|
+- openapi
|
+- [generator0]
| |
| +- spec0.yaml
| |
| +- spec1.yaml
|
+- [generator1]
|
+- spec2.yaml
```
Compilation of this project would use result in the plugin generating sources using `generator0` for the specification
files `spec0.yaml` and `spec1.yaml`, and `generator1` for the file `spec2.yaml`.