Add a root meta-trait to declare root shapes#3079
Draft
JordonPhillips wants to merge 1 commit into
Draft
Conversation
This adds a new `root` meta-trait. This trait marks a trait as a rooting trait. Any shape marked by a rooting trait is considered to be a root shape. Root shapes are shapes that are always considered to be referenced. Currently, service shapes and traits are considered to be root shapes. A new metadata trait is being added that will also define new root shapes. Beyond that, this trait is a necessary prerequisite for using Smithy to define schemas and use-cases that are not bound to the context of a service API. For example, imagine a theoretical `jsonSchema` trait that uses Smithy to define a plain JSONSchema definition that isn't tied to OpenAPI. We wouldn't want those shapes to be considered unreferenced because that might mean they get filtered away inappropriately and it would mean the unreferenced shape linter would start producing a huge amount of noise.
321333b to
3f26a93
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a new
rootmeta-trait. This trait marks a trait as a rooting trait. Any shape marked by a rooting trait is considered to be a root shape. Root shapes are shapes that are always considered to be referenced.Currently, service shapes and traits are considered to be root shapes. A new metadata trait is being added that will also define new root shapes
Beyond that, this trait is a necessary prerequisite for using Smithy to define schemas and use-cases that are not bound to the context of a service API.
For example, imagine a theoretical
jsonSchematrait that uses Smithy to define a plain JSONSchema definition that isn't tied to OpenAPI. We wouldn't want those shapes to be considered unreferenced because that might mean they get filtered away inappropriately and it would mean the unreferenced shape linter would start producing a huge amount of noise.Or for a more near-term example that still tied to services, this could be used with events:
The downside to this is that it can become more work to keep the sizes of projections down. You'll need to do more to filter out things that you don't want. I see the excludeShapesByTrait transform getting a lot more usage, for example.
This is a draft because it was a bit of a brain blast and I want to discuss this quite a bit more offline with folks before moving forward.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.