-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for jsonUnknown trait (#1574)
Implement support for `jsonUnknown` trait defined in disneystreaming/alloy#180
- Loading branch information
1 parent
7afbb5c
commit d4edb32
Showing
10 changed files
with
473 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
modules/bootstrapped/src/generated/smithy4s/example/AdditionalProperties.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.Document | ||
import smithy4s.Hints | ||
import smithy4s.Newtype | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.schema.Schema.bijection | ||
import smithy4s.schema.Schema.document | ||
import smithy4s.schema.Schema.map | ||
import smithy4s.schema.Schema.string | ||
|
||
object AdditionalProperties extends Newtype[Map[String, Document]] { | ||
val id: ShapeId = ShapeId("smithy4s.example", "AdditionalProperties") | ||
val hints: Hints = Hints.empty | ||
val underlyingSchema: Schema[Map[String, Document]] = map(string, document).withId(id).addHints(hints) | ||
implicit val schema: Schema[AdditionalProperties] = bijection(underlyingSchema, asBijection) | ||
} |
27 changes: 27 additions & 0 deletions
27
modules/bootstrapped/src/generated/smithy4s/example/JsonUnknownExample.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.Document | ||
import smithy4s.Hints | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.ShapeTag | ||
import smithy4s.schema.Schema.int | ||
import smithy4s.schema.Schema.string | ||
import smithy4s.schema.Schema.struct | ||
|
||
final case class JsonUnknownExample(s: Option[String] = None, i: Option[Int] = None, additionalProperties: Option[Map[String, Document]] = None) | ||
|
||
object JsonUnknownExample extends ShapeTag.Companion[JsonUnknownExample] { | ||
val id: ShapeId = ShapeId("smithy4s.example", "JsonUnknownExample") | ||
|
||
val hints: Hints = Hints.empty | ||
|
||
// constructor using the original order from the spec | ||
private def make(s: Option[String], i: Option[Int], additionalProperties: Option[Map[String, Document]]): JsonUnknownExample = JsonUnknownExample(s, i, additionalProperties) | ||
|
||
implicit val schema: Schema[JsonUnknownExample] = struct( | ||
string.optional[JsonUnknownExample]("s", _.s), | ||
int.optional[JsonUnknownExample]("i", _.i), | ||
AdditionalProperties.underlyingSchema.optional[JsonUnknownExample]("additionalProperties", _.additionalProperties).addHints(alloy.JsonUnknown()), | ||
)(make).withId(id).addHints(hints) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,8 @@ object JsoniterCodecCompiler { | |
DiscriminatedUnionMember, | ||
Default, | ||
Required, | ||
Nullable | ||
Nullable, | ||
JsonUnknown | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.