Changelog History
Page 1
-
v1.8.0 Changes
September 09, 2020scalaxb 1.8.0 adds Monocle Lens generation feature.
setup
Using the sbt-scalaxb this can be enabled as:
val monocleCore = "com.github.julien-truffaut" %% "monocle-core"% "2.0.3"// val monocleMacro = "com.github.julien-truffaut" %% "monocle-macro" % "2.0.3"val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.3.0"val scalaParser = "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"val dispatchV = "0.12.0"val dispatch = "net.databinder.dispatch" %% "dispatch-core" % dispatchVThisBuild / organization := "com.example"ThisBuild / scalaVersion := "2.12.8"lazy val root = (project in file(".")) .enablePlugins(ScalaxbPlugin) .settings( name := "foo", libraryDependencies ++= Seq(dispatch, scalaXml, scalaParser, monocleCore), Compile / scalaxb / scalaxbDispatchVersion := dispatchV, Compile / scalaxb / scalaxbPackageName := "com.example.ipo", Compile / scalaxb / scalaxbGenerateLens := true, Compile / scalaxb / scalaxbUseLists := true, )
generated code
This will generate Lenses in the companion objects as follows:
case class PurchaseOrderType(shipTo: ipo.Addressable, billTo: ipo.Addressable, comment: Option[String] = None, items: ipo.Items, attributes: Map[String, scalaxb.DataRecord[Any]] = Map.empty) { lazy val orderDate = attributes.get("@orderDate") map { \_.as[javax.xml.datatype.XMLGregorianCalendar]} }object PurchaseOrderType { def shipTo: monocle.Lens[PurchaseOrderType, ipo.Addressable] = monocle.Lens[PurchaseOrderType, ipo.Addressable](\_.shipTo)((\_shipTo: ipo.Addressable) =\> (purchaseordertype: PurchaseOrderType) =\> purchaseordertype.copy(shipTo = \_shipTo)) def billTo: monocle.Lens[PurchaseOrderType, ipo.Addressable] = monocle.Lens[PurchaseOrderType, ipo.Addressable](\_.billTo)((\_billTo: ipo.Addressable) =\> (purchaseordertype: PurchaseOrderType) =\> purchaseordertype.copy(billTo = \_billTo)) def comment: monocle.Lens[PurchaseOrderType, Option[String]] = monocle.Lens[PurchaseOrderType, Option[String]](\_.comment)((\_comment: Option[String]) =\> (purchaseordertype: PurchaseOrderType) =\> purchaseordertype.copy(comment = \_comment)) def items: monocle.Lens[PurchaseOrderType, ipo.Items] = monocle.Lens[PurchaseOrderType, ipo.Items](\_.items)((\_items: ipo.Items) =\> (purchaseordertype: PurchaseOrderType) =\> purchaseordertype.copy(items = \_items)) def attributes: monocle.Lens[PurchaseOrderType, Map[String, scalaxb.DataRecord[Any]]] = monocle.Lens[PurchaseOrderType, Map[String, scalaxb.DataRecord[Any]]](\_.attributes)((\_attributes: Map[String, scalaxb.DataRecord[Any]]) =\> (purchaseordertype: PurchaseOrderType) =\> purchaseordertype.copy(attributes = \_attributes)) implicit class PurchaseOrderTypeW[A](l: monocle.Lens[A, PurchaseOrderType]) { def shipTo: monocle.Lens[A, ipo.Addressable] = l composeLens PurchaseOrderType.shipTo def billTo: monocle.Lens[A, ipo.Addressable] = l composeLens PurchaseOrderType.billTo def comment: monocle.Lens[A, Option[String]] = l composeLens PurchaseOrderType.comment def items: monocle.Lens[A, ipo.Items] = l composeLens PurchaseOrderType.items def attributes: monocle.Lens[A, Map[String, scalaxb.DataRecord[Any]]] = l composeLens PurchaseOrderType.attributes } }case class Items(item: List[ipo.Item] = Nil) object Items { def item: monocle.Lens[Items, List[ipo.Item]] = monocle.Lens[Items, List[ipo.Item]](\_.item)((\_item: List[ipo.Item]) =\> (items: Items) =\> items.copy(item = \_item)) implicit class ItemsW[A](l: monocle.Lens[A, Items]) { def item: monocle.Lens[A, List[ipo.Item]] = l composeLens Items.item } }
usage
Here's an example of how the lenses can be used:
scala\> import com.example.ipo.\_import com.example.ipo.\_scala\> val items = Items(Item("a", BigInt(0), BigDecimal(0)) :: Nil) items: com.example.ipo.Items = Items(List(Item(a,0,0,None,None,Map()))) scala\> val po = PurchaseOrderType(Address("", "", ""), Address("", "", ""), None, items) po: com.example.ipo.PurchaseOrderType = PurchaseOrderType(Address(,,),Address(,,),None,Items(List(Item(a,0,0,None,None,Map()))),Map()) scala\> PurchaseOrderType.items.item.set(Item("b", BigInt(0), BigDecimal(0)) :: Nil)(po) res0: com.example.ipo.PurchaseOrderType = PurchaseOrderType(Address(,,),Address(,,),None,Items(List(Item(b,0,0,None,None,Map()))),Map())
In the above,
PurchaseOrderType.items.item
zooms into theitem
field of the purchase order'sitems
field and replaces the value.This was implemented by @eed3si9n as #535, based on #292 contributed by @lbruand.
-
v1.7.5 Changes
June 28, 2020- Populates
xsi:type
attribute ontoXML(...)
#518 by @abestel - โ Adds
scalaxbUseLists
setting to generateList[A]
instead ofSeq[A]
#526 by @pgrandjean - ๐ Fixes code generation to avoid multi-arg infix syntax #531 by @margussipria
- Splits generated
fromString
method for big enums that would otherwise not compile #517 by @LolHens
- Populates
-
v1.7.4 Changes
June 28, 2020- Populates
xsi:type
attribute ontoXML(...)
#518 by @abestel - โ Adds
scalaxbUseLists
setting to generateList[A]
instead ofSeq[A]
#526 by @pgrandjean - ๐ Fixes code generation to avoid multi-arg infix syntax #531 by @margussipria
- Populates
-
v1.7.3 Changes
September 22, 2019 -
v1.7.2 Changes
August 26, 2019๐ bug fix
- ๐ Fixes big decimal formatting in
toXML
according to XML Schema #505 by @tOverney
- ๐ Fixes big decimal formatting in
-
v1.7.1 Changes
March 16, 2019๐ bug fixes
- ๐ Fixes big decimal formatting according to XML Schema #483 by @danslapman
- ๐ Fixes equals called on a String and Option[String] #485 by @lespea
- ๐ Fixes one-way SOAP call #493 by @danslapman
-
v1.7.0 Changes
September 09, 2018๐ฅ Breaking changes
ExecutionContext
parameter is added to all methods returningFuture[A]
, instead of hardcoding a execution context. #482 inspired by #407
Symbol encoding strategy and capitalization
scalaxb 1.7.0 adds option to encode symbols.
lazy val scalaxbCapitalizeWords= settingKey[Boolean]("Attempts to capitalize class and attribute names to match the CamelCase convention") lazy val scalaxbSymbolEncodingStrategy = settingKey[SymbolEncodingStrategy.Value]("Specifies the strategy to encode non-identifier characters in generated class names") object SymbolEncodingStrategy extends Enumeration { val Discard = Value("discard") val SymbolName = Value("symbol-name") val UnicodePoint = Value("unicode-point") val DecimalAscii = Value("decimal-ascii") val Legacy151 = Value("legacy-1.5.1") }
Other enhancements
- ๐ Handle multiple faults #438 by @SupraFii
- โ Adds support for enum values list #446 by @bbarker
- ๐ Supports Dispatch versions from 0.11.4 to 0.14.x #468 by @margussipria
- 0๏ธโฃ Generates a default value for class parameters of
anyAttribute
#470 by @hosamaly - ๐ scala-xml 1.1.0 and scala-parser-combinators 1.1.0 #476 by @sullis
- ๐ Uses sealed traits for enums #479 by @mrdziuban
- โ Adds config option for setting
scalaxbEnumNameMaxLength
for enum name length #480 by @mrdziuban
๐ Bug fixes
- ๐ Don't throw exception on http status code != 200 to allow Fault parsing #444 by @alexdupre
- ๐ Fixes Soap11Fault bug when empty detail #450 by @dportabella
-
v1.5.2 Changes
August 24, 2017โจ enhancements
- โ Adds support for Gigahorse 0.3 and different backends (OkHttp and AHC) #428 by @alexdupre
๐ bug fixes
-
v1.5.1 Changes
March 10, 2017๐ bug fixes
- Replaces trailing underscore with
"u93"
. #415 by @varnerac - ๐ Fixes BigDecimal formatting. #417 by @coutoPL
โจ enhancements
- โ Adds Gigahorse support. #413 by @alexdupre
- โ Adds Scala 2.12 cross building. #413/#419 by @alexdupre and @dwijnand
- Replaces trailing underscore with
-
v1.5.0 Changes
March 10, 2017๐ฅ breaking changes
- ๐ Fixes name clashes in typeclass instance by prefixing full package name. #385 by @anatoliykmetyuk
- 0๏ธโฃ The default value for using varargs is set to false.
- ๐ sbt-scalaxb is now an auto plugin. See below.
๐ bug fixes
- ๐ Fixes SOAP operations which use multiple implicit headers. #380 by @joshlreese
- ๐ Fixes SOAP header values composition. #381 by @coutoPL
- ๐ Fixes SOAP header parts code generation. #400 by @jankeesvanandel
- ๐ Fixes enum name conflicts. #386 by @anatoliykmetyuk
- ๐ Fixes enum parsing, for example
00
inxsd:byte
. #388 by @anatoliykmetyuk
โจ enhancements
- โ Adds
--mutable
option to generate mutable case classes. See below. - ๐ Uses type attribute to convert
xs:any
. #389 by @anatoliykmetyuk - โ Adds
--autopackages
option to pick package names automatically. #391 by @anatoliykmetyuk - โ Adds
--visitor
option to generate a Visitor for traversing over the generated case classes. #392 by @anatoliykmetyuk
sbt-scalaxb changes
๐ sbt-scalaxb for scalaxb 1.5.0 is changed to an auto plugin.
Instead of addingscalaxbSettings
and definingsourceGenerators in Compile
,
๐ enableScalaxbPlugin
instead. All other setting/task keys will be prefixed with "scalaxb".
๐ฆ For example,packageName
will now be calledscalaxbPackageName
.Before:
import ScalaxbKeys._ lazy val root = (project in file(".")). settings( name := "foo-project"). settings(scalaxbSettings). settings( sourceGenerators in Compile += (scalaxb in Compile).taskValue, packageName in (Compile, scalaxb) := "generated" // packageNames in (Compile, scalaxb) := Map(uri("http://something/") -> "something"), // logLevel in (Compile, scalaxb) := Level.Debug )
After:
lazy val root = (project in file(".")). enablePlugins(ScalaxbPlugin). settings( name := "foo-project", scalaxbPackageName in (Compile, scalaxb) := "generated" // scalaxbAutoPackages in (Compile, scalaxb) := true )
mutable case class
scalaxb 1.5.0 adds an option to generate mutable case classes.
case class Address(var name: String, var street: String, var city: String)
In sbt-scalaxb, this can be enabled as:
lazy val root = (project in file(".")). enablePlugins(ScalaxbPlugin). settings( name := "foo-project", scalaxbPackageName in (Compile, scalaxb) := "generated", scalaxbGenerateMutable in (Compile, scalaxb) := true )