-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rendering of IntEnum traits (#1138)
- Loading branch information
Showing
8 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
modules/bootstrapped/src/generated/smithy4s/example/LeftRight.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,34 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.Enumeration | ||
import smithy4s.Hints | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.ShapeTag | ||
import smithy4s.schema.EnumTag | ||
import smithy4s.schema.Schema.enumeration | ||
|
||
sealed abstract class LeftRight(_value: String, _name: String, _intValue: Int, _hints: Hints) extends Enumeration.Value { | ||
override type EnumType = LeftRight | ||
override val value: String = _value | ||
override val name: String = _name | ||
override val intValue: Int = _intValue | ||
override val hints: Hints = _hints | ||
override def enumeration: Enumeration[EnumType] = LeftRight | ||
@inline final def widen: LeftRight = this | ||
} | ||
object LeftRight extends Enumeration[LeftRight] with ShapeTag.Companion[LeftRight] { | ||
val id: ShapeId = ShapeId("smithy4s.example", "leftRight") | ||
|
||
val hints: Hints = Hints.empty | ||
|
||
case object LEFT extends LeftRight("left", "LEFT", 0, Hints()) | ||
case object RIGHT extends LeftRight("right", "RIGHT", 1, Hints()) | ||
|
||
val values: List[LeftRight] = List( | ||
LEFT, | ||
RIGHT, | ||
) | ||
val tag: EnumTag = EnumTag.StringEnum | ||
implicit val schema: Schema[LeftRight] = enumeration(tag, values).withId(id).addHints(hints) | ||
} |
34 changes: 34 additions & 0 deletions
34
modules/bootstrapped/src/generated/smithy4s/example/OldStyleLeftRight.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,34 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.Enumeration | ||
import smithy4s.Hints | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.ShapeTag | ||
import smithy4s.schema.EnumTag | ||
import smithy4s.schema.Schema.enumeration | ||
|
||
sealed abstract class OldStyleLeftRight(_value: String, _name: String, _intValue: Int, _hints: Hints) extends Enumeration.Value { | ||
override type EnumType = OldStyleLeftRight | ||
override val value: String = _value | ||
override val name: String = _name | ||
override val intValue: Int = _intValue | ||
override val hints: Hints = _hints | ||
override def enumeration: Enumeration[EnumType] = OldStyleLeftRight | ||
@inline final def widen: OldStyleLeftRight = this | ||
} | ||
object OldStyleLeftRight extends Enumeration[OldStyleLeftRight] with ShapeTag.Companion[OldStyleLeftRight] { | ||
val id: ShapeId = ShapeId("smithy4s.example", "oldStyleLeftRight") | ||
|
||
val hints: Hints = Hints.empty | ||
|
||
case object LEFT extends OldStyleLeftRight("left", "LEFT", 0, Hints()) | ||
case object RIGHT extends OldStyleLeftRight("right", "RIGHT", 1, Hints()) | ||
|
||
val values: List[OldStyleLeftRight] = List( | ||
LEFT, | ||
RIGHT, | ||
) | ||
val tag: EnumTag = EnumTag.StringEnum | ||
implicit val schema: Schema[OldStyleLeftRight] = enumeration(tag, values).withId(id).addHints(hints) | ||
} |
34 changes: 34 additions & 0 deletions
34
modules/bootstrapped/src/generated/smithy4s/example/OneTwo.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,34 @@ | ||
package smithy4s.example | ||
|
||
import smithy4s.Enumeration | ||
import smithy4s.Hints | ||
import smithy4s.Schema | ||
import smithy4s.ShapeId | ||
import smithy4s.ShapeTag | ||
import smithy4s.schema.EnumTag | ||
import smithy4s.schema.Schema.enumeration | ||
|
||
sealed abstract class OneTwo(_value: String, _name: String, _intValue: Int, _hints: Hints) extends Enumeration.Value { | ||
override type EnumType = OneTwo | ||
override val value: String = _value | ||
override val name: String = _name | ||
override val intValue: Int = _intValue | ||
override val hints: Hints = _hints | ||
override def enumeration: Enumeration[EnumType] = OneTwo | ||
@inline final def widen: OneTwo = this | ||
} | ||
object OneTwo extends Enumeration[OneTwo] with ShapeTag.Companion[OneTwo] { | ||
val id: ShapeId = ShapeId("smithy4s.example", "oneTwo") | ||
|
||
val hints: Hints = Hints.empty | ||
|
||
case object ONE extends OneTwo("ONE", "ONE", 1, Hints()) | ||
case object TWO extends OneTwo("TWO", "TWO", 2, Hints()) | ||
|
||
val values: List[OneTwo] = List( | ||
ONE, | ||
TWO, | ||
) | ||
val tag: EnumTag = EnumTag.IntEnum | ||
implicit val schema: Schema[OneTwo] = enumeration(tag, values).withId(id).addHints(hints) | ||
} |
19 changes: 19 additions & 0 deletions
19
modules/bootstrapped/src/generated/smithy4s/example/StringWithEnumTraits.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,19 @@ | ||
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 StringWithEnumTraits extends Newtype[String] { | ||
val id: ShapeId = ShapeId("smithy4s.example", "StringWithEnumTraits") | ||
val hints: Hints = Hints( | ||
smithy4s.example.OldStyleLeftRight.RIGHT.widen, | ||
smithy4s.example.OneTwo.ONE.widen, | ||
smithy4s.example.LeftRight.LEFT.widen, | ||
) | ||
val underlyingSchema: Schema[String] = string.withId(id).addHints(hints) | ||
implicit val schema: Schema[StringWithEnumTraits] = 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
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 @@ | ||
$version: "2.0" | ||
|
||
namespace smithy4s.example | ||
|
||
intEnum oneTwo { | ||
ONE = 1 | ||
TWO = 2 | ||
} | ||
|
||
enum leftRight { | ||
LEFT = "left" | ||
RIGHT = "right" | ||
} | ||
|
||
@enum([{ | ||
name: "LEFT" | ||
value: "left" | ||
}, { | ||
name: "RIGHT" | ||
value: "right" | ||
}]) | ||
string oldStyleLeftRight | ||
|
||
@oneTwo(1) | ||
@leftRight("left") | ||
@oldStyleLeftRight("right") | ||
string StringWithEnumTraits |