Skip to content

Commit 5855e39

Browse files
committed
Update Docs
1 parent a515a78 commit 5855e39

2 files changed

Lines changed: 110 additions & 57 deletions

File tree

docs/plugins.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,56 @@ openApiGenerate {
120120
```
121121
122122
*If you want to create separate tasks (for example when you have more than one api spec and require different parameters for each), this is how to do so in Gradle 7+: `tasks.register('taskName', org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { ... }`.*
123+
124+
## Mill
125+
126+
This Mill library provides a Mill module that can be used to generate code from OpenAPI specifications.
127+
128+
### Example
129+
130+
```scala
131+
//| mill-version: 1.0.6
132+
//| mvnDeps:
133+
//| - org.openapitools:openapi-generator-mill-plugin:7.19.0 # 1.
134+
135+
import mill.*
136+
137+
import org.openapitools.generator.mill.OpenApiModule // 2.
138+
139+
object `package` extends JavaModule with MavenModule with OpenApiModule { // 3.
140+
141+
// other Mill config...
142+
143+
object openapi extends OpenApiConfig { // 4.
144+
def inputSpec: T[PathRef] = Task.Source(BuildCtx.workspaceRoot / "api" / "petstore.yaml")
145+
// other config options...
146+
}
147+
148+
override def generatedSources: T[Seq[PathRef]] = Seq(
149+
PathRef(Task.dest),
150+
openapi.generate(), // 5.
151+
)
152+
}
153+
```
154+
155+
1. Add the plugin to your `build.mill` as `mvnDeps` in the header section
156+
2. import `org.openapitools.generator.mill.OpenApiModule`
157+
3. add `OpenApiModule` to the module definition
158+
4. configure 1-n `OpenApiConfig` as sub-modules
159+
5. run the generation as part of the `compile` task
160+
161+
This gives access to the following tasks:
162+
163+
| Task | Description |
164+
|---------------------------|---------------------------------------------------------------------------------------------|
165+
| <configName>.generate | Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents. |
166+
| <configName>.validateSpec | Validates the configured spec |
167+
168+
and a command
169+
170+
| Command | Description |
171+
|---------------------|------------------------------------------------|
172+
| validateOpenapiSpec | Takes the path to a spec file and validates it |
173+
174+
175+
For full details of all options, see the [plugin README](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-mill-plugin).

0 commit comments

Comments
 (0)