33![ Maven Central Version] ( https://img.shields.io/maven-central/v/dev.rolang/gcp-codegen_3 )
44[ ![ Sonatype Snapshots] ( https://img.shields.io/nexus/s/https/oss.sonatype.org/dev.rolang/gcp-codegen_3.svg?label=Sonatype%20Snapshot )] ( https://oss.sonatype.org/content/repositories/snapshots/dev/rolang/gcp-codegen_3/ )
55
6- Generates client code from Google's [ disovery document] ( https://developers.google.com/discovery/v1/using ) .
7- Currently generates code for Scala 3.
6+ ⚠️ _ This project is in an experimental stage (with a messy code base), use with care if you want to give it a try_ .
7+
8+ Generates client code from Google's [ disovery document] ( https://developers.google.com/discovery/v1/using ) for your Scala (3) tech stack.
9+ Currently it provides following configurations for generated code:
10+ - Http sources: [ Sttp4] ( https://sttp.softwaremill.com/en/latest ) , [ Sttp3] ( https://sttp.softwaremill.com/en/stable )
11+ - JSON codecs: [ Jsoniter] ( https://github.com/plokhotnyuk/jsoniter-scala ) , [ ZioJson] ( https://zio.dev/zio-json )
12+ - JSON Array collection type: ` List ` , ` Vector ` , ` Array ` , ` ZioChunk `
13+
14+ __ NOTE__ : Generated code does not include authentication.
15+
16+ If you're using [ http4s] ( https://github.com/http4s/http4s ) and [ circe] ( https://github.com/circe/circe ) you may also want to check some similar projects:
17+ - [ hamnis/google-discovery-scala] ( https://github.com/hamnis/google-discovery-scala )
18+ - [ armanbilge/gcp4s] ( https://github.com/armanbilge/gcp4s )
819
920### Usage
1021
22+ The generator can be used with any tool that can perform system calls to a command line executable or add Scala 3 dependencies (e.g. [ scala command line] ( https://scala-cli.virtuslab.org/ ) , [ sbt 1] ( https://www.scala-sbt.org/1.x/docs/ ) , [ sbt 2] ( https://www.scala-sbt.org/2.x/docs/en/index.html ) , [ mill] ( https://mill-build.org ) , etc.).
23+
1124#### Usage via Scala command line example
1225See example under [ example/generate.scala] ( ./example/generate.scala ) .
1326
1427``` scala
15- //> using scala 3.6.2
28+ //> using scala 3.6.3
1629//> using dep dev.rolang::gcp-codegen::0.0.1
1730
1831import gcp .codegen .* , java .nio .file .* , GeneratorConfig .*
@@ -22,8 +35,7 @@ import gcp.codegen.*, java.nio.file.*, GeneratorConfig.*
2235 specsInput = SpecsInput .FilePath (Path .of(" pubsub_v1.json" )),
2336 config = GeneratorConfig (
2437 outDir = Path .of(" out" ),
25- resourcesPkg = " example.pubsub.v1.resource" ,
26- schemasPkg = " example.pubsub.v1.schemas" ,
38+ outPkg = " example.pubsub.v1" ,
2739 httpSource = HttpSource .Sttp4 ,
2840 jsonCodec = JsonCodec .Jsoniter ,
2941 dialect = Dialect .Scala3 ,
@@ -35,7 +47,7 @@ import gcp.codegen.*, java.nio.file.*, GeneratorConfig.*
3547```
3648Run example:
3749``` shell
38- cd example && scala generate.scala
50+ cd example && scala generate.scala && scala fmt ./out
3951```
4052See output in ` example/out ` .
4153
@@ -45,14 +57,13 @@ See output in `example/out`.
4557
4658| Configuration | Description | Options | Default |
4759| ------------------- | ---------------- | ------- | --- |
48- | --out-dir | Ouput directory | | |
49- | --specs | Can be ` stdin ` or a path to the JSON file. | | |
50- | --resources-pkg | Target package for generated resources | | |
51- | --schemas-pkg | Target package for generated schemas | | |
52- | --http-source | Generated http source. | [ Sttp4] ( https://sttp.softwaremill.com/en/latest ) , [ Sttp3] ( https://sttp.softwaremill.com/en/stable ) | |
53- | --json-codec | Generated JSON codec | [ Jsoniter] ( https://github.com/plokhotnyuk/jsoniter-scala ) , [ ZioJson] ( https://zio.dev/zio-json ) | |
54- | --array-type | Collection type for JSON arrays | ` List ` , ` Vector ` , ` Array ` , ` ZioChunk ` | ` List ` |
55- | --include-resources | Optional resource filter. | | |
60+ | -specs | Can be ` stdin ` or a path to the JSON file. | | |
61+ | -out-dir | Ouput directory | | |
62+ | -out-pkg | Output package | | |
63+ | -http-source | Generated http source. | [ Sttp4] ( https://sttp.softwaremill.com/en/latest ) , [ Sttp3] ( https://sttp.softwaremill.com/en/stable ) | |
64+ | -json-codec | Generated JSON codec | [ Jsoniter] ( https://github.com/plokhotnyuk/jsoniter-scala ) , [ ZioJson] ( https://zio.dev/zio-json ) | |
65+ | -array-type | Collection type for JSON arrays | ` List ` , ` Vector ` , ` Array ` , ` ZioChunk ` | ` List ` |
66+ | -include-resources | Optional resource filter. | | |
5667
5768##### Examples:
5869
0 commit comments