https://github.com/mikybars/openapi-generator-mill-plugin
Simple Mill plugin for generating source files from an OpenApi spec
https://github.com/mikybars/openapi-generator-mill-plugin
mill-plugin openapi
Last synced: about 1 month ago
JSON representation
Simple Mill plugin for generating source files from an OpenApi spec
- Host: GitHub
- URL: https://github.com/mikybars/openapi-generator-mill-plugin
- Owner: mikybars
- Created: 2025-08-04T16:32:29.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-11T07:20:43.000Z (10 months ago)
- Last Synced: 2026-03-29T21:42:41.575Z (3 months ago)
- Topics: mill-plugin, openapi
- Language: Shell
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 0
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: readme.adoc
Awesome Lists containing this project
README
= OpenApi
Simple https://mill-build.org/[Mill] plugin for generating source files from an https://www.openapis.org/[OpenApi] spec.
Just extend `OpenApiModule` and declare an `OpenApiConfig` object
.`build.mill`
[source,scala]
----
//| mill-version: 1.0.2
//| mvnDeps: ["io.github.mikybars::openapi-generator-mill-plugin::0.1.0"]
package build
import mill._, scalalib._
import mill.api.BuildCtx
import io.github.mikybars.mill.openapi.OpenApiModule
object foo extends JavaModule, OpenApiModule {
object openapi extends OpenApiConfig {
def inputSpec = Task.Source(BuildCtx.workspaceRoot / "api/rest/v1/openapi.yml")
def apiPackage: T[String] = "com.example.foo.rest.api"
def modelPackage: T[String] = "com.example.foo.rest.model"
def generatorName: T[String] = "spring"
def modelNameSuffix: T[String] = "Dto"
def additionalProperties: T[Map[String, String]] = Map(
// ...
"useSpringBoot3" -> "true",
// ...
)
}
}
----
Then
[source,console]
----
$ ./mill foo.openapi.generate
----
Alternatively, if you'd like to hook up the `generate` task into the Mill build process, just override the `generatedSources` builtin task:
`build.mill`
[source,scala]
----
object foo extends JavaModule, OpenApiModule {
object openapi extends OpenApiConfig
// ...
override def generatedSources: T[Seq[PathRef]] = Seq(
PathRef(Task.dest),
openapi.generate()
)}
}
----
And then
[source,console]
----
$ ./mill foo.compile # or foo.run, foo.test ...
----
With the above configuration, source files will be output into the `out/foo/openapi/generate.dest` folder.