-
Notifications
You must be signed in to change notification settings - Fork 220
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
Make adoption of Unit easier for existing models #1034
Make adoption of Unit easier for existing models #1034
Conversation
Considering Unit a neighbor of operations when it is the declared or implicit input or output means that any other shape named Unit in the service closure will be considered conflicting where it was not previously. By removing this relationship, existing models will continue to work without renames.
@@ -130,6 +135,11 @@ public boolean isInlined(Shape shape) { | |||
return isInlined(target); | |||
} | |||
|
|||
// smithy.api#Unit is always inlined | |||
if (UnitTypeTrait.UNIT.equals(shape.getId())) { |
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.
I think things like API Gateway will generate names for anonymous objects (which this code would cause). Is there a way to generate a Unit shape in the JSON Schema for tagged unions members, but not for operation input?
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.
I have hacked this PR to do this, but the implementation via a boolean flag screams "this is not the right way to accomplish this."
This would be so much easier if we had service attached shapes; then I could meaningfully use relationship data to examine what's actually attached to the scope of the conversion, and a lot of this code would be a lot simpler.
4058704
to
96e288d
Compare
smithy-jsonschema/src/main/java/software/amazon/smithy/jsonschema/DeconflictingStrategy.java
Outdated
Show resolved
Hide resolved
By always inlining Unit as an empty object rather than creating a pointer to a Unit schema, models will not need to rename either the built-in Unit or Units of their own in order to perform JSONSchema conversion.
96e288d
to
ec7913b
Compare
Description of changes:
Prevents Unit from being added to the service closure if it is only used by operation inputs and/or outputs, and
special-cases Unit for both operations and unions in JSONSchema conversion.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.