diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/CreatesTraitTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/CreatesTraitTest.java index 0aa918b88cb..29f268a062f 100644 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/CreatesTraitTest.java +++ b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/CreatesTraitTest.java @@ -9,11 +9,13 @@ import com.example.traits.enums.IntEnumTrait; import com.example.traits.enums.StringEnumTrait; import com.example.traits.enums.SuitTrait; +import com.example.traits.lists.DocumentListTrait; import com.example.traits.lists.ListMember; import com.example.traits.lists.NumberListTrait; import com.example.traits.lists.StringListTrait; import com.example.traits.lists.StructureListTrait; import com.example.traits.maps.MapValue; +import com.example.traits.maps.StringDocumentMapTrait; import com.example.traits.maps.StringStringMapTrait; import com.example.traits.maps.StringToStructMapTrait; import com.example.traits.mixins.StructWithMixinTrait; @@ -81,6 +83,10 @@ static Stream createTraitTests() { ListMember.builder().a("first").b(1).c("other").build().toNode(), ListMember.builder().a("second").b(2).c("more").build().toNode() )), + Arguments.of(DocumentListTrait.ID, ArrayNode.fromNodes( + ObjectNode.builder().withMember("a", "b").build(), + ObjectNode.builder().withMember("c", "d").withMember("e", "f").build() + )), // Maps Arguments.of(StringStringMapTrait.ID, StringStringMapTrait.builder() .putValues("a", "first").putValues("b", "other").build().toNode() @@ -90,6 +96,13 @@ static Stream createTraitTests() { .putValues("two", MapValue.builder().a("bar").b(4).build()) .build().toNode() ), + Arguments.of(StringDocumentMapTrait.ID, StringDocumentMapTrait.builder() + .putValues("a", ObjectNode.builder().withMember("a", "a").build().toNode()) + .putValues("b", ObjectNode.builder().withMember("b", "b").build().toNode()) + .putValues("string", Node.from("stuff")) + .putValues("number", Node.from(1)) + .build().toNode() + ), // Mixins Arguments.of(StructureListWithMixinMemberTrait.ID, ArrayNode.fromNodes(ObjectNode.builder().withMember("a", "a").withMember("d", "d").build())), diff --git a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LoadsFromModelTest.java b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LoadsFromModelTest.java index 377b4953f34..5a14fe9951b 100644 --- a/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LoadsFromModelTest.java +++ b/smithy-trait-codegen/src/it/java/software/amazon/smithy/traitcodegen/test/LoadsFromModelTest.java @@ -16,10 +16,12 @@ import com.example.traits.idref.IdRefStructTrait; import com.example.traits.idref.IdRefStructWithNestedIdsTrait; import com.example.traits.idref.NestedIdRefHolder; +import com.example.traits.lists.DocumentListTrait; import com.example.traits.lists.ListMember; import com.example.traits.lists.NumberListTrait; import com.example.traits.lists.StructureListTrait; import com.example.traits.maps.MapValue; +import com.example.traits.maps.StringDocumentMapTrait; import com.example.traits.maps.StringStringMapTrait; import com.example.traits.maps.StringToStructMapTrait; import com.example.traits.mixins.ListMemberWithMixin; @@ -115,6 +117,11 @@ static Stream loadsModelTests() { MapUtils.of("getValues", ListUtils.of( ListMember.builder().a("first").b(1).c("other").build(), ListMember.builder().a("second").b(2).c("more").build()))), + Arguments.of("lists/document-list-trait.smithy", DocumentListTrait.class, + MapUtils.of("getValues", ListUtils.of( + ObjectNode.builder().withMember("a", "a").build().toNode(), + ObjectNode.builder().withMember("b", "b").withMember("c", 1).build().toNode(), + Node.from("string")))), // Maps Arguments.of("maps/string-string-map-trait.smithy", StringStringMapTrait.class, MapUtils.of("getValues", MapUtils.of("a", "stuff", @@ -123,6 +130,13 @@ static Stream loadsModelTests() { MapUtils.of("getValues", MapUtils.of( "one", MapValue.builder().a("foo").b(2).build(), "two", MapValue.builder().a("bar").b(4).build()))), + Arguments.of("maps/string-to-document-map-trait.smithy", StringDocumentMapTrait.class, + MapUtils.of("getValues", MapUtils.of( + "a", ObjectNode.builder().withMember("a", "a").build().toNode(), + "b", ObjectNode.builder().withMember("b", "b").withMember("c", 1).build().toNode(), + "c", Node.from("stuff"), + "d", Node.from(1) + ))), // Mixins Arguments.of("mixins/struct-with-mixin-member.smithy", StructureListWithMixinMemberTrait.class, MapUtils.of("getValues", ListUtils.of( diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/defaults/defaults.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/defaults/defaults.smithy index dbd2c195025..79cc9718be9 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/defaults/defaults.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/defaults/defaults.smithy @@ -5,5 +5,4 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.defaults#StructDefaults @StructDefaults -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/documents/document-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/documents/document-trait.smithy index b750854052c..bb585727672 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/documents/document-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/documents/document-trait.smithy @@ -4,9 +4,5 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.documents#DocumentTrait -@DocumentTrait({ - metadata: "woo" - more: "yay" -}) -structure myStruct { -} +@DocumentTrait({ metadata: "woo", more: "yay" }) +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/documents/struct-with-nested-document.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/documents/struct-with-nested-document.smithy index 375e3706c48..ef3cdae5b23 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/documents/struct-with-nested-document.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/documents/struct-with-nested-document.smithy @@ -5,10 +5,6 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.documents#structWithNestedDocument @structWithNestedDocument( - doc: { - foo: "bar" - fizz: "buzz" - } + doc: { foo: "bar", fizz: "buzz" } ) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/enums/enum-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/enums/enum-trait.smithy index b253f4ad359..03c97e7f207 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/enums/enum-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/enums/enum-trait.smithy @@ -5,5 +5,4 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.enums#StringEnum @StringEnum("yes") -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/enums/string-enum-compatibility.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/enums/string-enum-compatibility.smithy index 943878846ef..8724d14013e 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/enums/string-enum-compatibility.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/enums/string-enum-compatibility.smithy @@ -5,5 +5,4 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.enums#Suit @Suit("club") -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/number-trait-errors.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/number-trait-errors.smithy index fc6471fa9b0..826455e5379 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/number-trait-errors.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/number-trait-errors.smithy @@ -9,5 +9,3 @@ namespace test.smithy.traitcodegen.numbers @ShortTrait("bad") @DoubleTrait("bad") structure structWithInvalidStringInput {} - - diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/set-trait-errors.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/set-trait-errors.smithy index 33b33db404f..31fca071971 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/set-trait-errors.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/set-trait-errors.smithy @@ -4,9 +4,7 @@ namespace test.smithy.traitcodegen.uniqueitems // Doesnt have unique items. Expect failure @NumberSetTrait([1, 1, 3, 4]) -structure repeatedNumberValues { -} +structure repeatedNumberValues {} @StringSetTrait(["a", "a", "b"]) -structure repeatedStringValues { -} +structure repeatedStringValues {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/structure-trait-warns.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/structure-trait-warns.smithy index 8af8dcedf71..44c6c4ffd29 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/structure-trait-warns.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/errorfiles/structure-trait-warns.smithy @@ -2,24 +2,15 @@ $version: "2.0" namespace test.smithy.traitcodegen.structures - @structureTrait( fieldA: "first" fieldB: false - fieldC: { - fieldN: "nested" - fieldQ: true - fieldZ: "A" - } + fieldC: { fieldN: "nested", fieldQ: true, fieldZ: "A" } fieldD: ["a", "b", "c"] - fieldE: { - a: "one" - b: "two" - } - fieldF: 100.01, - fieldG: 100, - extraA: 100, + fieldE: { a: "one", b: "two" } + fieldF: 100.01 + fieldG: 100 + extraA: 100 extraB: 200 ) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/idref/idref-map.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/idref/idref-map.smithy index f73eb02e873..a784f169b96 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/idref/idref-map.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/idref/idref-map.smithy @@ -4,10 +4,7 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.idref#IdRefMap -@IdRefMap( - a: IdRefTarget1 - b: IdRefTarget2 -) +@IdRefMap(a: IdRefTarget1, b: IdRefTarget2) structure myStruct {} string IdRefTarget1 diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/idref/idref-struct-with-nested-refs.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/idref/idref-struct-with-nested-refs.smithy index cc3dc064d81..c81da2e4e80 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/idref/idref-struct-with-nested-refs.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/idref/idref-struct-with-nested-refs.smithy @@ -5,14 +5,9 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.idref#IdRefStructWithNestedIds @IdRefStructWithNestedIds( - idRefHolder: { - id: IdRefTarget1 - } + idRefHolder: { id: IdRefTarget1 } idList: [IdRefTarget1, IdRefTarget2] - idMap: { - a: IdRefTarget1 - b: IdRefTarget2 - } + idMap: { a: IdRefTarget1, b: IdRefTarget2 } ) structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/document-list-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/document-list-trait.smithy new file mode 100644 index 00000000000..bf83c25b812 --- /dev/null +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/document-list-trait.smithy @@ -0,0 +1,17 @@ +$version: "2.0" + +namespace test.smithy.traitcodegen + +use test.smithy.traitcodegen.lists#DocumentListTrait + +@DocumentListTrait([ + { + a: "a" + } + { + b: "b" + c: 1 + } + "string" +]) +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/number-list-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/number-list-trait.smithy index cab37d2271d..4498a3426b5 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/number-list-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/number-list-trait.smithy @@ -5,5 +5,4 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.lists#NumberListTrait @NumberListTrait([1, 2, 3, 4, 5]) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/string-list-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/string-list-trait.smithy index 8821df4dfd9..15e073b8cf8 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/string-list-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/string-list-trait.smithy @@ -5,5 +5,4 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.lists#StringListTrait @StringListTrait(["a", "b", "c", "d"]) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/struct-list-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/struct-list-trait.smithy index 528317b1fb3..be8bf22e19b 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/struct-list-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/lists/struct-list-trait.smithy @@ -9,11 +9,11 @@ use test.smithy.traitcodegen.lists#StructureListTrait a: "first" b: 1 c: "other" - } { + } + { a: "second" b: 2 c: "more" } ]) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-string-map-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-string-map-trait.smithy index bf824192e2d..4eae963c816 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-string-map-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-string-map-trait.smithy @@ -4,10 +4,5 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.maps#StringStringMap -@StringStringMap( - a: "stuff" - b: "other" - c: "more!" -) -structure myStruct { -} +@StringStringMap(a: "stuff", b: "other", c: "more!") +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-to-document-map-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-to-document-map-trait.smithy new file mode 100644 index 00000000000..bd4b0b92098 --- /dev/null +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-to-document-map-trait.smithy @@ -0,0 +1,13 @@ +$version: "2.0" + +namespace test.smithy.traitcodegen + +use test.smithy.traitcodegen.maps#StringDocumentMap + +@StringDocumentMap( + a: { a: "a" } + b: { b: "b", c: 1 } + c: "stuff" + d: 1 +) +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-to-struct-map-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-to-struct-map-trait.smithy index 55d20f23f03..b8b70af3fdc 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-to-struct-map-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/maps/string-to-struct-map-trait.smithy @@ -5,14 +5,7 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.maps#StringToStructMap @StringToStructMap( - one: { - a: "foo" - b: 2 - } - two: { - a: "bar" - b: 4 - } + one: { a: "foo", b: 2 } + two: { a: "bar", b: 4 } ) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/mixins/struct-with-mixin-member.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/mixins/struct-with-mixin-member.smithy index 6c908fccccc..d0f920152cf 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/mixins/struct-with-mixin-member.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/mixins/struct-with-mixin-member.smithy @@ -10,7 +10,8 @@ use test.smithy.traitcodegen.mixins#structureListWithMixinMember b: 1 c: "other" d: "mixed-in" - } { + } + { a: "second" b: 2 c: "more" diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/mixins/struct-with-only-mixin-member.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/mixins/struct-with-only-mixin-member.smithy index dc738524fc2..80076918588 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/mixins/struct-with-only-mixin-member.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/mixins/struct-with-only-mixin-member.smithy @@ -4,8 +4,5 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.mixins#structWithMixin -@structWithMixin( - d: "mixed-in" -) -structure myStruct { -} +@structWithMixin(d: "mixed-in") +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/names/snake-case-struct.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/names/snake-case-struct.smithy index 6f97ca27f17..00fe3abce13 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/names/snake-case-struct.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/names/snake-case-struct.smithy @@ -4,8 +4,5 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.names#snake_case_structure -@snake_case_structure( - snake_case_member: "stuff" -) -structure myStruct { -} +@snake_case_structure(snake_case_member: "stuff") +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/structures/struct-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/structures/struct-trait.smithy index df16a7253ef..89e7ad3f1e3 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/structures/struct-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/structures/struct-trait.smithy @@ -7,18 +7,10 @@ use test.smithy.traitcodegen.structures#structureTrait @structureTrait( fieldA: "first" fieldB: false - fieldC: { - fieldN: "nested" - fieldQ: true - fieldZ: "A" - } + fieldC: { fieldN: "nested", fieldQ: true, fieldZ: "A" } fieldD: ["a", "b", "c"] - fieldE: { - a: "one" - b: "two" - } - fieldF: 100.01, + fieldE: { a: "one", b: "two" } + fieldF: 100.01 fieldG: 100 ) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/structures/struct-with-non-existent-collections.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/structures/struct-with-non-existent-collections.smithy index ab195d5d6b5..d050edbbe91 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/structures/struct-with-non-existent-collections.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/structures/struct-with-non-existent-collections.smithy @@ -7,11 +7,6 @@ use test.smithy.traitcodegen.structures#structureTrait @structureTrait( fieldA: "first" fieldB: false - fieldC: { - fieldN: "nested" - fieldQ: true - fieldZ: "A" - } + fieldC: { fieldN: "nested", fieldQ: true, fieldZ: "A" } ) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/number-set-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/number-set-trait.smithy index 3dd069c0736..167d38bb181 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/number-set-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/number-set-trait.smithy @@ -5,5 +5,4 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.uniqueitems#NumberSetTrait @NumberSetTrait([1, 2, 3, 4]) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/string-set-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/string-set-trait.smithy index 8145ca6d370..57e885e047c 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/string-set-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/string-set-trait.smithy @@ -5,5 +5,4 @@ namespace test.smithy.traitcodegen use test.smithy.traitcodegen.uniqueitems#StringSetTrait @StringSetTrait(["a", "b", "c", "d"]) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/struct-set-trait.smithy b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/struct-set-trait.smithy index 0e0c14b2ef8..0eee8fe05e5 100644 --- a/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/struct-set-trait.smithy +++ b/smithy-trait-codegen/src/it/resources/software/amazon/smithy/traitcodegen/test/uniqueitems/struct-set-trait.smithy @@ -9,11 +9,11 @@ use test.smithy.traitcodegen.uniqueitems#StructureSetTrait a: "first" b: 1 c: "other" - } { + } + { a: "second" b: 2 c: "more" } ]) -structure myStruct { -} +structure myStruct {} diff --git a/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/TraitCodegenSymbolProvider.java b/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/TraitCodegenSymbolProvider.java index 4652143e1ec..3affb9bff58 100644 --- a/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/TraitCodegenSymbolProvider.java +++ b/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/TraitCodegenSymbolProvider.java @@ -15,7 +15,7 @@ import software.amazon.smithy.codegen.core.Symbol; import software.amazon.smithy.codegen.core.SymbolProvider; import software.amazon.smithy.model.Model; -import software.amazon.smithy.model.node.ObjectNode; +import software.amazon.smithy.model.node.Node; import software.amazon.smithy.model.shapes.BigDecimalShape; import software.amazon.smithy.model.shapes.BigIntegerShape; import software.amazon.smithy.model.shapes.BlobShape; @@ -166,7 +166,7 @@ public Symbol structureShape(StructureShape shape) { @Override public Symbol documentShape(DocumentShape shape) { - return TraitCodegenUtils.fromClass(ObjectNode.class); + return TraitCodegenUtils.fromClass(Node.class); } @Override diff --git a/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/generators/FromNodeMapperVisitor.java b/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/generators/FromNodeMapperVisitor.java index 3b0f2bd145b..c536275935b 100644 --- a/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/generators/FromNodeMapperVisitor.java +++ b/smithy-trait-codegen/src/main/java/software/amazon/smithy/traitcodegen/generators/FromNodeMapperVisitor.java @@ -112,6 +112,7 @@ public Void floatShape(FloatShape shape) { @Override public Void documentShape(DocumentShape shape) { + writer.writeWithNoFormatting(varName); return null; } diff --git a/smithy-trait-codegen/src/test/java/software/amazon/smithy/traitcodegen/TraitCodegenPluginTest.java b/smithy-trait-codegen/src/test/java/software/amazon/smithy/traitcodegen/TraitCodegenPluginTest.java index 916faabb073..1d3bbcc00c4 100644 --- a/smithy-trait-codegen/src/test/java/software/amazon/smithy/traitcodegen/TraitCodegenPluginTest.java +++ b/smithy-trait-codegen/src/test/java/software/amazon/smithy/traitcodegen/TraitCodegenPluginTest.java @@ -28,7 +28,7 @@ public class TraitCodegenPluginTest { - private static final int EXPECTED_NUMBER_OF_FILES = 56; + private static final int EXPECTED_NUMBER_OF_FILES = 58; private MockManifest manifest; private Model model; diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/defaults/defaults.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/defaults/defaults.smithy index ff89a1e174d..8f61ed31cb1 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/defaults/defaults.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/defaults/defaults.smithy @@ -6,28 +6,40 @@ namespace test.smithy.traitcodegen.defaults structure StructDefaults { @default([]) defaultList: StringList + @default({}) defaultMap: StringMap + @default(true) defaultBoolean: Boolean + @default("default") defaultString: String + @default(1) defaultByte: Byte + @default(1) defaultShort: Short + @default(1) defaultInt: Integer + @default(1) defaultLong: Long + @default(2.2) defaultFloat: Float + @default(1.1) defaultDouble: Double + @default(100) defaultBigInt: BigInteger + @default(100.01) defaultBigDecimal: BigDecimal + @default("1985-04-12T23:20:50.52Z") defaultTimestamp: Timestamp } diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/enums/int-enum-trait.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/enums/int-enum-trait.smithy index 63793dc3b31..e6f34cd932d 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/enums/int-enum-trait.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/enums/int-enum-trait.smithy @@ -10,4 +10,3 @@ intEnum IntEnum { /// Negative response NO = 2 } - diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/enums/string-enum-compatibility.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/enums/string-enum-compatibility.smithy index 46ed2ec2e75..c14018ec267 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/enums/string-enum-compatibility.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/enums/string-enum-compatibility.smithy @@ -7,22 +7,21 @@ namespace test.smithy.traitcodegen.enums // ======================== // The following trait check that the plugin can generate traits from a // legacy string enum (i.e. a string with the @enum trait applied). - @enum([ { - name: "DIAMOND", + name: "DIAMOND" value: "diamond" - }, + } { - name: "CLUB", + name: "CLUB" value: "club" - }, + } { - name: "HEART", + name: "HEART" value: "heart" - }, + } { - name: "SPADE", + name: "SPADE" value: "spade" } ]) diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/idref/idref-list.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/idref/idref-list.smithy index 9a8cdf699f0..20234d9fb6d 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/idref/idref-list.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/idref/idref-list.smithy @@ -4,7 +4,6 @@ namespace test.smithy.traitcodegen.idref // The following trait check to make sure that Strings are converted to ShapeIds // when an @IdRef trait is added to a string - @trait list IdRefList { member: IdRefListmember diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/idref/idref-string.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/idref/idref-string.smithy index f660635ca29..dafacf95386 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/idref/idref-string.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/idref/idref-string.smithy @@ -4,7 +4,6 @@ namespace test.smithy.traitcodegen.idref // The following trait check to make sure that Strings are converted to ShapeIds // when an @IdRef trait is added to a string - @trait @idRef string IdRefString diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/lists/document-list-trait.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/lists/document-list-trait.smithy new file mode 100644 index 00000000000..b606dba7b18 --- /dev/null +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/lists/document-list-trait.smithy @@ -0,0 +1,8 @@ +$version: "2.0" + +namespace test.smithy.traitcodegen.lists + +@trait +list DocumentListTrait { + member: Document +} diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/manifest b/smithy-trait-codegen/src/test/resources/META-INF/smithy/manifest index e1e57d9efee..8e659e2ba7e 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/manifest +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/manifest @@ -13,8 +13,10 @@ ignored.smithy lists/number-list-trait.smithy lists/string-list-trait.smithy lists/struct-list-trait.smithy +lists/document-list-trait.smithy maps/string-string-map-trait.smithy maps/string-to-struct-map-trait.smithy +maps/string-to-document-map-trait.smithy mixins/struct-with-mixin-member.smithy mixins/struct-with-only-mixin-member.smithy names/snake-case-structure.smithy diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/maps/string-to-document-map-trait.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/maps/string-to-document-map-trait.smithy new file mode 100644 index 00000000000..867f9a95a3b --- /dev/null +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/maps/string-to-document-map-trait.smithy @@ -0,0 +1,9 @@ +$version: "2.0" + +namespace test.smithy.traitcodegen.maps + +@trait +map StringDocumentMap { + key: String + value: Document +} diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/mixins/struct-with-mixin-member.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/mixins/struct-with-mixin-member.smithy index 7ddf89b46bc..f4166cef18c 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/mixins/struct-with-mixin-member.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/mixins/struct-with-mixin-member.smithy @@ -4,7 +4,6 @@ namespace test.smithy.traitcodegen.mixins // The following trait checks that mixins are correctly flattened by // the trait codegen plugin - @trait list structureListWithMixinMember { member: listMemberWithMixin diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/mixins/struct-with-only-mixin-member.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/mixins/struct-with-only-mixin-member.smithy index bb41257e208..338596b53f2 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/mixins/struct-with-only-mixin-member.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/mixins/struct-with-only-mixin-member.smithy @@ -4,7 +4,6 @@ namespace test.smithy.traitcodegen.mixins // The following trait checks that mixins are correctly flattened by // the trait codegen plugin - @trait structure structWithMixin with [extras] {} diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/names/snake-case-structure.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/names/snake-case-structure.smithy index ad2c853fa87..f3a6c86ed61 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/names/snake-case-structure.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/names/snake-case-structure.smithy @@ -7,7 +7,6 @@ namespace test.smithy.traitcodegen.names // =================== // The following traits check that non-java-style names are // correctly changed into a useable Java-compatible name - /// Snake cased @trait structure snake_case_structure { diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/names/trait-with-name-conflict.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/names/trait-with-name-conflict.smithy index 0ed2f02dfad..457edf92148 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/names/trait-with-name-conflict.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/names/trait-with-name-conflict.smithy @@ -4,7 +4,6 @@ namespace test.smithy.traitcodegen.names // The following traits check to make sure that name conflicts between shapes and // java classes used in the generated codegen code are correctly handled - /// Conflicts with AbstractTrait base class @trait structure Abstract {} diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/nested/nested-namespace.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/nested/nested-namespace.smithy index 0dacd2eeae2..0afb579bc66 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/nested/nested-namespace.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/nested/nested-namespace.smithy @@ -7,7 +7,6 @@ namespace test.smithy.traitcodegen.nested // ======================= // The following traits check to make sure that traits within a nested smithy // namespace are mapped to a nested java namespace - /// A trait that should be generated in a nested namespace @trait structure nestedNamespaceTrait { diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/structures/structure-trait.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/structures/structure-trait.smithy index 9ff4944b609..e56dbb6868d 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/structures/structure-trait.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/structures/structure-trait.smithy @@ -60,6 +60,7 @@ structure NestedA { enum NestedB { /// An A! A + /// A B! B } @@ -68,6 +69,7 @@ enum NestedB { intEnum NestedC { /// An A! A = 1 + /// A B! B = 2 } diff --git a/smithy-trait-codegen/src/test/resources/META-INF/smithy/timestamps/struct-with-nested-timestamps.smithy b/smithy-trait-codegen/src/test/resources/META-INF/smithy/timestamps/struct-with-nested-timestamps.smithy index 394427bf6b3..960e4d8d82a 100644 --- a/smithy-trait-codegen/src/test/resources/META-INF/smithy/timestamps/struct-with-nested-timestamps.smithy +++ b/smithy-trait-codegen/src/test/resources/META-INF/smithy/timestamps/struct-with-nested-timestamps.smithy @@ -6,10 +6,13 @@ namespace test.smithy.traitcodegen.timestamps structure structWithNestedTimestamps { @required baseTime: basicTimestamp + @required dateTime: dateTimeTimestamp + @required httpDate: httpDateTimestamp + @required epochSeconds: epochSecondsTimestamp }