-
Notifications
You must be signed in to change notification settings - Fork 50
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
fix: remove invalid defaults for some services #1112
fix: remove invalid defaults for some services #1112
Conversation
6c5d483
to
dacde52
Compare
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.
Looks pretty good, thanks @milesziemer.
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean { | ||
val serviceId = settings.service | ||
return serviceId in removeDefaultsFrom | ||
} |
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.
Nit: Can be simplified:
override fun enabledForService(model: Model, settings: KotlinSettings) =
settings.service in removeDefaultsFrom
private fun shouldRemoveRootDefault(shape: Shape, removeDefaultsFrom: Set<ShapeId>): Boolean = | ||
shape !is MemberShape && removeDefaultsFrom.contains(shape.id) && shape.hasTrait<DefaultTrait>() | ||
|
||
private fun shouldRemoveMemberDefault(shape: Shape, removeDefaultsFrom: Set<ShapeId>): Boolean = | ||
shape is MemberShape && removeDefaultsFrom.contains(shape.target) && shape.hasTrait<DefaultTrait>() |
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.
Style:
removeDefaultsFrom.contains(shape.id)
→shape.id in removeDefaultsFrom
removeDefaultsFrom.contains(shape.target)
→shape.target in removeDefaultsFrom
import software.amazon.smithy.model.traits.DefaultTrait | ||
import kotlin.test.assertFalse | ||
|
||
class RemoveDefaultsTest { |
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.
suggestion: This test could be improved by verifying it doesn't remove defaults from shapes not in the set and that it also removes them from member shapes.
ad40494
to
21e392c
Compare
Adds an integration that removes the default value from certain shapes in some services where the default value is 0, but the service expects a value > 0.
21e392c
to
6aebd1c
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
closing in favor of #1116 |
Issue #
N/A
Description of changes
Adds a customization that removes default values from certain shapes for some services. These default values could cause
issues if the service expects a value > 0. Removing the default means these values aren't set under the hood causing unexpected request failures.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.