Skip to content

Commit

Permalink
Updates docs for ScalaPB Validation (#1518)
Browse files Browse the repository at this point in the history
* Updates docs for ScalaPB Validation

* Adds explanation about how to enable the validation

* Apply suggestions from code review

Co-authored-by: Francisco Diaz <francisco.d@47deg.com>

Co-authored-by: Francisco Diaz <francisco.d@47deg.com>
  • Loading branch information
fedefernandez and franciscodr committed Oct 18, 2022
1 parent 02b9fb1 commit ccf1e1a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions microsite/src/main/docs/reference/source-generation.md
Expand Up @@ -81,6 +81,7 @@ muSrcGenSerializationType := SerializationType.Protobuf // or SerializationType.
| `muSrcGenCompressionType` | The compression type that will be used by generated RPC services. Set to `higherkindness.mu.rpc.srcgen.Model.GzipGen` for Gzip compression. | `higherkindness.mu.rpc.srcgen.Model.NoCompressionGen` |
| `muSrcGenIdiomaticEndpoints` | Flag indicating if idiomatic gRPC endpoints should be used. If `true`, the service operations will be prefixed by the namespace. | `true` |
| `muSrcGenProtocVersion` | Specifies the protoc version that [ScalaPB](https://scalapb.github.io/) should use when generating source files from proto files. | `None` (let ScalaPB choose the protoc version) |
| `muSrcGenValidateProto` | Flag indicating if the plugin should generate validation methods based on rules and constraints defined in the specs. Only proto is supported at this moment. | `false` |

### muSrcGenJarNames

Expand Down Expand Up @@ -109,6 +110,32 @@ sbt module containing the IDL definitions (`foo-domain`):
//...
```

### muSrcGenValidateProto

The sbt-mu-srcgen supports the plugin [scalapb-validate](https://github.com/scalapb/scalapb-validate).
This plugin generates validators for your models, using the base validators defined by the [PGV protoc plugin](https://github.com/envoyproxy/protoc-gen-validate)

As you probably guessed, this is only compatible with proto and the setting will be ignored when working with Avro files.

To enable the validation methods generation, you need to set the setting `muSrcGenValidateProto` to true and
import the PVG validators provided transitively by the `scalapb-validate-core` protobuf library:

```
//...
.settings(
Seq(
muSrcGenIdlType := IdlType.Proto,
muSrcGenTargetDir := (Compile / sourceManaged).value / "compiled_proto",
muSrcGenValidateProto := true,
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %% "scalapb-validate-core" % scalapb.validate.compiler.BuildInfo.version % "protobuf",
"io.higherkindness" %% "mu-rpc-service" % V.muRPC
)
)
)
//...
```

## Implementation Notes: An Intentional Incompatibility with the Avro Standard

In order to make it easier for users to evolve their schemas over time,
Expand Down

0 comments on commit ccf1e1a

Please sign in to comment.