Skip to content

Update to Smithy 1.23.x which supports IDL v2 #581

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

Merged
merged 3 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ allprojects {
version = "0.11.0"
}

extra["smithyVersion"] = "[1.21.0,1.22.0["
extra["smithyVersion"] = "[1.23.0,1.24.0["

// The root project doesn't produce a JAR.
tasks["jar"].enabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import software.amazon.smithy.codegen.core.SymbolDependencyContainer;
import software.amazon.smithy.codegen.core.SymbolReference;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.loader.Prelude;
import software.amazon.smithy.model.shapes.MemberShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.traits.DeprecatedTrait;
Expand Down Expand Up @@ -265,14 +266,20 @@ boolean writeMemberDocs(Model model, MemberShape member) {
return member.getMemberTrait(model, DocumentationTrait.class)
.map(DocumentationTrait::getValue)
.map(docs -> {
if (member.getMemberTrait(model, DeprecatedTrait.class).isPresent()) {
if (member.getTrait(DeprecatedTrait.class).isPresent() || isTargetDeprecated(model, member)) {
docs = "@deprecated\n\n" + docs;
}
writeDocs(docs);
return true;
}).orElse(false);
}

private boolean isTargetDeprecated(Model model, MemberShape member) {
return model.expectShape(member.getTarget()).getTrait(DeprecatedTrait.class).isPresent()
// don't consider deprecated prelude shapes (like PrimitiveBoolean)
&& !Prelude.isPreludeShape(member.getTarget());
}

/**
* Adds one or more dependencies to the generated code.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,6 @@ public void skipsFilterForStructureWithoutSensitiveData() {
+ "})");
}

@Test
public void filtersSensitiveMemberPointingToStructure() {
testStructureCodegen("test-sensitive-member-pointing-to-structure.smithy",
"export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n"
+ " ...obj,\n"
+ " ...(obj.sensitiveFoo && { sensitiveFoo:\n"
+ " SENSITIVE_STRING\n"
+ " }),\n"
+ "})");
}

@Test
public void callsFilterForUnionWithSensitiveData() {
testStructureCodegen("test-union-with-sensitive-data.smithy",
Expand Down Expand Up @@ -339,17 +328,6 @@ public void filtersSensitiveUnion() {
+ "})");
}

@Test
public void filtersSensitiveMemberPointingToUnion() {
testStructureCodegen("test-sensitive-member-pointing-to-union.smithy",
"export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n"
+ " ...obj,\n"
+ " ...(obj.sensitiveFoo && { sensitiveFoo:\n"
+ " SENSITIVE_STRING\n"
+ " }),\n"
+ "})");
}

@Test
public void callsFilterForListWithStructureWithSensitiveData() {
testStructureCodegen("test-list-with-structure-with-sensitive-data.smithy",
Expand Down Expand Up @@ -433,17 +411,6 @@ public void skipsFilterForInsensitiveList() {
+ "})");
}

@Test
public void filtersSensitiveMemberPointingToList() {
testStructureCodegen("test-sensitive-member-pointing-to-list.smithy",
"export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n"
+ " ...obj,\n"
+ " ...(obj.sensitiveFoo && { sensitiveFoo:\n"
+ " SENSITIVE_STRING\n"
+ " }),\n"
+ "})");
}

@Test
public void callsFilterForMapWithStructureWithSensitiveData() {
testStructureCodegen("test-map-with-structure-with-sensitive-data.smithy",
Expand Down Expand Up @@ -524,17 +491,6 @@ public void filtersSensitiveMap() {
+ "})");
}

@Test
public void filtersSensitiveMemberPointingToMap() {
testStructureCodegen("test-sensitive-member-pointing-to-map.smithy",
"export const GetFooInputFilterSensitiveLog = (obj: GetFooInput): any => ({\n"
+ " ...obj,\n"
+ " ...(obj.sensitiveFoo && { sensitiveFoo:\n"
+ " SENSITIVE_STRING\n"
+ " }),\n"
+ "})");
}

@Test
public void skipsFilterForInsensitiveMap() {
testStructureCodegen("test-insensitive-map.smithy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ structure GetFooInput {
}

list PhoneNumbersList {
@sensitive
member: String
member: SensitiveString
}

@sensitive
string SensitiveString
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ list UserList {
structure User {
username: String,

@sensitive
password: String
password: SensitiveString
}

@sensitive
string SensitiveString
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ list UserList {
union TestUnion {
bar: String,

@sensitive
sensitiveBar: String
sensitiveBar: SensitiveString
}

@sensitive
string SensitiveString
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ structure GetFooInput {
map PhoneNumbersMap {
key: String,

@sensitive
value: String
value: SensitiveString
}

@sensitive
string SensitiveString
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ map UserMap {
structure User {
username: String,

@sensitive
password: String
password: SensitiveString
}

@sensitive
string SensitiveString
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ map UserMap {
union TestUnion {
bar: String,

@sensitive
sensitiveBar: String
sensitiveBar: SensitiveString
}

@sensitive
string SensitiveString

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ operation GetFoo {
structure GetFooInput {
username: String,

@sensitive
password: String
password: SensitiveString
}

@sensitive
string SensitiveString
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ structure GetFooInput {
structure User {
username: String,

@sensitive
password: String
password: SensitiveString
}

@sensitive
string SensitiveString
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ structure GetFooInput {
union TestUnion {
bar: String,

@sensitive
sensitiveBar: String
sensitiveBar: SensitiveString
}

@sensitive
string SensitiveString