-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Description
Summary
Add a code generation module (zio-blocks-codegen) providing a generic IR (intermediate representation) ADT for Scala data types and a code emitter that generates Scala source files from it.
Motivation
zio-http currently contains zio-http-gen, which generates Scala code from OpenAPI specifications. However, the core concept — an IR representing Scala types (case classes, sealed traits, objects, enums) and emitting formatted source code — is not HTTP-specific. Multiple generators (OpenAPI → Scala, Smithy → Scala, Protobuf → Scala, JSON Schema → Scala) share the same output concern.
By extracting this into zio-blocks, we enable:
- Reuse across generators (OpenAPI, Smithy, Protobuf, etc.)
- A single, well-tested code emitter
- Consistent code style across all generated code
- Other ZIO ecosystem libraries to leverage codegen without depending on
zio-http
Scope
- IR ADT: Type-safe representation of Scala code structures:
File,Package,ImportCaseClass,SealedTrait,Object,EnumField,Method,TypeRef,AnnotationNewtype(zio-prelude wrapper types)
- Emitter: IR → formatted Scala source string
- Scalafmt integration (optional): Format emitted code
- No domain-specific logic: The IR is generic — OpenAPI-to-IR conversion stays in
zio-http(orzio-blocks-openapi), Smithy-to-IR stays inzio-blocks-smithy, etc.
Related
- Add OpenAPI micro-library #918 — OpenAPI micro-library (consumer of codegen)
- zio-http
zio-http-genmodule — current implementation to extract from - zio-http 4.0 migration: codegen moves from
zio-http→zio-blocks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels