-
Notifications
You must be signed in to change notification settings - Fork 68
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
Update to smithy 2.0; add int enum support #352
Conversation
if (hints.get[IntEnum].isDefined) { | ||
MetaDecode | ||
.from( | ||
s"Enum[${values.map(_.stringValue).mkString(",")}]" |
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.
Not sure if we want to be using the stringValue
in cases like this.. probably not, but that's what I had in the other PR. The ordinal would look a bit more confusing, but would be more relevant
smithy.api.Trait(Some("integer"), None, None, None), | ||
smithy.api.Trait(Some("integer"), None, None), |
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.
This change is caused by the difference between 1.22.0
and 1.21.0-rc1
. Once we update to smithy 2 (the real one), this will change back.
@@ -12,7 +12,9 @@ sealed abstract class LowHigh(_value: String, _name: String, _ordinal: Int) exte | |||
object LowHigh extends smithy4s.Enumeration[LowHigh] with smithy4s.ShapeTag.Companion[LowHigh] { | |||
val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "LowHigh") | |||
|
|||
val hints : smithy4s.Hints = smithy4s.Hints.empty | |||
val hints : smithy4s.Hints = smithy4s.Hints( | |||
smithy.api.Enum(List(smithy.api.EnumDefinition(smithy.api.NonEmptyString("Low"), Some(smithy.api.EnumConstantBodyName("LOW")), None, None, None), smithy.api.EnumDefinition(smithy.api.NonEmptyString("High"), Some(smithy.api.EnumConstantBodyName("HIGH")), None, None, None))), |
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.
These are here since this enum is still using the v1 syntax. Not sure if we want to remove these or not.. probably doesn't impact usage, just readability.
Age.schema.optional[StructureWithRefinedTypes]("age", _.age).addHints(smithy.api.Default()), | ||
PersonAge.schema.optional[StructureWithRefinedTypes]("personAge", _.personAge).addHints(smithy.api.Default()), |
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.
Going to see why these showed up... they shouldn't have
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.
The reason these showed up is that smithy 2.0 does the following when loading v1 models:
Inject an appropriate `@default` trait on structure members that targeted
shapes with a default zero value and were not marked with the `@box`
trait
Not sure how we want to proceed here.. especially since the default seems to be empty? I guess that indicates a null default? In that case, this could be problematic with required fields since they'll get the empty default trait as well.. which would indicate that a Never mind about that point. required and default are mutually exclusive.null
default is valid, where it isn't.
intEnum FaceCard { | ||
@enumValue(1) | ||
JACK | ||
@enumValue(2) | ||
QUEEN | ||
@enumValue(3) | ||
KING | ||
@enumValue(4) | ||
ACE | ||
@enumValue(5) | ||
JOKER | ||
} | ||
|
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.
With the real smithy 2 release we can change these to:
intEnum {
JACK = 1
QUEEN = 2
... etc
@@ -244,7 +244,8 @@ object CollisionAvoidance { | |||
"BigDecimal", | |||
"Map", | |||
"List", | |||
"Set" | |||
"Set", | |||
"None" |
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.
Idk if this is the right solution here.. but it works. There was a collision between scala's Option#None and an enum member in the aws-http module
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.
yeah that's fine
Alright so the plugin tests are failing with:
I've been trying to figure out why this might be, so far no luck. Any ideas are appreciated! |
@lewisjkl, the scripted tests fail because some of them pull an incompatible version of aws-issued smithy libraries : |
Ported over from #189.
Note: This PR is created against the latest published snapshot of smithy 2.0 (version
1.21.0-rc1
). There have been a few improvements/changes since then that I will point out in the comments below.