diff --git a/build.sbt b/build.sbt index 94b81903..0ed4f00b 100644 --- a/build.sbt +++ b/build.sbt @@ -16,7 +16,7 @@ lazy val core = project libraryDependencies ++= Seq( "io.higherkindness" %% "mu-rpc-service" % muV, "com.github.julien-truffaut" %% "monocle-core" % "2.1.0", - "io.higherkindness" %% "skeuomorph" % "0.0.25", + "io.higherkindness" %% "skeuomorph" % "0.0.26", "com.julianpeeters" %% "avrohugger-core" % "1.0.0-RC22", "io.circe" %% "circe-generic" % "0.13.0", "org.http4s" %% "http4s-blaze-client" % "0.21.7", diff --git a/core/src/main/scala/higherkindness/mu/rpc/srcgen/Model.scala b/core/src/main/scala/higherkindness/mu/rpc/srcgen/Model.scala index 0f22bb98..b646679b 100644 --- a/core/src/main/scala/higherkindness/mu/rpc/srcgen/Model.scala +++ b/core/src/main/scala/higherkindness/mu/rpc/srcgen/Model.scala @@ -16,66 +16,8 @@ package higherkindness.mu.rpc.srcgen -import higherkindness.mu.rpc.protocol.{SerializationType => SerType, _} -import shapeless.tag -import shapeless.tag.@@ - object Model { - import Toolbox.u._ - - implicit private class StringOps(private val s: String) extends AnyVal { - def trimAll: String = s.replaceAll("\\s", "") - } - - final case class RpcDefinitions( - outputName: String, - outputPackage: Option[String], - options: Seq[RpcOption], - messages: Seq[RpcMessage], - services: Seq[RpcService] - ) - - final case class RpcOption(name: String, value: String) - - final case class RpcMessage(name: String, params: Seq[ValDef]) { - - // Workaround for `Term.Param` using referential equality; needed mostly for unit testing - override def equals(other: Any): Boolean = - other match { - case that: RpcMessage => - this.name == that.name && this.params.map(_.toString.trimAll) == that.params.map( - _.toString.trimAll - ) - case _ => false - } - } - - final case class RpcService( - serializationType: SerType, - name: String, - requests: Seq[RpcRequest] - ) - - final case class RpcRequest( - name: String, - requestType: Tree, - responseType: Tree, - streamingType: Option[StreamingType] = None - ) { - - // Workaround for `Type` using referential equality; needed mostly for unit testing - override def equals(other: Any): Boolean = - other match { - case that: RpcRequest => - this.name == that.name && - this.requestType.toString.trimAll == that.requestType.toString.trimAll && - this.responseType.toString.trimAll == that.responseType.toString.trimAll && - this.streamingType == that.streamingType - case _ => false - } - } - sealed trait ExecutionMode extends Product with Serializable object ExecutionMode { case object Compendium extends ExecutionMode @@ -83,7 +25,6 @@ object Model { } sealed trait IdlType extends Product with Serializable - object IdlType { case object Proto extends IdlType case object Avro extends IdlType @@ -92,7 +33,6 @@ object Model { } sealed trait SerializationType extends Product with Serializable - object SerializationType { case object Protobuf extends SerializationType case object Avro extends SerializationType @@ -131,19 +71,9 @@ object Model { case object ScalaBigDecimalGen extends BigDecimalTypeGen case object ScalaBigDecimalTaggedGen extends BigDecimalTypeGen - sealed abstract class CompressionTypeGen(val value: String) extends Product with Serializable - case object GzipGen extends CompressionTypeGen("Gzip") - case object NoCompressionGen extends CompressionTypeGen("Identity") - - trait UseIdiomaticEndpointsTag - type UseIdiomaticEndpoints = Boolean @@ UseIdiomaticEndpointsTag - - object UseIdiomaticEndpoints { - val trueV = UseIdiomaticEndpoints(true) - - def apply(v: Boolean): UseIdiomaticEndpoints = - tag[UseIdiomaticEndpointsTag][Boolean](v) - } + sealed abstract class CompressionTypeGen extends Product with Serializable + case object GzipGen extends CompressionTypeGen + case object NoCompressionGen extends CompressionTypeGen sealed trait StreamingImplementation case object Fs2Stream extends StreamingImplementation diff --git a/core/src/main/scala/higherkindness/mu/rpc/srcgen/SrcGenApplication.scala b/core/src/main/scala/higherkindness/mu/rpc/srcgen/SrcGenApplication.scala index 9e9a093e..5a549ccd 100644 --- a/core/src/main/scala/higherkindness/mu/rpc/srcgen/SrcGenApplication.scala +++ b/core/src/main/scala/higherkindness/mu/rpc/srcgen/SrcGenApplication.scala @@ -18,40 +18,46 @@ package higherkindness.mu.rpc.srcgen import java.io.File import java.nio.file.Path - -import higherkindness.mu.rpc.srcgen.Model.{ - BigDecimalTypeGen, - CompressionTypeGen, - MarshallersImport, - StreamingImplementation, - UseIdiomaticEndpoints -} +import higherkindness.mu.rpc.srcgen.Model._ import higherkindness.mu.rpc.srcgen.avro.AvroSrcGenerator import higherkindness.mu.rpc.srcgen.openapi.OpenApiSrcGenerator import higherkindness.mu.rpc.srcgen.openapi.OpenApiSrcGenerator.HttpImpl import higherkindness.mu.rpc.srcgen.proto.ProtoSrcGenerator +import higherkindness.skeuomorph.mu.CompressionType object SrcGenApplication { def apply( marshallersImports: List[MarshallersImport], bigDecimalTypeGen: BigDecimalTypeGen, - compressionType: CompressionTypeGen, - useIdiomaticEndpoints: UseIdiomaticEndpoints, + compressionTypeGen: CompressionTypeGen, + useIdiomaticEndpoints: Boolean, streamingImplementation: StreamingImplementation, idlTargetDir: File, resourcesBasePath: Path, httpImpl: HttpImpl - ): GeneratorApplication[SrcGenerator] = + ): GeneratorApplication[SrcGenerator] = { + val compressionType: CompressionType = compressionTypeGen match { + case GzipGen => CompressionType.Gzip + case NoCompressionGen => CompressionType.Identity + } new GeneratorApplication( - ProtoSrcGenerator - .build(compressionType, useIdiomaticEndpoints, streamingImplementation, idlTargetDir), + ProtoSrcGenerator( + streamingImplementation, + idlTargetDir, + compressionType, + useIdiomaticEndpoints + ), AvroSrcGenerator( marshallersImports, bigDecimalTypeGen, compressionType, useIdiomaticEndpoints ), - OpenApiSrcGenerator(httpImpl, resourcesBasePath) + OpenApiSrcGenerator( + httpImpl, + resourcesBasePath + ) ) + } } diff --git a/core/src/main/scala/higherkindness/mu/rpc/srcgen/avro/AvroSrcGenerator.scala b/core/src/main/scala/higherkindness/mu/rpc/srcgen/avro/AvroSrcGenerator.scala index 05b653e5..6fba6587 100644 --- a/core/src/main/scala/higherkindness/mu/rpc/srcgen/avro/AvroSrcGenerator.scala +++ b/core/src/main/scala/higherkindness/mu/rpc/srcgen/avro/AvroSrcGenerator.scala @@ -16,23 +16,23 @@ package higherkindness.mu.rpc.srcgen.avro -import java.io.File - -import scala.collection.JavaConverters._ -import scala.util.Right import avrohugger.Generator import avrohugger.format.Standard import avrohugger.types._ +import cats.implicits._ import higherkindness.mu.rpc.srcgen.Model._ import higherkindness.mu.rpc.srcgen._ +import higherkindness.skeuomorph.mu.CompressionType +import java.io.File import org.apache.avro._ -import cats.implicits._ +import scala.collection.JavaConverters._ +import scala.util.Right final case class AvroSrcGenerator( marshallersImports: List[MarshallersImport], bigDecimalTypeGen: BigDecimalTypeGen, - compressionTypeGen: CompressionTypeGen, - useIdiomaticEndpoints: UseIdiomaticEndpoints + compressionType: CompressionType = CompressionType.Identity, + useIdiomaticEndpoints: Boolean = true ) extends SrcGenerator { private val avroBigDecimal: AvroScalaDecimalType = bigDecimalTypeGen match { @@ -103,6 +103,7 @@ final case class AvroSrcGenerator( }) .map(generateFrom(_, serializationType)) + //TODO: implement this using higherkindness.skeuomorph.mu.Protocol.fromAvroProtocol, as is done in ProtoSrcGenerator def generateFrom( protocol: Protocol, serializationType: SerializationType @@ -130,16 +131,12 @@ final case class AvroSrcGenerator( val messageLines = (schemaLines.tail :+ "").toList - val extraParams = - s"compressionType = ${compressionTypeGen.value}" +: - (if (useIdiomaticEndpoints) { - List( - s"""namespace = Some("${protocol.getNamespace}")""", - "methodNameStyle = Capitalize" - ) - } else Nil) - - val serviceParams = (serializationType.toString +: extraParams).mkString(",") + val serviceParams = Seq( + serializationType.toString, + s"compressionType = $compressionType", + if (useIdiomaticEndpoints) s"""namespace = Some("${protocol.getNamespace}")""" + else "namespace = None" + ).mkString(", ") val requestLines = protocol.getMessages.asScala.toList.flatTraverse { case (name, message) => val comment = Option(message.getDoc).map(doc => s" /** $doc */").toList @@ -153,7 +150,7 @@ final case class AvroSrcGenerator( if (requests.isEmpty) List.empty else { List( - s"@service(${serviceParams}) trait ${protocol.getName}[F[_]] {", + s"@service($serviceParams) trait ${protocol.getName}[F[_]] {", "" ) ++ requests :+ "}" } diff --git a/core/src/main/scala/higherkindness/mu/rpc/srcgen/proto/ProtoSrcGenerator.scala b/core/src/main/scala/higherkindness/mu/rpc/srcgen/proto/ProtoSrcGenerator.scala index 991c30d4..af286445 100644 --- a/core/src/main/scala/higherkindness/mu/rpc/srcgen/proto/ProtoSrcGenerator.scala +++ b/core/src/main/scala/higherkindness/mu/rpc/srcgen/proto/ProtoSrcGenerator.scala @@ -17,26 +17,17 @@ package higherkindness.mu.rpc.srcgen.proto import java.io.File - import scala.meta._ import scala.util.control.NoStackTrace - import cats.effect.{IO, Sync} import cats.syntax.flatMap._ import cats.data.Validated._ - import higherkindness.droste.data.Mu import higherkindness.droste.data.Mu._ import higherkindness.mu.rpc.srcgen.Model._ -import higherkindness.mu.rpc.srcgen.Model.{ - CompressionTypeGen, - GzipGen, - NoCompressionGen, - StreamingImplementation, - UseIdiomaticEndpoints -} import higherkindness.mu.rpc.srcgen._ import higherkindness.skeuomorph.mu.{CompressionType, MuF} +import higherkindness.skeuomorph.{mu => skeuomorph} import higherkindness.skeuomorph.protobuf.ParseProto.{parseProto, ProtoSource} import higherkindness.skeuomorph.protobuf.{ProtobufF, Protocol} @@ -46,11 +37,11 @@ object ProtoSrcGenerator { override def toString: String = s"ProtoBufSrcGenException: $message" } - def build( - compressionTypeGen: CompressionTypeGen, - useIdiomaticEndpoints: UseIdiomaticEndpoints, + def apply( streamingImplementation: StreamingImplementation, - idlTargetDir: File + idlTargetDir: File = new File("."), + compressionType: CompressionType = CompressionType.Identity, + useIdiomaticEndpoints: Boolean = true ): SrcGenerator = new SrcGenerator { @@ -70,24 +61,11 @@ object ProtoSrcGenerator { case MonixObservable => { case (_, a) => t"_root_.monix.reactive.Observable[$a]" } } - val skeuomorphCompression: CompressionType = compressionTypeGen match { - case GzipGen => CompressionType.Gzip - case NoCompressionGen => CompressionType.Identity - } - - val transformToMuProtocol: Protocol[Mu[ProtobufF]] => higherkindness.skeuomorph.mu.Protocol[ - Mu[ - MuF - ] - ] = - higherkindness.skeuomorph.mu.Protocol - .fromProtobufProto(skeuomorphCompression, useIdiomaticEndpoints) + val transformToMuProtocol: Protocol[Mu[ProtobufF]] => skeuomorph.Protocol[Mu[MuF]] = + skeuomorph.Protocol.fromProtobufProto(compressionType, useIdiomaticEndpoints) - val generateScalaSource: higherkindness.skeuomorph.mu.Protocol[Mu[MuF]] => Either[ - String, - String - ] = - higherkindness.skeuomorph.mu.codegen.protocol(_, streamCtor).map(_.syntax) + val generateScalaSource: skeuomorph.Protocol[Mu[MuF]] => Either[String, String] = + skeuomorph.codegen.protocol(_, streamCtor).map(_.syntax) val splitLines: String => List[String] = _.split("\n").toList diff --git a/core/src/test/scala/higherkindness/mu/rpc/srcgen/AvroScalaGeneratorArbitrary.scala b/core/src/test/scala/higherkindness/mu/rpc/srcgen/AvroScalaGeneratorArbitrary.scala index 57bb2fb9..d5811869 100644 --- a/core/src/test/scala/higherkindness/mu/rpc/srcgen/AvroScalaGeneratorArbitrary.scala +++ b/core/src/test/scala/higherkindness/mu/rpc/srcgen/AvroScalaGeneratorArbitrary.scala @@ -18,7 +18,8 @@ package higherkindness.mu.rpc.srcgen import higherkindness.mu.rpc.srcgen.Model.SerializationType._ import higherkindness.mu.rpc.srcgen.Model._ -import org.scalacheck.{Arbitrary, Gen} +import higherkindness.skeuomorph.mu.CompressionType +import org.scalacheck._ trait AvroScalaGeneratorArbitrary { @@ -28,15 +29,15 @@ trait AvroScalaGeneratorArbitrary { expectedOutputFilePath: String, serializationType: SerializationType, marshallersImports: List[MarshallersImport], - compressionTypeGen: CompressionTypeGen, - useIdiomaticEndpoints: UseIdiomaticEndpoints + compressionType: CompressionType, + useIdiomaticEndpoints: Boolean = true ) def generateOutput( serializationType: SerializationType, marshallersImports: List[MarshallersImport], - compressionTypeGen: CompressionTypeGen, - useIdiomaticEndpoints: UseIdiomaticEndpoints + compressionType: CompressionType, + useIdiomaticEndpoints: Boolean = true ): List[String] = { val imports: String = ("import higherkindness.mu.rpc.protocol._" :: marshallersImports @@ -44,12 +45,12 @@ trait AvroScalaGeneratorArbitrary { .map("import " + _)).sorted .mkString("\n") - val serviceParams: Seq[String] = - serializationType.toString :: - s"compressionType = ${compressionTypeGen.value}" :: - List(s"""namespace = Some("foo.bar")""", "methodNameStyle = Capitalize").filter(_ => - useIdiomaticEndpoints - ) + val serviceParams: String = Seq( + serializationType.toString, + s"compressionType = $compressionType", + if (useIdiomaticEndpoints) s"""namespace = Some("foo.bar")""" + else "namespace = None" + ).mkString(", ") s""" |package foo.bar @@ -60,7 +61,7 @@ trait AvroScalaGeneratorArbitrary { | |final case class HelloResponse(arg1: String, arg2: Option[String], arg3: Seq[String]) | - |@service(${serviceParams.mkString(",")}) trait MyGreeterService[F[_]] { + |@service($serviceParams) trait MyGreeterService[F[_]] { | | def sayHelloAvro(arg: foo.bar.HelloRequest): F[foo.bar.HelloResponse] | @@ -103,20 +104,20 @@ trait AvroScalaGeneratorArbitrary { inputResourcePath <- Gen.oneOf("/avro/GreeterService.avpr", "/avro/GreeterService.avdl") serializationType <- Gen.oneOf(Avro, AvroWithSchema, Protobuf, Custom) marshallersImports <- Gen.listOf(marshallersImportGen(serializationType)) - compressionTypeGen <- Gen.oneOf(GzipGen, NoCompressionGen) - useIdiomaticEndpoints <- Arbitrary.arbBool.arbitrary.map(UseIdiomaticEndpoints(_)) + compressionType <- Gen.oneOf(CompressionType.Gzip, CompressionType.Identity) + useIdiomaticEndpoints <- Arbitrary.arbBool.arbitrary } yield Scenario( inputResourcePath, generateOutput( serializationType, marshallersImports, - compressionTypeGen, + compressionType, useIdiomaticEndpoints ), "foo/bar/MyGreeterService.scala", serializationType, marshallersImports, - compressionTypeGen, + compressionType, useIdiomaticEndpoints ) } diff --git a/core/src/test/scala/higherkindness/mu/rpc/srcgen/AvroSrcGenTests.scala b/core/src/test/scala/higherkindness/mu/rpc/srcgen/AvroSrcGenTests.scala index 765296e9..3953c632 100644 --- a/core/src/test/scala/higherkindness/mu/rpc/srcgen/AvroSrcGenTests.scala +++ b/core/src/test/scala/higherkindness/mu/rpc/srcgen/AvroSrcGenTests.scala @@ -18,22 +18,17 @@ package higherkindness.mu.rpc.srcgen import cats.data.Validated import cats.data.Validated.Valid - -import scala.io._ import higherkindness.mu.rpc.srcgen.AvroScalaGeneratorArbitrary._ import higherkindness.mu.rpc.srcgen.Model.SerializationType.Avro -import higherkindness.mu.rpc.srcgen.Model.{ - BigDecimalAvroMarshallers, - NoCompressionGen, - ScalaBigDecimalTaggedGen, - UseIdiomaticEndpoints -} +import higherkindness.mu.rpc.srcgen.Model._ import higherkindness.mu.rpc.srcgen.avro._ +import higherkindness.skeuomorph.mu.CompressionType import org.scalacheck.Prop.forAll import org.scalatest._ import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec import org.scalatestplus.scalacheck.Checkers +import scala.io._ class AvroSrcGenTests extends AnyWordSpec with Matchers with OneInstancePerTest with Checkers { @@ -50,8 +45,7 @@ class AvroSrcGenTests extends AnyWordSpec with Matchers with OneInstancePerTest AvroSrcGenerator( List(BigDecimalAvroMarshallers), ScalaBigDecimalTaggedGen, - NoCompressionGen, - UseIdiomaticEndpoints.trueV + CompressionType.Identity ).generateFrom( Source.fromInputStream(getClass.getResourceAsStream("/avro/Invalid.avdl")).mkString, Avro @@ -74,7 +68,7 @@ class AvroSrcGenTests extends AnyWordSpec with Matchers with OneInstancePerTest AvroSrcGenerator( scenario.marshallersImports, ScalaBigDecimalTaggedGen, - scenario.compressionTypeGen, + scenario.compressionType, scenario.useIdiomaticEndpoints ).generateFrom( Source.fromInputStream(getClass.getResourceAsStream(scenario.inputResourcePath)).mkString, diff --git a/core/src/test/scala/higherkindness/mu/rpc/srcgen/ProtoSrcGenTests.scala b/core/src/test/scala/higherkindness/mu/rpc/srcgen/ProtoSrcGenTests.scala index 87745616..17e70327 100644 --- a/core/src/test/scala/higherkindness/mu/rpc/srcgen/ProtoSrcGenTests.scala +++ b/core/src/test/scala/higherkindness/mu/rpc/srcgen/ProtoSrcGenTests.scala @@ -17,14 +17,7 @@ package higherkindness.mu.rpc.srcgen import java.io.File - -import higherkindness.mu.rpc.srcgen.Model.{ - Fs2Stream, - MonixObservable, - NoCompressionGen, - SerializationType, - UseIdiomaticEndpoints -} +import higherkindness.mu.rpc.srcgen.Model._ import higherkindness.mu.rpc.srcgen.proto.ProtoSrcGenerator import higherkindness.skeuomorph.ProtobufCompilationException import org.scalatest._ @@ -41,8 +34,7 @@ class ProtoSrcGenTests extends AnyWordSpec with Matchers with OneInstancePerTest "generate the expected Scala code (FS2 stream)" in { val result: Option[(String, String)] = - ProtoSrcGenerator - .build(NoCompressionGen, UseIdiomaticEndpoints(false), Fs2Stream, new java.io.File(".")) + ProtoSrcGenerator(Fs2Stream) .generateFrom( files = Set(protoFile("book")), serializationType = SerializationType.Protobuf @@ -56,13 +48,7 @@ class ProtoSrcGenTests extends AnyWordSpec with Matchers with OneInstancePerTest "generate the expected Scala code (Monix Observable)" in { val result: Option[(String, String)] = - ProtoSrcGenerator - .build( - NoCompressionGen, - UseIdiomaticEndpoints(false), - MonixObservable, - new java.io.File(".") - ) + ProtoSrcGenerator(MonixObservable) .generateFrom( files = Set(protoFile("book")), serializationType = SerializationType.Protobuf @@ -78,13 +64,7 @@ class ProtoSrcGenTests extends AnyWordSpec with Matchers with OneInstancePerTest "throw an exception on an invalid Protobuf schema" in { assertThrows[ProtobufCompilationException] { - ProtoSrcGenerator - .build( - NoCompressionGen, - UseIdiomaticEndpoints(false), - MonixObservable, - new java.io.File(".") - ) + ProtoSrcGenerator(MonixObservable) .generateFrom( files = Set(protoFile("broken")), serializationType = SerializationType.Protobuf @@ -146,7 +126,7 @@ class ProtoSrcGenTests extends AnyWordSpec with Matchers with OneInstancePerTest | val values = findValues |} | - |@service(Protobuf, Identity) trait BookService[F[_]] { + |@service(Protobuf, compressionType=Identity, namespace=Some("com.proto")) trait BookService[F[_]] { | def GetBook(req: _root_.com.proto.book.GetBookRequest): F[_root_.com.proto.book.Book] | def GetBooksViaAuthor(req: _root_.com.proto.book.GetBookViaAuthor): F[${streamOf( "_root_.com.proto.book.Book" diff --git a/docs/README.md b/docs/README.md index 5c1e5948..e47cdfa6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,9 @@ +[comment]: <> (Don't edit this file!) +[comment]: <> (It is automatically updated after every release of https://github.com/47degrees/.github) +[comment]: <> (If you want to suggest a change, please open a PR or issue in that repository) -[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/higherkindness/mu-scala/master/LICENSE) [![Join the chat at https://gitter.im/47deg/mu](https://badges.gitter.im/47deg/mu.svg)](https://gitter.im/47deg/mu?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/higherkindness/mu-scala/master/LICENSE) +[![Join the chat at https://gitter.im/47deg/mu](https://badges.gitter.im/47deg/mu.svg)](https://gitter.im/47deg/mu?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) # @NAME@ @@ -11,24 +15,23 @@ For installing this plugin, add the following line to your `plugins.sbt` file: -```scala +```sbt mdoc:silent addSbtPlugin("io.higherkindness" % "sbt-mu-srcgen" % "@VERSION@") ``` + ### NOTE For any users using version `0.22.x` and below, the `SrcGenPlugin` is enabled on every module by default. However, for everyone using -version `0.23.x` and beyond (the latest version), you'll need to manually enable the plugin for any module for which you want to +version `0.23.x` and beyond, you'll need to manually enable the plugin for any module for which you want to auto-generate [mu-scala] code, like such: -```scala +```sbt mdoc:silent .enablePlugins(SrcGenPlugin) ``` -**this is a breaking change between the versions**, so be sure to make sure that you're choosing your modules to enable source generation +**This is a breaking change between the versions**, so be sure to make sure that you're choosing your modules to enable source generation intentionally if you want to upgrade this library. - - The full documentation is available at the [mu](https://higherkindness.io/mu-scala/guides/generate-sources-from-idl) site. [RPC]: https://en.wikipedia.org/wiki/Remote_procedure_call diff --git a/plugin/src/main/scala/higherkindness/mu/rpc/srcgen/SrcGenPlugin.scala b/plugin/src/main/scala/higherkindness/mu/rpc/srcgen/SrcGenPlugin.scala index 7f6e7755..96172fda 100644 --- a/plugin/src/main/scala/higherkindness/mu/rpc/srcgen/SrcGenPlugin.scala +++ b/plugin/src/main/scala/higherkindness/mu/rpc/srcgen/SrcGenPlugin.scala @@ -93,7 +93,7 @@ object SrcGenPlugin extends AutoPlugin { lazy val muSrcGenIdiomaticEndpoints: SettingKey[Boolean] = settingKey[Boolean]( "If `true`, the gRPC endpoints generated in the services generated from idls will contain the " + - "namespace as prefix and their method names will be capitalized. `false` by default." + "namespace as prefix. `true` by default." ) lazy val muSrcGenOpenApiHttpImpl: SettingKey[HttpImpl] = @@ -155,7 +155,7 @@ object SrcGenPlugin extends AutoPlugin { } }, muSrcGenCompressionType := NoCompressionGen, - muSrcGenIdiomaticEndpoints := false, + muSrcGenIdiomaticEndpoints := true, muSrcGenOpenApiHttpImpl := HttpImpl.Http4sV20, muSrcGenStreamingImplementation := Fs2Stream, muSrcGenExecutionMode := Local, @@ -210,7 +210,7 @@ object SrcGenPlugin extends AutoPlugin { muSrcGenMarshallerImports.value, muSrcGenBigDecimal.value, muSrcGenCompressionType.value, - UseIdiomaticEndpoints(muSrcGenIdiomaticEndpoints.value), + muSrcGenIdiomaticEndpoints.value, muSrcGenStreamingImplementation.value, muSrcGenIdlTargetDir.value, (Compile / resourceManaged).value.toPath, diff --git a/plugin/src/sbt-test/sbt-mu-srcgen/idiomaticEndpoints/test b/plugin/src/sbt-test/sbt-mu-srcgen/idiomaticEndpoints/test index 5bdcac6c..aabe0ea7 100644 --- a/plugin/src/sbt-test/sbt-mu-srcgen/idiomaticEndpoints/test +++ b/plugin/src/sbt-test/sbt-mu-srcgen/idiomaticEndpoints/test @@ -9,7 +9,7 @@ $ delete target/scala-2.12/src_managed/main/io/higherkindness/MyService.scala $ exists src/main/resources/service.avdl > 'set muSrcGenIdlType := higherkindness.mu.rpc.srcgen.Model.IdlType.Avro' > 'set muSrcGenSerializationType := higherkindness.mu.rpc.srcgen.Model.SerializationType.AvroWithSchema' -> 'set muSrcGenIdiomaticEndpoints := true' +> 'set muSrcGenIdiomaticEndpoints := false' > muSrcGen $ exists target/scala-2.12/src_managed/main/io/higherkindness/MyService.scala > compile