Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump smithy to 1.49.0 #1485

Merged
merged 27 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
## Maintainers' notice

This file serves as a template for release notes in GitHub releases.
When adding entries, please treat them as if they could end up in a release any time. This makes it much easier for us to make frequent releases!

Thank you!

# 0.18.19 - binary-breaking changes in `core`

**WARNING**: This release includes binary-breaking changes in the `core` module. This is indirectly caused by an upstream change in [smithy-lang/smithy](https://github.com/smithy-lang/smithy/).

In the vast majority of applications using Smithy4s, it will not cause runtime issues. However, in the unlikely event that you have custom interpreters that query the `.breakingChanges` field of a `Trait` hint, or have that field populated by a non-stdlib trait/hint, you'll have to ensure that all the libraries pulled by your application are compiled against smithy4s 0.18.19 or above.

In sbt, you can check what versions of smithy4s are used by your dependencies using the `whatDependsOn` task.

We apologize for the inconvenience.

* Update smithy: 1.45.0 to 1.49.0 (binary breaking) in https://github.com/disneystreaming/smithy4s/pull/1485

# 0.18.18

* Fix an issue in the ADT trait validators that would sometimes fail validation while they shouldn't.
* Fix an issue in the ADT trait validators that would sometimes fail validation while they shouldn't. https://github.com/disneystreaming/smithy4s/pull/1514

# 0.18.17

* Constraints applied to list or map members are now correctly rendered in the generated code.
* Makes the json decoding of tagged-unions lenient for AWS
* Fix an issue with duplicated entries in generated smithy-build.json file (#1491)
* Add support for passing custom OpenAPI config via a `smithy-build.json` file
* Fix a bug when using `adt` with mixins, see #1457
Expand Down
42 changes: 41 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import com.typesafe.tools.mima.core.ProblemFilters
import com.typesafe.tools.mima.core.MissingClassProblem
import com.typesafe.tools.mima.core.IncompatibleResultTypeProblem
import com.typesafe.tools.mima.core.IncompatibleMethTypeProblem
import _root_.java.util.stream.Collectors
import java.nio.file.Files
import sbt.internal.IvyConsole
Expand Down Expand Up @@ -214,7 +218,43 @@ lazy val core = projectMatrix
.map(f => (f, f.relativeTo(base)))
// this excludes modules/core/src/generated/PartiallyAppliedStruct.scala
.collect { case (f, Some(relF)) => f -> relF.getPath() }
}
},
scalacOptions ++= Seq(
"-Wconf:msg=value noInlineDocumentSupport in class ProtocolDefinition is deprecated:silent"
),
mimaBinaryIssueFilters ++= Seq(
// Incompatible change from smithy 1.46.0
// Introduced in https://github.com/smithy-lang/smithy/pull/2156
// Discussed in https://github.com/smithy-lang/smithy/issues/2243
// Brought to smithy4s in https://github.com/disneystreaming/smithy4s/pull/1485
ProblemFilters.exclude[MissingClassProblem](
"smithy.api.TraitChangeSeverity*"
),
ProblemFilters.exclude[IncompatibleMethTypeProblem](
"smithy.api.TraitDiffRule.apply"
),
ProblemFilters.exclude[IncompatibleResultTypeProblem](
"smithy.api.TraitDiffRule.<init>$default$2"
),
ProblemFilters.exclude[IncompatibleMethTypeProblem](
"smithy.api.TraitDiffRule.this"
),
ProblemFilters.exclude[IncompatibleResultTypeProblem](
"smithy.api.TraitDiffRule.severity"
),
ProblemFilters.exclude[IncompatibleMethTypeProblem](
"smithy.api.TraitDiffRule.copy"
),
ProblemFilters.exclude[IncompatibleResultTypeProblem](
"smithy.api.TraitDiffRule.copy$default$2"
),
ProblemFilters.exclude[IncompatibleResultTypeProblem](
"smithy.api.TraitDiffRule._2"
),
ProblemFilters.exclude[IncompatibleResultTypeProblem](
"smithy.api.TraitDiffRule.apply$default$2"
)
)
)
.jvmPlatform(allJvmScalaVersions, jvmDimSettings)
.jsPlatform(allJsScalaVersions, jsDimSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private[aws] object AwsEcsQueryCodecs {
// without UrlFormDataEncoderSchemaVisitor having to be more aware than necessary of these protocol quirks.
private[aws] val inputEncoders = {
UrlForm
.Encoder(capitalizeStructAndUnionMemberNames = true)
.Encoder(capitalizeStructAndUnionMemberNames = true, alwaysSkipEmptyLists = true)
.mapK { smithy4s.codecs.Encoder.andThenK((form: UrlForm) => Blob(form.render)) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private[aws] object AwsJsonCodecs {
.withFlexibleCollectionsSupport(true)
.withHintMask(hintMask)
.withMaxArity(Int.MaxValue)
.withLenientTaggedUnionDecoding
)

private[aws] val jsonDecoders = jsonPayloadCodecs.decoders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private[aws] object AwsQueryCodecs {

private[aws] val inputEncoders = {
UrlForm
.Encoder(capitalizeStructAndUnionMemberNames = false)
.Encoder(capitalizeStructAndUnionMemberNames = false, alwaysSkipEmptyLists = false)
.mapK { smithy4s.codecs.Encoder.andThenK((form: UrlForm) => Blob(form.render)) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private[aws] object AwsRestJsonCodecs {
.withFlexibleCollectionsSupport(true)
.withHintMask(hintMask)
.withMaxArity(Int.MaxValue)
.withLenientTaggedUnionDecoding
)

def nullToEmptyObject(blob: Blob): Blob =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,12 @@ object AwsComplianceSuite extends ProtocolComplianceSuite {
"QueryIdempotencyTokenAutoFill",

// TODO https://github.com/disneystreaming/smithy4s/issues/1424
"AwsJson10DeserializeIgnoreType",
"AwsJson10ClientPopulatesDefaultValuesInInput",
"AwsJson10ClientPopulatesDefaultsValuesWhenMissingInResponse",
"AwsJson10ClientPopulatesNestedDefaultValuesWhenMissing",
"AwsJson10ClientPopulatesNestedDefaultsWhenMissingInResponseBody",
"AwsJson10ClientErrorCorrectsWhenServerFailsToSerializeRequiredValues",
"AwsJson11DeserializeIgnoreType",
"RestJsonHttpPayloadWithUnsetUnion",
"RestJsonDeserializeIgnoreType",
"RestXmlHttpPayloadWithUnsetUnion"
)
(complianceTest: ComplianceTest[IO]) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"maven" : {
"dependencies" : [
"com.disneystreaming.alloy:alloy-core:0.3.6"
"com.disneystreaming.alloy:alloy-core:0.3.8"
],
"repositories" : [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ private[codegen] object GenerateSmithyBuild {
pr: ProjectRef,
settings: Settings[Scope]
): ListSet[String] = {
println("extract Repos")
(pr / resolvers)
.get(settings)
.toList
Expand Down
11 changes: 9 additions & 2 deletions modules/core/src/smithy4s/http/UrlForm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,15 @@ object UrlForm {

object Encoder {

/** Constructs an [[Encoder]] that encodes data as [[UrlForm]]s. Can be configured using `@alloyurlformname`. */
def apply(
capitalizeStructAndUnionMemberNames: Boolean
): CachedSchemaCompiler[Encoder] =
apply(capitalizeStructAndUnionMemberNames, alwaysSkipEmptyLists = false)

/** Constructs an [[Encoder]] that encodes data as [[UrlForm]]s. Can be configured using `@alloy#urlformname`. */
def apply(
capitalizeStructAndUnionMemberNames: Boolean,
alwaysSkipEmptyLists: Boolean
): CachedSchemaCompiler[Encoder] =
new CachedSchemaCompiler.Impl[Encoder] {
protected override type Aux[A] = UrlFormDataEncoder[A]
Expand All @@ -213,7 +219,8 @@ object UrlForm {
}
val schemaVisitor = new UrlFormDataEncoderSchemaVisitor(
cache,
capitalizeStructAndUnionMemberNames
capitalizeStructAndUnionMemberNames,
alwaysSkipEmptyLists
)
val urlFormDataEncoder = schemaVisitor(schema)
maybeStaticUrlFormData match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ private[http] class UrlFormDataEncoderSchemaVisitor(
val cache: CompilationCache[UrlFormDataEncoder],
// These are used by AwsEc2QueryCodecs to conform to the requirements of
// https://smithy.io/2.0/aws/protocols/aws-ec2-query-protocol.html?highlight=ec2%20query%20protocol#query-key-resolution.
capitalizeStructAndUnionMemberNames: Boolean
capitalizeStructAndUnionMemberNames: Boolean,
alwaysSkipEmptyLists: Boolean
) extends SchemaVisitor.Cached[UrlFormDataEncoder] { compile =>

override def primitive[P](
Expand Down Expand Up @@ -60,7 +61,10 @@ private[http] class UrlFormDataEncoderSchemaVisitor(
val maybeKey =
if (hints.has[UrlFormFlattened]) None
else Option(getKey(member.hints, "member"))
val skipEmpty = hints.toMap.contains(SkipEmpty.keyId)

val skipEmpty =
hints.toMap.contains(SkipEmpty.keyId) || alwaysSkipEmptyLists

collection =>
// This is to handle a quirk of the AWS Query protocol at
// https://github.com/smithy-lang/smithy/blob/f8a846df3c67fa4ae55ecaa57002d22499dc439f/smithy-aws-protocol-tests/model/awsQuery/input-lists.smithy#L43-L57
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,14 @@ object SimpleRestJsonComplianceSuite extends ProtocolComplianceSuite {
.compile
.toVector
.map(_.toArray)
.map(decodeDocument(_, smithy4s.json.Json.payloadDecoders))
.map(
decodeDocument(
_,
smithy4s.json.Json.payloadCodecs
.configureJsoniterCodecCompiler(_.withMaxArity(Int.MaxValue))
.decoders
)
)
.flatMap(loadDynamic(_).liftTo[IO])
} yield dsi
}
Expand Down
7 changes: 7 additions & 0 deletions modules/json/src/smithy4s/json/JsonPayloadCodecCompiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ trait JsonPayloadCodecCompiler {
*/
def withJsoniterCodecCompiler(jsoniterCodecCompiler: JsoniterCodecCompiler): JsonPayloadCodecCompiler

/**
* Like withJsoniterCodecCompiler, but allows you to modify the current codec compiler more easily.
*/
def configureJsoniterCodecCompiler(
jsoniterCodecCompiler: JsoniterCodecCompiler => JsoniterCodecCompiler
): JsonPayloadCodecCompiler

/**
* Changes the jsoniter reader config that is used when parsing json payloads into data.
*/
Expand Down
6 changes: 6 additions & 0 deletions modules/json/src/smithy4s/json/JsoniterCodecCompiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ trait JsoniterCodecCompiler extends CachedSchemaCompiler[JsonCodec] {
*/
def withHintMask(hintMask: HintMask): JsoniterCodecCompiler

/**
* Enables lenient decoding of tagged unions, where unset alternatives are encoded as null
* values in the json payload. Also ignores unrecognised union keys.
*/
def withLenientTaggedUnionDecoding: JsoniterCodecCompiler

}

object JsoniterCodecCompiler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ private[json] case class JsonPayloadCodecCompilerImpl(
jsoniterCodecCompiler: JsoniterCodecCompiler
): JsonPayloadCodecCompiler =
copy(jsoniterCodecCompiler = jsoniterCodecCompiler)

def configureJsoniterCodecCompiler(
jsoniterCodecCompiler: JsoniterCodecCompiler => JsoniterCodecCompiler
): JsonPayloadCodecCompiler =
copy(jsoniterCodecCompiler =
jsoniterCodecCompiler(this.jsoniterCodecCompiler)
)

def withJsoniterReaderConfig(
jsoniterReaderConfig: JsoniterReaderConfig
): JsonPayloadCodecCompiler =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ private[smithy4s] case class JsoniterCodecCompilerImpl(
flexibleCollectionsSupport: Boolean,
infinitySupport: Boolean,
preserveMapOrder: Boolean,
hintMask: Option[HintMask]
hintMask: Option[HintMask],
lenientTaggedUnionDecoding: Boolean
) extends CachedSchemaCompiler.Impl[JCodec]
with JsoniterCodecCompiler {

Expand Down Expand Up @@ -55,13 +56,17 @@ private[smithy4s] case class JsoniterCodecCompilerImpl(
): JsoniterCodecCompiler =
copy(preserveMapOrder = preserveMapOrder)

def withLenientTaggedUnionDecoding: JsoniterCodecCompiler =
copy(lenientTaggedUnionDecoding = true)

def fromSchema[A](schema: Schema[A], cache: Cache): JCodec[A] = {
val visitor = new SchemaVisitorJCodec(
maxArity,
explicitDefaultsEncoding,
infinitySupport,
flexibleCollectionsSupport,
preserveMapOrder,
lenientTaggedUnionDecoding,
cache
)
val amendedSchema =
Expand All @@ -82,6 +87,7 @@ private[smithy4s] object JsoniterCodecCompilerImpl {
infinitySupport = false,
flexibleCollectionsSupport = false,
preserveMapOrder = false,
lenientTaggedUnionDecoding = false,
hintMask = Some(JsoniterCodecCompiler.defaultHintMask)
)

Expand Down
Loading