Add support for 1.0 downgrades and serialization#1403
Merged
Conversation
This commit adds the ability to downgrade the in-memory semantic model to 1.0 models, and adds support for serializing 1.0 JSON AST models to ModelSerializer.
mtdowling
commented
Sep 14, 2022
| return this; | ||
| } | ||
|
|
||
| @Override |
Member
Author
There was a problem hiding this comment.
The fluent interface here needed this override for it to work
sugmanue
approved these changes
Sep 14, 2022
gosar
reviewed
Sep 15, 2022
|
|
||
| Node.assertEquals(actual, expected); | ||
|
|
||
| // Now validate the file is serialized correctly when downgraded to 1.0. |
Contributor
There was a problem hiding this comment.
Would we be able to have a test that starts a 1.0 model, loads it and serializes it as 1.0 and compares?
gosar
reviewed
Sep 16, 2022
Comment on lines
+122
to
+123
| for (StructureShape structure : model.getStructureShapes()) { | ||
| for (MemberShape member : structure.getAllMembers().values()) { |
Contributor
There was a problem hiding this comment.
could have been getMemberShapesWithTrait like above?
smithy-model/src/main/java/software/amazon/smithy/model/transform/DowngradeToV1.java
Show resolved
Hide resolved
| * @param model Model to downgrade. | ||
| * @return Returns the downgraded model. | ||
| */ | ||
| public Model downgradeToV1(Model model) { |
Contributor
There was a problem hiding this comment.
The javadoc does say 'remove' a bunch, but probably worth an explicit callout that this is lossy.
| + "structure Struct {\n" | ||
| + " @default(10)\n" | ||
| + " foo: MyInteger\n" | ||
| + " baz: PrimitiveInteger = null\n" |
Contributor
There was a problem hiding this comment.
Good to add a member which has the zero value and make assertions on that
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 commit adds the ability to downgrade the in-memory semantic model to 1.0 models, and adds support for serializing 1.0 JSON AST models to ModelSerializer.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.