Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ public boolean isMemberNullable(MemberShape member, CheckMode checkMode) {
}
// fall-through.
case LIST:
// Map values and list members are only null if they have the @sparse trait.
return container.hasTrait(SparseTrait.ID);
// Map values and list members are only null if they have the @sparse trait
// OR if the target is a Document since Document can hold a null value
return container.hasTrait(SparseTrait.ID) || target.isDocumentShape();
default:
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,24 @@ public void nullNonSparseMapValue() {
"a: Non-sparse map shape `ns.foo#Map` cannot contain null values"));
}

@Test
public void nullNonSparseDocumentMapValue() {
// This should not raise any errors since null is a valid Document value
ObjectNode map = ObjectNode.builder()
.withMember("a", Node.nullNode())
.build();
NodeValidationVisitor visitor = NodeValidationVisitor.builder()
.value(map)
.model(MODEL)
.allowOptionalNull(true)
.build();
List<ValidationEvent> events = MODEL
.expectShape(ShapeId.from("ns.foo#DocumentMap"))
.accept(visitor);

assertThat(events, hasSize(0));
}

@Test
public void nullSparseMapValue() {
ObjectNode map = ObjectNode.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@
"smithy.api#sparse": {}
}
},
"ns.foo#DocumentMap": {
"type": "map",
"key": {
"target": "ns.foo#KeyString"
},
"value": {
"target": "smithy.api#Document"
}
},
"ns.foo#Structure": {
"type": "structure",
"members": {
Expand Down