-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
110 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Generate endpoint definitions from an OpenAPI YAML | ||
|
||
```eval_rst | ||
.. note:: | ||
This is a really early alpha implementation. | ||
``` | ||
|
||
## Installation steps | ||
|
||
Add the sbt plugin to the `project/plugins.sbt`: | ||
|
||
```scala | ||
addSbtPlugin("com.softwaremill.sttp.tapir" % "sbt-openapi-codegen" % "0.17.0-M11") | ||
``` | ||
|
||
Enable the plugin for your project in the `build.sbt`: | ||
|
||
```scala | ||
enablePlugins(OpenapiCodegenPlugin) | ||
``` | ||
|
||
Add your OpenApi file to the project, and override the `openapiSwaggerFile` setting in the `build.sbt`: | ||
|
||
```scala | ||
openapiSwaggerFile := baseDirectory.value / "swagger.yaml" | ||
``` | ||
|
||
At this point your compile step will try to generate the endpoint definitions | ||
to the `sttp.tapir.generated.TapirGeneratedEndpoints` object, where you can access the | ||
defined case-classes and endpoint definitions. | ||
|
||
## Usage and options | ||
|
||
The generator currently supports these settings, you can override them in the `build.sbt`; | ||
|
||
| setting | default value | description | | ||
|---|---|---| | ||
| openapiSwaggerFile | baseDirectory.value / "swagger.yaml" | The swagger file with the api definitions. | | ||
| openapiPackage | sttp.tapir.generated | The name for the generated package. | | ||
| openapiObject | TapirGeneratedEndpoints | The name for the generated object. | | ||
|
||
The general usage is; | ||
|
||
```scala | ||
import sttp.tapir.generated._ | ||
import sttp.tapir.docs.openapi._ | ||
import sttp.tapir.openapi.circe.yaml._ | ||
|
||
val docs = TapirGeneratedEndpoints.generatedEndpoints.toOpenAPI("My Bookshop", "1.0") | ||
``` | ||
|
||
### Limitations | ||
|
||
Currently, the generated code depends on `"io.circe" %% "circe-generic"`. In the future probably we will make the encoder/decoder json lib configurable (PRs welcome). | ||
|
||
We currently miss a lot of OpenApi features like: | ||
- tags | ||
- enums/ADTs | ||
- missing model types and meta descriptions (like date, minLength) | ||
- file handling | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
sphinx_rtd_theme==0.4.3 | ||
recommonmark==0.5.0 | ||
sphinx==2.0.1 | ||
sphinx-autobuild==0.7.1 | ||
sphinx-autobuild==0.7.1 | ||
sphinx-markdown-tables==0.0.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters