-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include field modifiers in collision avoidance (#1593)
- Loading branch information
Showing
6 changed files
with
66 additions
and
6 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
22 changes: 22 additions & 0 deletions
22
modules/bootstrapped/src/generated/smithy4s/example/DefaultNotCapitalized.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,22 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.Hints | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.ShapeTag | ||
import smithy4s.schema.Schema.struct | ||
|
||
final case class DefaultNotCapitalized(name: Username = smithy4s.example.Username("hello")) | ||
|
||
object DefaultNotCapitalized extends ShapeTag.Companion[DefaultNotCapitalized] { | ||
val id: ShapeId = ShapeId("smithy4s.example", "DefaultNotCapitalized") | ||
|
||
val hints: Hints = Hints.empty | ||
|
||
// constructor using the original order from the spec | ||
private def make(name: Username): DefaultNotCapitalized = DefaultNotCapitalized(name) | ||
|
||
implicit val schema: Schema[DefaultNotCapitalized] = struct( | ||
Username.schema.required[DefaultNotCapitalized]("name", _.name).addHints(smithy.api.Default(smithy4s.Document.fromString("hello"))), | ||
)(make).withId(id).addHints(hints) | ||
} |
15 changes: 15 additions & 0 deletions
15
modules/bootstrapped/src/generated/smithy4s/example/Username.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,15 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.Hints | ||
import smithy4s.Newtype | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.schema.Schema.bijection | ||
import smithy4s.schema.Schema.string | ||
|
||
object Username extends Newtype[String] { | ||
val id: ShapeId = ShapeId("smithy4s.example", "username") | ||
val hints: Hints = Hints.empty | ||
val underlyingSchema: Schema[String] = string.withId(id).addHints(hints) | ||
implicit val schema: Schema[Username] = bijection(underlyingSchema, asBijection) | ||
} |
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