Commit 3fffff6
authored
* Smithy parser impl (#1522)
* Add Smithy code generator for zio-http Endpoints
Implement SmithyEndpointGen that generates zio-http Endpoint definitions
from Smithy IDL models. This complements the Smithy parser added in the
previous commit.
Features:
- Generate case classes from Smithy structure shapes
- Generate sealed traits from union shapes
- Generate enums from enum shapes
- Generate Endpoint definitions from operations with @http traits
- Support for path parameters (@httpLabel)
- Support for query parameters (@httpQuery)
- Support for header bindings (@HTTPHeader)
- Support for request/response body (@httpPayload)
- Comprehensive type mapping from Smithy to Scala types
Tests: 22 Smithy-specific tests (14 parser + 8 generator)
All 110 zio-http-gen tests pass.
* Add filesystem support for Smithy code generation
Add convenience methods to read and process Smithy files:
- fromString: Parse Smithy IDL string and generate code
- fromFile: Read a single .smithy file and generate code
- fromDirectory: Read all .smithy files from a directory
- generate: Full pipeline from source dir to target dir
- generateFromFile: Full pipeline from single file to target dir
- mergeModels: Combine multiple SmithyModels into one
This allows users to easily integrate Smithy code generation into
their build process by pointing to a directory of .smithy files.
* Add streaming, documentation, and auth trait support
Enhance the Smithy code generator with additional features:
Parser improvements:
- Add @streaming trait for streaming blob payloads
- Add @eventstream trait for event streams
- Add auth traits (@httpBasicAuth, @httpDigestAuth, @httpBearerAuth,
@httpApiKeyAuth, @auth)
- Parse /// doc comments as @documentation traits
Code generation improvements:
- Detect streaming inputs/outputs and set streaming flag
- Extract documentation from @documentation traits
- Use @mediaType trait when available
- Include error documentation in generated endpoints
Tests: 29 Smithy-specific tests, 117 total zio-http-gen tests
* Add comprehensive Smithy model validation
Add SmithyValidation module with:
- Shape reference validation (undefined references)
- HTTP trait validation (methods, status codes, path params)
- Constraint trait validation (@Length, @range, @pattern)
- Operation validation (input/output must be structures)
- Service validation (operations, resources, version)
- Enum and union validation (non-empty, no duplicates)
- 40 new validation tests
Integrate validation into SmithyEndpointGen with optional
validate parameter for all generation methods.
* Add SmithyConfig for code generation options
- Create SmithyConfig with field normalization enabled by default
- Update SmithyEndpointGen to accept and use SmithyConfig
- Add config options: validation, companion objects, endpoints object, etc.
- Add 7 tests for config options (76 total Smithy tests pass)
* Format Smithy code with scalafmt (#1522)
* Apply sbt fmt (#1522)
* Fix unmoored doc comment in Smithy parser (#1522)
* Add comprehensive .smithy example files and tests (#1522)
Add three real-world Smithy IDL example files covering:
- Pet store API with CRUD operations, pagination, enums, validation
- Auth service with bearer tokens, login/logout, user management
- Order service with resources, nested types, money, addresses
Add tests to parse all example files and verify shape extraction.
* Add Alternator support to RichTextCodec | operator (#1522)
Enhance RichTextCodec's | operator to use Alternator typeclass, unifying
same-type alternatives without nested Either types. This matches the
behavior of HttpCodec's | operator.
Changes:
- RichTextCodec: Use Alternator in | operator for type-unified alternatives
- Header.scala: Simplify code by removing unnecessary .transform/.merge
- Add SmithyCodecs with primitive codecs demonstrating the enhancement
- Add SmithyCodecsSpec with 30 tests for the primitive codecs
* Fix Scala 2.12 compatibility for RichTextCodec | operator (#1522)
Wrap dependent-type method references in explicit lambdas for Scala 2.12
compatibility. Add MIMA exclusion for the | method signature change.
* Fix scaladoc error by escaping $ in doc comment (#1522)
* Remove unused zio-parser dependency (#1522)
1 parent db58f27 commit 3fffff6
File tree
20 files changed
+6084
-14
lines changed- project
- zio-http-gen/src
- main/scala/zio/http/gen/smithy
- test
- resources/smithy
- scala/zio/http/gen
- openapi
- scala
- smithy
- zio-http
- jvm/src/test/scala/zio/http/codec
20 files changed
+6084
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
0 commit comments