Releases: disneystreaming/smithy4s
v0.18.5 : x-www-form-urlencoded bug fix
This releases fixes a bug related to default values in the x-www-form-urlencoded encoding.
See #1323
What's Changed
- Updated headers for 2024 by @Baccata in #1337
- Bump actions/download-artifact from 3 to 4 by @dependabot in #1336
- Use field.getUnlessDefault instead of field.get in UrlFormDataEncoder by @bpholt in #1323
Full Changelog: v0.18.4...v0.18.5
v0.18.4
This release fixes a bunch of bugs and introduces some minor semantic changes. Make sure to review them!
What's Changed
Update meaning of required
in both codegen and runtime by @Baccata in #1301
Adjusts the behavior of required fields with defaults. Most importantly, it changes the behavior when the following conditions are all true:
@required
is present on a member@default
(or=
shorthand) is present on that member- the runtime value matches the default
e.g. @required s: String = "foo"
with a runtime value of "foo"
.
In past releases, JSON codecs would not write such fields when serializing your data, unless configured to do so with the withExplicitDefaultsEncoding
option. Starting with this release, @required
fields will always be serialized in JSON, Documents and XML (as well as any other codecs that use getUnlessDefault
or foreachUnlessDefault
).
This isn't yet fixed in AWS ec2Query codecs. A fix is in the works.
Additional changelog information
Changes the behaviour of Field#getUnlessDefault
and Field#foreachUnlessDefault
to always take the value into consideration when the smithy.api#required
trait is present on the field. This leads to field values being always serialised even when their values match their defaults, as this abides by least-surprise-principle.
Fix LSP rendering of the repository by @daddykotex in #1293
Fixes sbt's and mill's rendering of Maven repositories in smithy4sUpdateLSPConfig
and smithy4s.codegen.LSP/updateConfig
, respectively.
Avoid duplicate repos/deps/imports in the smithy-build.json by @daddykotex in #1299
In some cases, it was possible that using the LSP config tasks in sbt/mill would result in a repository appearing on the list more than once. This fix removes such duplication.
AwsCredentialsProvider should allow Instance Metadata Service base URI to be overridden using environment variable by @bpholt in #1306
Adds the ability to configure the base URI of the AWS Metadata Service with the AWS_EC2_METADATA_SERVICE_ENDPOINT
variable, which is consistent with some official AWS SDKs.
Escape astrisks following slashes in documentation by @bpholt in #1304
Add support for Unit primitives when unfolding typed nodes by @denisrosca in #1325
Fixes an issue (#1297) in which Unit values couldn't be rendered in Smithy traits.
- fix: Do not evaluate traits of traits members recursively by @ghostbuster91 in #1305
Fixes an issue (#1296) in which the code generator would fail with a stack overflow when rendering some recursive traits.
Library updates and internal changes
- Update os-lib to 0.9.2 by @scala-steward in #1288
- Update fs2-core, fs2-io to 3.9.3 by @scala-steward in #1291
- Update PULL_REQUEST_TEMPLATE.md for checkboxes by @daddykotex in #1294
- Update smithy-build, smithy-model to 1.41.0 by @scala-steward in #1292
- Update http4s-circe, http4s-client, ... to 0.23.24 by @scala-steward in #1298
- Update smithy-build, smithy-model to 1.41.1 by @scala-steward in #1303
- Update sbt-sonatype to 3.10.0 by @scala-steward in #1302
- Update sbt-bloop to 1.5.12 by @scala-steward in #1309
- Update coursier to 2.1.8 by @scala-steward in #1311
- Update mill-main, mill-main-api, ... to 0.11.6 by @scala-steward in #1310
- Update swagger-ui-dist to 5.9.4 by @scala-steward in #1314
- Update webjars-locator to 0.50 by @scala-steward in #1313
- Update sbt-bloop to 1.5.13 by @scala-steward in #1322
- Update jsoniter-scala-core, ... to 2.25.0 by @scala-steward in #1318
New Contributors
Full Changelog: v0.18.3...v0.18.4
v0.18.3
v0.18.3 : misc fixes
- Support constraint traits on members targeting enums
Although it's weird to allow it, it is actually supported in Smithy.
- Tweak operation schema
*Input
and*Output
functions
Some schema visitor will adjust their behaviour if a shape is the input or the output of an operation. For this reason we have a InputOutput
class with a Input
and Output
hint that you can add to schemas to adjust the behaviour. OperationSchema
has functions to work on input schemas and output schemas of an operation. This change makes these functions automatically add the relevant hint.
See #1284
- OptionDefaultVisitor supports bijection
When the schema for the member of a structure is a bijection, and the structure is meant to be decoded from metadata (like http headers), optionality was disregarded. This was making optional member required when decoding.
See #1284
- Fixing AwsInstanceMetadata codec in #1266
Resolves an issue in which AWS credentials would be decoded using the wrong timestamp format, affecting AWS clients on EC2/ECS.
See #1266
- Render explicit type annotations for some methods that were missing them in #1272
This resolves a problem in which type inference would have different results between Scala 2.13 and 3.x, causing an error on Scala 2.13 under the -Xsource:3
flag.
See #1272
- Override
toString
on error shapes
Default toString
implementation on Throwable
prints the class name, instead, we decided to rely on a custom toString
implementation.
See #1263
What's Changed
- Add Tests to Confirm Empty Body Fixes by @lewisjkl in #1257
- Update fs2-data-xml to 1.9.1 by @scala-steward in #1261
- Update nscplugin, sbt-scala-native, ... to 0.4.16 by @scala-steward in #1262
- Cleanup some codegen code by @kubukoz in #1259
- Fix AwsInstanceMetadata decoding by @msosnicki in #1266
- Move change to the right place in the changelog by @kubukoz in #1269
- Update jsoniter-scala-macros to 2.24.2 by @scala-steward in #1271
- Render more explicit type annotations by @kubukoz in #1272
- Update jsoniter-scala-macros to 2.24.3 by @scala-steward in #1278
- Update jsoniter-scala-macros to 2.24.4 by @scala-steward in #1281
- Update webjars-locator to 0.48 by @scala-steward in #1276
- Update smithy-build, smithy-model to 1.40.0 by @scala-steward in #1268
- Documentation website updates by @daddykotex in #1286
- Misc fixes: OptionDefaultVisitor and InputOutput on OperationSchema by @daddykotex in #1284
- Throwable toString override by @daddykotex in #1263
- Update swagger-ui-dist to 5.9.1 by @scala-steward in #1277
- Update jsoniter-scala-core to 2.24.4 by @scala-steward in #1280
- Support range/length refinement providers for enums by @Baccata in #1283
Full Changelog: v0.18.2...v0.18.3
v0.18.2 - UrlForm encapsulation improvements
What's Changed
- Expose UrlForm.parse and UrlFormDecodeError by @BalmungSan in #1254
New Contributors
- @BalmungSan made their first contribution in #1254
Full Changelog: v0.18.1...v0.18.2
v0.18.1 : bug fixes
0.18.1
Open enum support in Dynamic module
In 0.18.0, support was added for open enums in smithy4s-generated code. This release extends that support to runtime (dynamic) schemas.
Fixed a bug preventing a model pre-processor from being exercised
This model-preprocessor aims at removing constraints from output types in AWS specs (as AWS doesn't seem to respect said constraints)
#1251
What's Changed
- Extra dollar sign to avoid env var substitution in docs by @daddykotex in #1241
- Wrap dollar sign in backtick by @daddykotex in #1242
- Break the dependency on bootstrapped by @daddykotex in #1246
- Update fs2-data-xml to 1.9.0 by @scala-steward in #1249
- Update jsoniter-scala-core, ... to 2.24.1 by @scala-steward in #1248
- Listed the AwsConstraintsTransformer with relevant SPI by @Baccata in #1251
- Dynamic: support open enums by @kubukoz in #1244
- Update alloy by @Baccata in #1253
Full Changelog: v0.18.0...v0.18.1
v0.18.0 : towards multi-protocol
0.18.0
This 0.18.0 release of Smithy4s contains a significant rewrite of the abstractions and the internals that compose the library. It is motivated by a desire to facilitate the catering to two orthogonal use-cases :
- implementation of different protocols.
- integration with other http libraries than the one we provide out-of-the-box.
This release is neither source nor binary compatible with the previous ones, and also forces some users to update their Smithy specifications. Please read the next section carefully.
This release also comes with a number of user-facing improvements.
Behavioural changes
The default timestamp format in Json serialisation is now EPOCH_SECONDS
. This change is motivated by a desire to align with AWS and to improve our compatibility with their tooling. Timestamps shapes (or members pointing to timestamp shapes) now will need to be annotated with @timestampFormat("DATE_TIME")
in order to retrieve the previous behaviour.
Significant rewrite of the abstractions.
The abstractions that power smithy4s have been overhauled to facilitate integration with other protocols than simpleRestJson and other http libraries than http4s. Many levels of the library has been impacted in significant ways, which is likely to break a great many third-party integrations. The amount of breaking changes is too large to list exhaustively, therefore only a highlight is provided in this changelog.
smithy4s.schema.Field
is no longer a GADT differentiating from required/optional fields. There is now asmithy4s.schema.Schema.OptionSchema
GADT member instead, which was required to support some traits.smithy4s.schema.Schema.UnionSchema
now references an ordinal function, as opposed to the previous dispatch function.smithy4s.Endpoint
now contains asmithy4s.schema.OperationSchema
, which is a construct gathering all schemas related to an operation.smithy4s.Endpoint.Middleware
now generalises the concept of "endpoint-specific middleware" to non-http4s centric usecases. It does however loses theMonoid
instance, as it now lives in theinteropcats
package provided by thesmithy4s-cats
module.smithy4s.Service
now allows to get an ordinal value out of a reified operation, thus making it easier to dispatch it to the correct handler.smithy4s.Service
now contains some methods for instantiation of services from an endpoint compilers.- Two new packages in
core
have appeared :smithy4s.server
andsmithy4s.client
, each containing protocol-agnostic constructs that aim at taking care of some of the complexity of integrating libraries/protocols with smithy4s. - A
smithy4s.capability.MonadThrowLike
andsmith4s.capability.Zipper
types have been created, unlocking the writing of generic functions that benefits integrations
with various third-party libraries. smithy4s.http.HttpRequest
andsmithy4s.http.HttpResponse
types have been created.smithy4s.http.HttpUnaryClientCodecs
andsmithy4s.http.HttpUnaryServerCodecs
are new constructs that aim at facilitating the integration of http-protocols. In particular, they take care of a fair amount of complexity related to handlingsmithy.api#http*
traits (including the reconciliation of data coming from http metadata and http bodies).- Overall, the amount of code in the
smithy4s-http4s
module has drastically diminished, as the constructs necessary for the generalisation of the http-related logic have been created. We (maintainers) love http4s, and are not planning on publicly maintaining any other integration, but we are responsible for other integrations in our work ecosystem. Therefore, generalising what we can makes our jobs easier, but also should allow for third parties to have an easier time integrating their http-libraries of choice with Smithy4s.
Highlight : schema partitioning
The most ground-breaking change of 0.18, which is crucial for how things are now implemented, is the addition of a smithy4s.schema.SchemaPartition
utility that allow to split schemas into sub-schemas that each take care of the subset of the data. This mechanism allows to completely decouple the (de)serialisation of http bodies from the decoding of http metadata. This means, for instance, that JSON serialisation no longer has to be aware of traits such as httpHeader
, httpQuery
, httpLabel
. This greatly facilitates the integration of other serialisation technologies (XML, URL Form, etc) as these no longer have to contain convoluted logic related to which fields should be skipped during (de)-serialisation.
As a result, the smithy4s-json module has been rewritten. In particular, the code it contains is now held in the smithy4s.json
package, since it is no longer coupled with http-semantics. The smithy4s.json.Json
object has also been created to provide high-level methods facilitating the encoding/decoding of generated types into json, which is helpful for a number of use-cases that fall out of the server/client bindings.
Features
AWS SDK support.
Smithy4s' coverage of the AWS protocols has increased drastically. Now, the vast majority of services and operations are supported. This does mean that Smithy4s can effectively be used as a cross-platform AWS SDK (with caveats), delegating to http4s
for transport.
The Smithy4s build plugins now also come with utilities to facilitate the code-generation from AWS service specifications.
Please refer yourself to the relevant documentation page.
Build plugins
Smithy has support in IDE via the smithy-language-server. The language server uses a configuration file to understand your project. In 0.18, our build plugins for sbt
and mill
can generate that configuration file for you. Use the following commands depending on the build tool you use, for sbt
: sbt smithy4sUpdateLSPConfig
and for mill
: mill smithy4s.codegen.LSP/updateConfig
.
Mill
The mill
plugin is build for version 0.11.0
. The changes to the API are solely results of this migration.
The most important migration bits:
- Change from
def smithy4sInputDirs: mill.define.Sources
todef smithy4sInputDirs: mill.define.Target[Seq[PathRef]]
- Change from
def manifest: T[mill.modules.Jvm.JarManifest]
todef manifest: T[mill.api.JarManifest]
- Change from
def smithy4sAllExternalDependencies: T[Agg[Dep]]
todef smithy4sAllExternalDependencies: T[Agg[BoundDep]]
Cats Module
Addition of a cats module to contain SchemaVisitor
implementations of commonly-used cats typeclasses. Currently included are cats.Show
and cats.Hash
(note that cats.Eq
is provided by the cats.Hash
implementation).
See #921
Structure Patterns
Allows for marking string types with the alloy#structurePattern
trait. This trait indicates that a given pattern, with parameters, applies to a given string and that this string should
actually be parsed into a structure where the members of the structure are derived from the parameters in the string pattern.
See #942
Non-Orphan Typeclass Instances
Allows creating implicit typeclass instances in the companion objects in the smithy4s-generated code. This is useful for creating instances of
typeclasses such as cats.Show
, cats.Eq
or any others you may be using.
See #912
smithy4s.Blob
smithy4s.ByteArray
has been deprecated in favor of smithy4s.Blob
. This new type is more flexible, in that it can be backed by byte arrays and byte buffers alike.
Additionally, it allows for O(1) concatenation. This change is motivated by a desire to ease integration with third party libraries whilst reducing the need of copies of binary data.
Smithy4s Optics Instances
When the smithy4sRenderOptics setting is enabled, Lenses and Prisms will be rendered in the companion objects of the generated code when appropriate.
See #1103
Open Enumerations
Introduces alternative code generation for enums and intEnums when they are marked with the alloy#openEnum
trait.
See #1137
Union Projections and Visitors
Added convenient methods for working with unions including projectors for each union alternative and a visitor in union companion objects that can be passed to each union's new accept
method.
See #1144
Sparse collections
The sparse
trait is now supported, allowing for the modelling of collections with null values. Its presence leads to the code-generation of List[Option[A]]
and Map[String, Option[A]]
.
See #993
Xml support
The smithy4s-xml
now exists, containing utilities to parse XML blobs into the generated data classes, and render XML from the generated data classes. This serde logic abides by the rules described in the the official smithy documentation.
application/x-www-form-urlencoded support
The smithy4s-core
now contains utilities to parse application/x-www-form-urlencoded payloads into the generated data classes, and render those payloads same payloads the generated data classes. This encoding allows for a few customisation, driven by alloy traits.
See #1113
What's Changed
v0.17.18 - bugfix release
What's Changed
Full Changelog: v0.17.17...v0.17.18
v0.17.17: Updates to simpleRestJson http tests
What's Changed
Full Changelog: v0.17.16...v0.17.17
v0.17.16: HEAD Response Fix
Fixes a bug where HEAD responses contained an empty {}
in the body (where there should be no body present).
What's Changed
Full Changelog: v0.17.15...v0.17.16
v0.17.15: Fixes for intEnum trait rendering
Updates to fix compile errors when intEnum shapes are used as traits.
What's Changed
Full Changelog: v0.17.14...v0.17.15