https://github.com/scalateams/mill-zio-http-gen
A zio-http-gen plugin for Mill build tool.
https://github.com/scalateams/mill-zio-http-gen
mill mill-module mill-plugin scala zio-http
Last synced: 3 months ago
JSON representation
A zio-http-gen plugin for Mill build tool.
- Host: GitHub
- URL: https://github.com/scalateams/mill-zio-http-gen
- Owner: scalateams
- License: apache-2.0
- Created: 2026-02-05T21:42:33.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-03-05T16:18:35.000Z (3 months ago)
- Last Synced: 2026-03-05T18:41:57.739Z (3 months ago)
- Topics: mill, mill-module, mill-plugin, scala, zio-http
- Language: Scala
- Homepage:
- Size: 86.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mill-zio-http-gen
  [](https://javadoc.io/doc/org.scalateams/mill-zio-http-gen_mill1_3/latest/org.scalateams.mill.zio.http.gen/index.html) [](https://github.com/scala-steward-org/scala-steward) [](https://github.com/scalateams/mill-zio-http-gen)
A [zio-http-gen](https://github.com/zio/zio-http) plugin for Mill build tool.
## Usage
*build.mill*:
```scala
//| mvnDeps:
//| - org.scalateams::mill-zio-http-gen::0.1.2
import mill.scalalib.*
import org.scalateams.mill.zio.http.gen.ZioHttpGenModule
object project extends ScalaModule with ZioHttpGenModule {
def mvnDeps = super.mvnDeps() ++ Seq(mvn"dev.zio::zio-http:3.10.0")
def scalaVersion = "3.3.7"
object openapi extends OpenAPIModule {
def packagePrefix = Task { Seq("com", "example") }
}
}
```
```shell script
> mill project.compile
Generated 2 file(s) from .../openapi/openapi.yaml in package com.example
Compiling compiler interface...
...
done compiling
```
### Overriding default configuration
*build.mill*:
```scala
object openapi extends OpenAPIModule {
import org.scalateams.mill.zio.http.gen.parsers.Parser
import zio.http.gen.openapi.Config
def config = Task { Config.default.copy(commonFieldsOnSuperType = true) }
def packagePrefix = Task { Seq("com", "example") }
def parsers = Task { Map("yaml" -> ParserRef.of[Parser.yaml])
def sources = Task.Sources("openapi")
}
```
### Providing specification dynamically
```scala
object openapi extends OpenAPIModule {
import mill.*
def packagePrefix = Task { Seq("com", "example") }
def specification = Task {
"""openapi: 3.1.0
|info:
| title: User API
| version: 1.0.0
|paths:""".stripMargin
}
def generatedSources = Task {
val content = specification() // think of downloading etc.
os.write.over(Task.dest / Path("openapi.yaml"), content, createFolders = true)
Seq(PathRef(Task.dest))
}
}
```
### Multiple generators
```scala
object project extends ScalaModule with ZioHttpGenModule { self =>
object openapi extends OpenAPIModule {
def packagePrefix = Task { Seq("com", "example") }
}
object openapi_internal extends OpenAPIModule {
import mill.*
def packagePrefix = openapi.packagePrefix() ++ Seq("internal")
def sources = Task.Sources(self.moduleDir / "internal" / "openapi")
}
}
```
## Related projects
* [zio-http](https://github.com/zio/zio-http)
* Inspired by [zio-http-sbt](https://github.com/zio/zio-http-sbt)
## Contributing
Before committing run:
```console
$ ./mill __.style + __.test + __.publishLocal
```
All contributions are welcome!