All Versions
13
Latest Version
Avg Release Cycle
126 days
Latest Release
1555 days ago

Changelog History
Page 1

  • v1.8.0 Changes

    September 09, 2020

    scalaxb 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 the item field of the purchase order's items 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 on toXML(...) #518 by @abestel
    • โž• Adds scalaxbUseLists setting to generate List[A] instead of Seq[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
  • v1.7.4 Changes

    June 28, 2020
    • Populates xsi:type attribute on toXML(...) #518 by @abestel
    • โž• Adds scalaxbUseLists setting to generate List[A] instead of Seq[A] #526 by @pgrandjean
    • ๐Ÿ›  Fixes code generation to avoid multi-arg infix syntax #531 by @margussipria
  • v1.7.3 Changes

    September 22, 2019

    โœจ enhancement

    ๐Ÿ› bug fix

    • ๐Ÿ›  Fixes the handling of attributes declared as sequences #512 by @abestel
  • v1.7.2 Changes

    August 26, 2019

    ๐Ÿ› bug fix

  • v1.7.1 Changes

    March 16, 2019

    v1.7.0...v1.7.1

    ๐Ÿ› bug fixes

  • v1.7.0 Changes

    September 09, 2018

    1.5.2...v1.7.0

    ๐Ÿ’ฅ Breaking changes

    • ExecutionContext parameter is added to all methods returning Future[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") }
    

    #461 by @hosamaly

    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

    • โ†ช Splits fromAnySchemaType into smaller chunks to work around JVM code size limit. #429 by @fltt
  • v1.5.1 Changes

    March 10, 2017

    ๐Ÿ› bug fixes

    โœจ enhancements

  • 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

    โœจ 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 adding scalaxbSettings and defining sourceGenerators in Compile,
    ๐Ÿ”Œ enable ScalaxbPlugin instead. All other setting/task keys will be prefixed with "scalaxb".
    ๐Ÿ“ฆ For example, packageName will now be called scalaxbPackageName.

    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
      )
    

    #405 by @eed3si9n

    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
      )
    

    #390 by @AndreVanDelft