Skip to content

Commit

Permalink
Fix APIGW exports
Browse files Browse the repository at this point in the history
  • Loading branch information
syall committed Apr 24, 2023
1 parent 7399331 commit 6c2cf2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -142,7 +143,7 @@ public Model preprocessModel(Model model, GoSettings settings) {
Model previousModel = handleApiGateWayExportsNullabilityExceptions(
getPreviousModel(service, model), service, nullabilityExceptions, true);
model = handleApiGateWayExportsNullabilityExceptions(
model, service, nullabilityExceptions, false);
model, service, nullabilityExceptions, true);
List<ValidationEvent> awsSdkGoV2ChangedNullabilityEvents = getAwsSdkGoV2ChangedNullabilityEvents(
previousModel,
model);
Expand Down Expand Up @@ -266,6 +267,7 @@ private static Model handleApiGateWayExportsNullabilityExceptions(
// Patch default traits to nullability exceptions
for (ShapeId shapeId : nullabilityExceptions) {
if (relaxed && !model.getShape(shapeId).isPresent()) {
LOGGER.warning("Shape `" + shapeId + "` nullability exception is not present in the model");
continue;
}
Shape shape = model.expectShape(shapeId);
Expand Down Expand Up @@ -317,8 +319,14 @@ private static Model handleApiGateWayExportsNullabilityExceptions(
}

private static void validateNullabilityExceptions(Set<ShapeId> nullabilityExceptions, Model model) {
Map<ShapeId, Shape> nullabilityExceptionMap = nullabilityExceptions.stream()
.collect(Collectors.toMap(s -> s, s -> model.expectShape(s)));
Map<ShapeId, Shape> nullabilityExceptionMap = new HashMap<>();
for (ShapeId shapeId : nullabilityExceptions) {
if (model.getShape(shapeId).isPresent()) {
nullabilityExceptionMap.put(shapeId, model.expectShape(shapeId));
} else {
LOGGER.warning("Shape `" + shapeId + "` nullability exception is not present in the model");
}
}
// Existing “defaulted” root boolean or number shapes MUST be backfilled with a
// default trait.
for (Map.Entry<ShapeId, Shape> entry : nullabilityExceptionMap.entrySet()) {
Expand Down
Expand Up @@ -71,6 +71,7 @@
"com.amazonaws.mediaconvert#__doubleMinNegative60Max6",
"com.amazonaws.mediaconvert#__doubleMinNegative60MaxNegative1",
"com.amazonaws.mediaconvert#__doubleMinNegative6Max3",
"com.amazonaws.mediaconvert#__doubleMinNegative8Max0",
"com.amazonaws.mediaconvert#__integer",
"com.amazonaws.mediaconvert#__integerMin0Max0",
"com.amazonaws.mediaconvert#__integerMin0Max1",
Expand Down

0 comments on commit 6c2cf2a

Please sign in to comment.