Published by ghik about 6 years ago
Changes in REST framework:
application/x-www-form-urlencoded
through @FormBody
annotation on REST methodsOpenApi
now supports arbitrary JSON values for default values in schemas, enums and examples@whenAbsent
annotation on method parameters and case class parameters are included into generated OpenAPI documents@example
annotation for REST parameters to define example values later included into OpenAPI documentOther changes:
MacroGenerated
now accepts typed companion which may inject implicits into macro materializationApplier
and Unapplier
typeclasses@reifyAnnot
and @reifyEncodedAnnot
can accept parameters annotated as @infer
which will be inferred by macro engine as implicitsPublished by ghik about 6 years ago
Changes in REST framework:
DefaultRestApiCompanion
and DefaultRestServerApiCompanion
require materialization of OpenApiMetadata
which requires RestSchema
instances for data types used in REST API traits.204 No Content
status code is used for empty responses instead of 200 OK
.Changes in RPC macro engine:
meta
package from rpc
package and renamed some of them@annotated[A]
filtering meta-annotation for RPC methods and parameters@rpcMethodMetadata
, @rpcParamMetadata
, @adtCaseMetadata
and @adtParamMetadata
meta-annotationsOther changes:
JsonOptions
now aggregates some of its fields in JsonFormatting
object, added afterColon
formatting optioncommons-annotations
module now depends on commons-macros
SharedExtensions
Primary motivation for this release is RPC based REST framework
The biggest breaking change is change of serialization format used by GenCodec
for Option
- migrate carefully!
Changes in RPC framework itself (mostly inspired or needed by REST framework):
@composite
@multi
raw methods. Now it can appear anywhere in the raw method signature but it must be explicitly marked as @methodName
. It may also be inside a @composite
parameter.@methodTag
and @paramTag
now accept default tag value instead of type. This value is injected as effective annotation on real methods/params so there's no need to worry about default tags in annotation processing.@tagged
now accepts whenUntagged
parameter containing tag value assumed when real method/param is untagged. This fallback tag value is also injected as effective annotation on real method/param.@rpcNamePrefix
which may be aggregated by method/param tags to effectively allow overloading RPC methods as long as they have different tags.@tried
- raw method annotation which causes results of real methods to be automatically wrapped into Try
. This catches possible exceptions thrown by real methods and makes it possible to handle them during serialization to raw values.@transientDefault
on RPC method parametersRPCFramework
(legacy RPC) now accept a single RawInvocation
parameter that aggregates method name and argument list.Changes in annotation processing:
@defaultsToName
meta-annotation for String
-typed annotation parameters.Changes in serialization (mostly breaking, #74):
Option
no longer serializes to a list - it uses the same format as Opt
, i.e. None
is represented as null
and Some(null)
is indistinguishable from None
- it will deserialize as None
. Input
and Output
implementations may fall back to the old list-based format by overriding legacyOptionEncoding
method.JsonStringInput
and JsonStringOutput
now accept JsonOptions
- #66. Default serialization of timestamps has changed to emit ISO-formatted UTC-based millisecond-precision timestamp string. Default serialization of byte arrays has changed to emit JSON arrays of numbers instead of HEX strings.InputType
and replaced it with simple isNull
method on Input
@transparent
codecs now delegate null
deserialization to its underlying codec instead of returning bare null
value.Other unrelated features:
Timestamp
classJettyRPCFramework
client now accepts responses bigger than 2MiB - #77Introduced TypeString
and JavaClassName
- platform-independent, serializable, macro-generated typeclasses that hold full textual representation of a Scala type (TypeString
) and fully qualified class name of a Java class corresponding to a Scala type (JavaClassName
).
SealedUtils.instancesFor
macro which lists instances of some typeclass for every case class (non-abstract subclass) of a sealed hierarchy@showAst
annotation which works similarly to .showAst
extension macro but can be used on definitions (classes, objects, members) instead of just expressions. However, it requires commons-analyzer
compiler plugin to be enabled.This is an overhaul of RPC macro engine and overall RPC design. Compatibility with previous version is not preserved but RPCFramework
is kept as legacy glue code. Porting old usages of RPCFramework
to new version should be relatively easy as incompatibilities are not big:
fire
, call
and get
) has changed - it takes RPC name in separate parameter list and arguments as List[RawValue]
instead of List[List[RawValue]]
RPCMetadata
API changed - there is separate metadata map for every method type (procedure, function, getter).GenCodec
and serializationBreaking changes:
HasGenCodec
redesigned. MacroCodec[T]
removed in favor or MacroGenerated[GenCodec[T]]
. HasGenCodec
is now more flexible - previously it didn't work for case classes with default parameter values or sealed traits with subclasses in companion object. This was caused by overzealous validation done by the compiler on super constructor arguments - they cannot refer to the object being constructed. Materialization of MacroGenerated
is now able to work around this.GenCodec.Auto
has been deprecated and will be removed
Input
and Output
now support BigInt
and BigDecimal
natively - #69Other changes:
@whenAbsent
for providing default values for case class parameters used only during deserializationBreaking changes:
BsonRef
is now parameterized by entity type and also wraps an actual getter from entity type to referred typeGenCodec
for Map[K,V]
that uses list-of-key-value-pairs encoding (where no GenKeyCodec[K]
is available) has been removed
commons-spring
ScalaParameterNameDiscoverer
- a ParameterNameDiscoverer
implementation which uses Java 8 reflection to obtain parameter names or falls back to Scala runtime reflection when under older Java or when parameter names are not present in bytecodeScalaDefaultValuesInjector
- a BeanFactoryPostProcessor
implementation which injects default values of Scala constructor and factory method arguments into bean definitions if they are lacking.ValueEnum
ValueEnum
is a new way for defining Scala enums, representing enum constants as final val
s in companion object of enum class.
Advantages:
ValueEnum
does not extend java.lang.Enum
)name
(name of the final val
that declares the constant) and ordinal
(zero based index of enum constant, consistent with declaration order).Disadvantages:
ValueEnum
which may result in both lack of correct warnings and incorrect warningsSerialization framework:
GenCodec
s for much less generated code by moving as much code as possible to base classes: ApplyUnapplyCodec
, ProductCodec
, SealedHierarchyCodec
etc.RPC framework:
AsRawRPC
, AsRealRPC
RPCTypeClasses
in favor of newly introduced RPCFramework#RPCCompanion
which is designed so that DCE removes unused TC instancescommons-core
full cross projectcommons-shared
(previously cross compiled to JVM and JS) and commons-core
(previously JVM only) have been merged into a single cross compiled module commons-core
. Therefore you must replace your dependencies to commons-shared
with commons-core
.BasicJavaInterop
, implemented JavaInterop
separately for JS (without Java 8 stuff which is unavailable in ScalaJS)Published by ghik over 8 years ago
RPC framework has been generalized to allow other types of remote methods than getters, functions and procedures. Old functionality of RPCFramework
is retained as StandardRPCFramework
, which is now a special case of new, generalized RPCFramework
. RPCMetadata
has also been adjusted to reflect the generalization.
These changes are not backwards compatible.
hocon-spring
has been moved to commons-spring
module