-
Notifications
You must be signed in to change notification settings - Fork 69
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
add default support in several locations #358
Changes from 3 commits
558dd08
8997283
c533a74
5b186fc
e76c4fb
f19520d
24a52d8
ed15d1f
680fdc5
6d5938e
065461d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.schema.Schema._ | ||
|
||
case class DefaultTest(one: Option[Int] = None, two: Option[String] = None, three: Option[List[String]] = None) | ||
object DefaultTest extends smithy4s.ShapeTag.Companion[DefaultTest] { | ||
val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "DefaultTest") | ||
|
||
val hints : smithy4s.Hints = smithy4s.Hints.empty | ||
|
||
implicit val schema: smithy4s.Schema[DefaultTest] = struct( | ||
int.optional[DefaultTest]("one", _.one).addHints(smithy.api.Default(smithy4s.Document.fromDouble(1.0))), | ||
string.optional[DefaultTest]("two", _.two).addHints(smithy.api.Default(smithy4s.Document.fromString("test"))), | ||
StringList.underlyingSchema.optional[DefaultTest]("three", _.three).addHints(smithy.api.Default(smithy4s.Document.array())), | ||
){ | ||
DefaultTest.apply | ||
}.withId(id).addHints(hints) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ object StreamedObjectsGen extends smithy4s.Service[StreamedObjectsGen, StreamedO | |
val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "PutStreamedObject") | ||
val input: smithy4s.Schema[PutStreamedObjectInput] = PutStreamedObjectInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) | ||
val output: smithy4s.Schema[Unit] = unit.addHints(smithy4s.internals.InputOutput.Output.widen) | ||
val streamedInput : smithy4s.StreamingSchema[StreamedBlob] = smithy4s.StreamingSchema("PutStreamedObjectInput", StreamedBlob.schema) | ||
val streamedInput : smithy4s.StreamingSchema[StreamedBlob] = smithy4s.StreamingSchema("PutStreamedObjectInput", StreamedBlob.schema.addHints(smithy.api.Default(smithy4s.Document.fromString("")))) | ||
val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing | ||
val hints : smithy4s.Hints = smithy4s.Hints.empty | ||
def wrap(input: PutStreamedObjectInput) = PutStreamedObject(input) | ||
|
@@ -66,7 +66,7 @@ object StreamedObjectsGen extends smithy4s.Service[StreamedObjectsGen, StreamedO | |
val input: smithy4s.Schema[GetStreamedObjectInput] = GetStreamedObjectInput.schema.addHints(smithy4s.internals.InputOutput.Input.widen) | ||
val output: smithy4s.Schema[GetStreamedObjectOutput] = GetStreamedObjectOutput.schema.addHints(smithy4s.internals.InputOutput.Output.widen) | ||
val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing | ||
val streamedOutput : smithy4s.StreamingSchema[StreamedBlob] = smithy4s.StreamingSchema("GetStreamedObjectOutput", StreamedBlob.schema) | ||
val streamedOutput : smithy4s.StreamingSchema[StreamedBlob] = smithy4s.StreamingSchema("GetStreamedObjectOutput", StreamedBlob.schema.addHints(smithy.api.Default(smithy4s.Document.fromString("")))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Afaik AWS automatically adds this default since the blob shape used to be boxed and now isn't, this would go away if we updated streaming.smithy to be $version 2.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting |
||
val hints : smithy4s.Hints = smithy4s.Hints.empty | ||
def wrap(input: GetStreamedObjectInput) = GetStreamedObject(input) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.Newtype | ||
import smithy4s.schema.Schema._ | ||
|
||
object StringList extends Newtype[List[String]] { | ||
val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "StringList") | ||
val hints : smithy4s.Hints = smithy4s.Hints.empty | ||
val underlyingSchema : smithy4s.Schema[List[String]] = list(string).withId(id).addHints(hints) | ||
implicit val schema : smithy4s.Schema[StringList] = bijection(underlyingSchema, asBijection) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove when changing to use official smithy 2 release