diff --git a/config/spotless/formatting.xml b/config/spotless/formatting.xml
index 564744fe8aa..4be3da5e7b4 100644
--- a/config/spotless/formatting.xml
+++ b/config/spotless/formatting.xml
@@ -415,8 +415,8 @@
-
-
+
+
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddApiKeySource.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddApiKeySource.java
index 923568d013b..ee3e7fe33ae 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddApiKeySource.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddApiKeySource.java
@@ -25,17 +25,17 @@ public List getApiTypes() {
@Override
public OpenApi after(Context extends Trait> context, OpenApi openApi) {
return context.getService()
- .getTrait(ApiKeySourceTrait.class)
- .map(trait -> {
- LOGGER.fine(
- () -> String.format(
- "Adding %s trait to %s",
- EXTENSION_NAME,
- context.getService().getId()
- )
- );
- return openApi.toBuilder().putExtension(EXTENSION_NAME, trait.getValue()).build();
- })
- .orElse(openApi);
+ .getTrait(ApiKeySourceTrait.class)
+ .map(trait -> {
+ LOGGER.fine(
+ () -> String.format(
+ "Adding %s trait to %s",
+ EXTENSION_NAME,
+ context.getService().getId()
+ )
+ );
+ return openApi.toBuilder().putExtension(EXTENSION_NAME, trait.getValue()).build();
+ })
+ .orElse(openApi);
}
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddAuthorizers.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddAuthorizers.java
index f8975bd7df7..8a4469963bb 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddAuthorizers.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddAuthorizers.java
@@ -61,14 +61,14 @@ public List getApiTypes() {
@Override
public Map> updateSecurity(
- Context extends Trait> context,
- Shape shape,
- SecuritySchemeConverter extends Trait> converter,
- Map> requirement
+ Context extends Trait> context,
+ Shape shape,
+ SecuritySchemeConverter extends Trait> converter,
+ Map> requirement
) {
// Only modify requirements that exactly match the updated scheme.
if (requirement.size() != 1
- || !requirement.keySet().iterator().next().equals(converter.getOpenApiAuthSchemeName())) {
+ || !requirement.keySet().iterator().next().equals(converter.getOpenApiAuthSchemeName())) {
return requirement;
}
@@ -76,19 +76,19 @@ public Map> updateSecurity(
AuthorizerIndex authorizerIndex = AuthorizerIndex.of(context.getModel());
return authorizerIndex.getAuthorizer(service, shape)
- // Remove the original scheme authentication scheme from the operation if found.
- // Add a new scheme for this operation using the authorizer name.
- .map(authorizer -> MapUtils.of(authorizer, requirement.values().iterator().next()))
- .orElse(requirement);
+ // Remove the original scheme authentication scheme from the operation if found.
+ // Add a new scheme for this operation using the authorizer name.
+ .map(authorizer -> MapUtils.of(authorizer, requirement.values().iterator().next()))
+ .orElse(requirement);
}
@Override
public OperationObject updateOperation(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operation,
- String httpMethodName,
- String path
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operation,
+ String httpMethodName,
+ String path
) {
ServiceShape service = context.getService();
AuthorizerIndex authorizerIndex = AuthorizerIndex.of(context.getModel());
@@ -111,21 +111,21 @@ public OperationObject updateOperation(
}
return operation.toBuilder()
- .addSecurity(MapUtils.of(operationAuth, ListUtils.of()))
- .build();
+ .addSecurity(MapUtils.of(operationAuth, ListUtils.of()))
+ .build();
}
private boolean usesApiGatewayApiKeys(ServiceShape service, String operationAuth) {
// Get the authorizer for this operation if it has no "type" or
// "customAuthType" set, as is required for API Gateway's API keys.
Optional definitionOptional = service.getTrait(AuthorizersTrait.class)
- .flatMap(
- authorizers -> authorizers.getAuthorizer(operationAuth)
- .filter(
- authorizer -> !authorizer.getType().isPresent()
- && !authorizer.getCustomAuthType().isPresent()
- )
- );
+ .flatMap(
+ authorizers -> authorizers.getAuthorizer(operationAuth)
+ .filter(
+ authorizer -> !authorizer.getType().isPresent()
+ && !authorizer.getCustomAuthType().isPresent()
+ )
+ );
if (!definitionOptional.isPresent()) {
return false;
@@ -140,15 +140,15 @@ private boolean usesApiGatewayApiKeys(ServiceShape service, String operationAuth
@Override
public OpenApi after(Context extends Trait> context, OpenApi openapi) {
return context.getService()
- .getTrait(AuthorizersTrait.class)
- .map(authorizers -> addComputedAuthorizers(context, openapi, authorizers))
- .orElse(openapi);
+ .getTrait(AuthorizersTrait.class)
+ .map(authorizers -> addComputedAuthorizers(context, openapi, authorizers))
+ .orElse(openapi);
}
private OpenApi addComputedAuthorizers(
- Context extends Trait> context,
- OpenApi openApi,
- AuthorizersTrait trait
+ Context extends Trait> context,
+ OpenApi openApi,
+ AuthorizersTrait trait
) {
OpenApi.Builder builder = openApi.toBuilder();
ComponentsObject.Builder components = openApi.getComponents().toBuilder();
@@ -172,19 +172,19 @@ private OpenApi addComputedAuthorizers(
}
private boolean isAuthConverterMatched(
- Context extends Trait> context,
- SecuritySchemeConverter extends Trait> converter,
- ShapeId scheme
+ Context extends Trait> context,
+ SecuritySchemeConverter extends Trait> converter,
+ ShapeId scheme
) {
return converter.getAuthSchemeId().equals(scheme)
- && context.getService().hasTrait(converter.getAuthSchemeType());
+ && context.getService().hasTrait(converter.getAuthSchemeType());
}
private SecurityScheme convertAuthScheme(
- Context extends Trait> context,
- SecuritySchemeConverter converter,
- AuthorizerDefinition authorizer,
- String authorizerName
+ Context extends Trait> context,
+ SecuritySchemeConverter converter,
+ AuthorizerDefinition authorizer,
+ String authorizerName
) {
T authTrait = context.getService().expectTrait(converter.getAuthSchemeType());
SecurityScheme createdScheme = converter.createSecurityScheme(context, authTrait);
@@ -203,27 +203,27 @@ private SecurityScheme convertAuthScheme(
}
ObjectNode authorizerNode = Node.objectNodeBuilder()
- .withOptionalMember("type", authorizer.getType().map(Node::from))
- .withOptionalMember("authorizerUri", authorizer.getUri().map(Node::from))
- .withOptionalMember("authorizerCredentials", authorizer.getCredentials().map(Node::from))
- .withOptionalMember(
- "identityValidationExpression",
- authorizer.getIdentityValidationExpression().map(Node::from)
- )
- .withOptionalMember("identitySource", authorizer.getIdentitySource().map(Node::from))
- .withOptionalMember(
- "authorizerResultTtlInSeconds",
- authorizer.getResultTtlInSeconds().map(Node::from)
- )
- .withOptionalMember(
- "authorizerPayloadFormatVersion",
- authorizer.getAuthorizerPayloadFormatVersion().map(Node::from)
- )
- .withOptionalMember(
- "enableSimpleResponses",
- authorizer.getEnableSimpleResponses().map(Node::from)
- )
- .build();
+ .withOptionalMember("type", authorizer.getType().map(Node::from))
+ .withOptionalMember("authorizerUri", authorizer.getUri().map(Node::from))
+ .withOptionalMember("authorizerCredentials", authorizer.getCredentials().map(Node::from))
+ .withOptionalMember(
+ "identityValidationExpression",
+ authorizer.getIdentityValidationExpression().map(Node::from)
+ )
+ .withOptionalMember("identitySource", authorizer.getIdentitySource().map(Node::from))
+ .withOptionalMember(
+ "authorizerResultTtlInSeconds",
+ authorizer.getResultTtlInSeconds().map(Node::from)
+ )
+ .withOptionalMember(
+ "authorizerPayloadFormatVersion",
+ authorizer.getAuthorizerPayloadFormatVersion().map(Node::from)
+ )
+ .withOptionalMember(
+ "enableSimpleResponses",
+ authorizer.getEnableSimpleResponses().map(Node::from)
+ )
+ .build();
if (authorizerNode.size() != 0) {
schemeBuilder.putExtension(EXTENSION_NAME, authorizerNode);
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddBinaryTypes.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddBinaryTypes.java
index f793ba39dc3..7548a357d96 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddBinaryTypes.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddBinaryTypes.java
@@ -48,14 +48,14 @@ public OpenApi after(Context extends Trait> context, OpenApi openApi) {
if (!binaryTypes.isEmpty()) {
LOGGER.fine(() -> "Adding recognized binary types to model: " + binaryTypes);
return openApi.toBuilder()
- .putExtension(
- EXTENSION_NAME,
- Stream.concat(binaryTypes.stream(), Stream.of(DEFAULT_BINARY_TYPE))
- .distinct()
- .map(Node::from)
- .collect(ArrayNode.collect())
- )
- .build();
+ .putExtension(
+ EXTENSION_NAME,
+ Stream.concat(binaryTypes.stream(), Stream.of(DEFAULT_BINARY_TYPE))
+ .distinct()
+ .map(Node::from)
+ .collect(ArrayNode.collect())
+ )
+ .build();
}
return openApi;
@@ -68,26 +68,26 @@ private Stream supportedMediaTypes(Context extends Trait> context) {
// Find the media types defined on all request and response bindings.
return topDownIndex.getContainedOperations(context.getService())
- .stream()
- .flatMap(
- operation -> Stream.concat(
- OptionalUtils.stream(
- binaryMediaType(model, httpBindingIndex.getRequestBindings(operation))
- ),
- OptionalUtils.stream(
- binaryMediaType(model, httpBindingIndex.getResponseBindings(operation))
- )
- )
- );
+ .stream()
+ .flatMap(
+ operation -> Stream.concat(
+ OptionalUtils.stream(
+ binaryMediaType(model, httpBindingIndex.getRequestBindings(operation))
+ ),
+ OptionalUtils.stream(
+ binaryMediaType(model, httpBindingIndex.getResponseBindings(operation))
+ )
+ )
+ );
}
private Optional binaryMediaType(Model model, Map httpBindings) {
return httpBindings.values()
- .stream()
- .filter(binding -> binding.getLocation().equals(HttpBinding.Location.PAYLOAD))
- .map(HttpBinding::getMember)
- .flatMap(member -> OptionalUtils.stream(member.getMemberTrait(model, MediaTypeTrait.class)))
- .map(MediaTypeTrait::getValue)
- .findFirst();
+ .stream()
+ .filter(binding -> binding.getLocation().equals(HttpBinding.Location.PAYLOAD))
+ .map(HttpBinding::getMember)
+ .flatMap(member -> OptionalUtils.stream(member.getMemberTrait(model, MediaTypeTrait.class)))
+ .map(MediaTypeTrait::getValue)
+ .findFirst();
}
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsPreflightIntegration.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsPreflightIntegration.java
index 239a227a62f..deb46a7c596 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsPreflightIntegration.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsPreflightIntegration.java
@@ -72,16 +72,16 @@ public List getApiTypes() {
@Override
public PathItem updatePathItem(Context extends Trait> context, String path, PathItem pathItem) {
return context.getService()
- .getTrait(CorsTrait.class)
- .map(corsTrait -> addPreflightIntegration(context, path, pathItem, corsTrait))
- .orElse(pathItem);
+ .getTrait(CorsTrait.class)
+ .map(corsTrait -> addPreflightIntegration(context, path, pathItem, corsTrait))
+ .orElse(pathItem);
}
private static PathItem addPreflightIntegration(
- Context extends Trait> context,
- String path,
- PathItem pathItem,
- CorsTrait corsTrait
+ Context extends Trait> context,
+ String path,
+ PathItem pathItem,
+ CorsTrait corsTrait
) {
// Filter out any path for which an OPTIONS handler has already been defined
if (pathItem.getOptions().isPresent()) {
@@ -92,15 +92,15 @@ private static PathItem addPreflightIntegration(
LOGGER.fine(() -> "Adding CORS-preflight OPTIONS request and API Gateway integration for " + path);
Map headers = deduceCorsHeaders(context, path, pathItem, corsTrait);
return pathItem.toBuilder()
- .options(createPreflightOperation(context, path, pathItem, headers))
- .build();
+ .options(createPreflightOperation(context, path, pathItem, headers))
+ .build();
}
private static Map deduceCorsHeaders(
- Context context,
- String path,
- PathItem pathItem,
- CorsTrait corsTrait
+ Context context,
+ String path,
+ PathItem pathItem,
+ CorsTrait corsTrait
) {
Map corsHeaders = new HashMap<>();
corsHeaders.put(CorsHeader.MAX_AGE, String.valueOf(corsTrait.getMaxAge()));
@@ -120,8 +120,8 @@ private static Map deduceCorsHeaders(
// Sets additional allowed headers from the API Gateway config.
Set additionalAllowedHeaders = context.getConfig()
- .getExtensions(ApiGatewayConfig.class)
- .getAdditionalAllowedCorsHeadersSet();
+ .getExtensions(ApiGatewayConfig.class)
+ .getAdditionalAllowedCorsHeadersSet();
headerNames.addAll(additionalAllowedHeaders);
headerNames.addAll(findAllHeaders(path, pathItem));
@@ -134,8 +134,8 @@ private static Map deduceCorsHeaders(
Model model = context.getModel();
TopDownIndex topDownIndex = TopDownIndex.of(model);
Map operations = topDownIndex.getContainedOperations(context.getService())
- .stream()
- .collect(Collectors.toMap(o -> o.getId().getName(), o -> o));
+ .stream()
+ .collect(Collectors.toMap(o -> o.getId().getName(), o -> o));
for (OperationObject operationObject : pathItem.getOperations().values()) {
if (operationObject.getOperationId().isPresent()) {
OperationShape operationShape = operations.get(operationObject.getOperationId().get());
@@ -144,12 +144,12 @@ private static Map deduceCorsHeaders(
}
LOGGER.fine(
- () -> String.format(
- "Adding the following %s headers to `%s`: %s",
- CorsHeader.ALLOW_HEADERS,
- path,
- headerNames
- )
+ () -> String.format(
+ "Adding the following %s headers to `%s`: %s",
+ CorsHeader.ALLOW_HEADERS,
+ path,
+ headerNames
+ )
);
corsHeaders.put(CorsHeader.ALLOW_HEADERS, String.join(",", headerNames));
@@ -157,8 +157,8 @@ private static Map deduceCorsHeaders(
}
private static Set getSecuritySchemeRequestHeaders(
- Context extends Trait> context,
- SecuritySchemeConverter converter
+ Context extends Trait> context,
+ SecuritySchemeConverter converter
) {
T t = context.getService().expectTrait(converter.getAuthSchemeType());
return converter.getAuthRequestHeaders(context, t);
@@ -167,19 +167,19 @@ private static Set getSecuritySchemeRequestHeaders(
private static Collection findAllHeaders(String path, PathItem pathItem) {
// Get all "in" = "header" parameters and gather up their "name" properties.
return pathItem.getOperations()
- .values()
- .stream()
- .flatMap(operationObject -> operationObject.getParameters().stream())
- .filter(parameter -> parameter.getIn().filter(in -> in.equals("header")).isPresent())
- .map(
- parameter -> parameter.getName()
- .orElseThrow(
- () -> new OpenApiException(
- "OpenAPI header parameter is missing a name in " + path
- )
- )
- )
- .collect(Collectors.toList());
+ .values()
+ .stream()
+ .flatMap(operationObject -> operationObject.getParameters().stream())
+ .filter(parameter -> parameter.getIn().filter(in -> in.equals("header")).isPresent())
+ .map(
+ parameter -> parameter.getName()
+ .orElseThrow(
+ () -> new OpenApiException(
+ "OpenAPI header parameter is missing a name in " + path
+ )
+ )
+ )
+ .collect(Collectors.toList());
}
private static String getAllowMethods(PathItem item) {
@@ -187,20 +187,20 @@ private static String getAllowMethods(PathItem item) {
}
private static OperationObject createPreflightOperation(
- Context extends Trait> context,
- String path,
- PathItem pathItem,
- Map headers
+ Context extends Trait> context,
+ String path,
+ PathItem pathItem,
+ Map headers
) {
return OperationObject.builder()
- .tags(ListUtils.of("CORS"))
- .security(Collections.emptyList())
- .description("Handles CORS-preflight requests")
- .operationId(createOperationId(path))
- .putResponse("200", createPreflightResponse(headers))
- .parameters(findPathParameters(pathItem))
- .putExtension(INTEGRATION_EXTENSION, createPreflightIntegration(context, headers, pathItem))
- .build();
+ .tags(ListUtils.of("CORS"))
+ .security(Collections.emptyList())
+ .description("Handles CORS-preflight requests")
+ .operationId(createOperationId(path))
+ .putResponse("200", createPreflightResponse(headers))
+ .parameters(findPathParameters(pathItem))
+ .putExtension(INTEGRATION_EXTENSION, createPreflightIntegration(context, headers, pathItem))
+ .build();
}
private static List findPathParameters(PathItem pathItem) {
@@ -221,24 +221,24 @@ private static List findPathParameters(PathItem pathItem) {
private static String createOperationId(String path) {
// Make the operationId all alphanumeric camel case characters.
return CaseUtils.toCamelCase("Cors" + path, true, '{', '}', '/', '?', '&', '=')
- .replaceAll("[^A-Z0-9a-z_]", "_");
+ .replaceAll("[^A-Z0-9a-z_]", "_");
}
private static ResponseObject createPreflightResponse(Map headers) {
// The preflight response just returns all of the computed CORS headers.
ResponseObject.Builder builder = ResponseObject.builder()
- .description("Canned response for CORS-preflight requests");
+ .description("Canned response for CORS-preflight requests");
ParameterObject headerParameter = ParameterObject.builder()
- .schema(Schema.builder().type("string").build())
- .build();
+ .schema(Schema.builder().type("string").build())
+ .build();
headers.forEach((name, value) -> builder.putHeader(name.toString(), Ref.local(headerParameter)));
return builder.build();
}
private static ObjectNode createPreflightIntegration(
- Context extends Trait> context,
- Map headers,
- PathItem pathItem
+ Context extends Trait> context,
+ Map headers,
+ PathItem pathItem
) {
IntegrationResponse.Builder responseBuilder = IntegrationResponse.builder().statusCode("200");
@@ -249,13 +249,13 @@ private static ObjectNode createPreflightIntegration(
boolean isPreflightSynced = Boolean.TRUE.equals(context.getConfig().getSyncCorsPreflightIntegration());
MockIntegrationTrait.Builder integration = MockIntegrationTrait.builder()
- // See https://forums.aws.amazon.com/thread.jspa?threadID=256140
- .contentHandling("CONVERT_TO_TEXT")
- // Passthrough behavior "never" will fail the request with unsupported content type more appropriately.
- // https://docs.aws.amazon.com/apigateway/latest/developerguide/integration-passthrough-behaviors.html
- .passThroughBehavior(isPreflightSynced ? "never" : "when_no_match")
- .putResponse("default", responseBuilder.build())
- .putRequestTemplate(API_GATEWAY_DEFAULT_ACCEPT_VALUE, PREFLIGHT_SUCCESS);
+ // See https://forums.aws.amazon.com/thread.jspa?threadID=256140
+ .contentHandling("CONVERT_TO_TEXT")
+ // Passthrough behavior "never" will fail the request with unsupported content type more appropriately.
+ // https://docs.aws.amazon.com/apigateway/latest/developerguide/integration-passthrough-behaviors.html
+ .passThroughBehavior(isPreflightSynced ? "never" : "when_no_match")
+ .putResponse("default", responseBuilder.build())
+ .putRequestTemplate(API_GATEWAY_DEFAULT_ACCEPT_VALUE, PREFLIGHT_SUCCESS);
if (isPreflightSynced) {
// Adds request template for every unique Content-Type supported by all path operations.
@@ -265,12 +265,12 @@ private static ObjectNode createPreflightIntegration(
// example {"statusCode":200}.
for (OperationObject operation : pathItem.getOperations().values()) {
ObjectNode extensionNode = operation.getExtension(INTEGRATION_EXTENSION)
- .flatMap(Node::asObjectNode)
- .orElse(Node.objectNode());
+ .flatMap(Node::asObjectNode)
+ .orElse(Node.objectNode());
Set mimeTypes = extensionNode.getObjectMember(REQUEST_TEMPLATES_KEY)
- .map(ObjectNode::getStringMap)
- .map(Map::keySet)
- .orElse(SetUtils.of());
+ .map(ObjectNode::getStringMap)
+ .map(Map::keySet)
+ .orElse(SetUtils.of());
mimeTypes.forEach(mimeType -> integration.putRequestTemplate(mimeType, PREFLIGHT_SUCCESS));
}
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsResponseHeaders.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsResponseHeaders.java
index 5848485dbc2..a6de197e3ec 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsResponseHeaders.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsResponseHeaders.java
@@ -40,35 +40,35 @@ public List getApiTypes() {
@Override
public OperationObject postProcessOperation(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operation,
- String method,
- String path
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operation,
+ String method,
+ String path
) {
return context.getService()
- .getTrait(CorsTrait.class)
- .map(trait -> addCorsHeadersToResponses(context, shape, operation, method, trait))
- .orElse(operation);
+ .getTrait(CorsTrait.class)
+ .map(trait -> addCorsHeadersToResponses(context, shape, operation, method, trait))
+ .orElse(operation);
}
private OperationObject addCorsHeadersToResponses(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operationObject,
- String method,
- CorsTrait trait
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operationObject,
+ String method,
+ CorsTrait trait
) {
OperationObject.Builder builder = operationObject.toBuilder();
for (Map.Entry entry : operationObject.getResponses().entrySet()) {
ResponseObject updated = createUpdatedResponseWithCorsHeaders(
- context,
- shape,
- operationObject,
- method,
- trait,
- entry.getValue()
+ context,
+ shape,
+ operationObject,
+ method,
+ trait,
+ entry.getValue()
);
builder.putResponse(entry.getKey(), updated);
}
@@ -77,12 +77,12 @@ private OperationObject addCorsHeadersToResponses(
}
private ResponseObject createUpdatedResponseWithCorsHeaders(
- Context extends Trait> context,
- OperationShape operation,
- OperationObject operationObject,
- String method,
- CorsTrait trait,
- ResponseObject response
+ Context extends Trait> context,
+ OperationShape operation,
+ OperationObject operationObject,
+ String method,
+ CorsTrait trait,
+ ResponseObject response
) {
// Determine which headers have been added to the response.
List headers = new ArrayList<>();
@@ -177,8 +177,8 @@ private ResponseObject createUpdatedResponseWithCorsHeaders(
for (String headerName : headers) {
if (!response.getHeader(headerName).isPresent()) {
ParameterObject headerParam = ParameterObject.builder()
- .schema(headerSchema)
- .build();
+ .schema(headerSchema)
+ .build();
builder.putHeader(headerName, Ref.local(headerParam));
}
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsToGatewayResponses.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsToGatewayResponses.java
index 349461557aa..05aeb6400b3 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsToGatewayResponses.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsToGatewayResponses.java
@@ -42,16 +42,16 @@ final class AddCorsToGatewayResponses implements ApiGatewayMapper {
* TODO: Does this need to be made protocol-specific?
*/
private static final ObjectNode DEFAULT_GATEWAY_RESPONSE = Node.objectNode()
- .withMember(
- "responseTemplates",
- Node.objectNode()
- .withMember("application/json", "{\"message\":$context.error.messageString}")
- );
+ .withMember(
+ "responseTemplates",
+ Node.objectNode()
+ .withMember("application/json", "{\"message\":$context.error.messageString}")
+ );
private static final ObjectNode DEFAULT_GATEWAY_RESPONSES = Node.objectNodeBuilder()
- .withMember("DEFAULT_4XX", DEFAULT_GATEWAY_RESPONSE)
- .withMember("DEFAULT_5XX", DEFAULT_GATEWAY_RESPONSE)
- .build();
+ .withMember("DEFAULT_4XX", DEFAULT_GATEWAY_RESPONSE)
+ .withMember("DEFAULT_5XX", DEFAULT_GATEWAY_RESPONSE)
+ .build();
private static final String GATEWAY_RESPONSES_EXTENSION = "x-amazon-apigateway-gateway-responses";
private static final String HEADER_PREFIX = "gatewayresponse.header.";
@@ -65,21 +65,21 @@ public List getApiTypes() {
@Override
public OpenApi after(Context extends Trait> context, OpenApi openapi) {
return context.getService()
- .getTrait(CorsTrait.class)
- .map(corsTrait -> updateModel(context, openapi, corsTrait))
- .orElse(openapi);
+ .getTrait(CorsTrait.class)
+ .map(corsTrait -> updateModel(context, openapi, corsTrait))
+ .orElse(openapi);
}
private OpenApi updateModel(Context extends Trait> context, OpenApi openapi, CorsTrait corsTrait) {
// Update the existing gateway responses if present, or inject a default one if not.
Node extension = openapi.getExtension(GATEWAY_RESPONSES_EXTENSION)
- .map(node -> node.expectObjectNode(GATEWAY_RESPONSES_EXTENSION + " must be an object"))
- .map(node -> updateGatewayResponses(context, corsTrait, node))
- .orElse(updateGatewayResponses(context, corsTrait));
+ .map(node -> node.expectObjectNode(GATEWAY_RESPONSES_EXTENSION + " must be an object"))
+ .map(node -> updateGatewayResponses(context, corsTrait, node))
+ .orElse(updateGatewayResponses(context, corsTrait));
// Add the gateway responses the `x-amazon-apigateway-gateway-responses` OpenAPI extension.
return openapi.toBuilder()
- .putExtension(GATEWAY_RESPONSES_EXTENSION, extension)
- .build();
+ .putExtension(GATEWAY_RESPONSES_EXTENSION, extension)
+ .build();
}
private Node updateGatewayResponses(Context extends Trait> context, CorsTrait trait) {
@@ -88,9 +88,9 @@ private Node updateGatewayResponses(Context extends Trait> context, CorsTrait
}
private Node updateGatewayResponses(
- Context extends Trait> context,
- CorsTrait trait,
- ObjectNode gatewayResponses
+ Context extends Trait> context,
+ CorsTrait trait,
+ ObjectNode gatewayResponses
) {
Map corsHeaders = new HashMap<>();
corsHeaders.put(CorsHeader.ALLOW_ORIGIN, trait.getOrigin());
@@ -102,22 +102,22 @@ private Node updateGatewayResponses(
}
return gatewayResponses.getMembers()
- .entrySet()
- .stream()
- .collect(ObjectNode.collect(Map.Entry::getKey, entry -> {
- return updateGatewayResponse(context, trait, corsHeaders, entry.getValue().expectObjectNode());
- }));
+ .entrySet()
+ .stream()
+ .collect(ObjectNode.collect(Map.Entry::getKey, entry -> {
+ return updateGatewayResponse(context, trait, corsHeaders, entry.getValue().expectObjectNode());
+ }));
}
private ObjectNode updateGatewayResponse(
- Context extends Trait> context,
- CorsTrait trait,
- Map sharedHeaders,
- ObjectNode gatewayResponse
+ Context extends Trait> context,
+ CorsTrait trait,
+ Map sharedHeaders,
+ ObjectNode gatewayResponse
) {
ObjectNode responseParameters = gatewayResponse
- .getObjectMember(RESPONSE_PARAMETERS_KEY)
- .orElse(Node.objectNode());
+ .getObjectMember(RESPONSE_PARAMETERS_KEY)
+ .orElse(Node.objectNode());
// Track all CORS headers of the gateway response.
Map headers = new TreeMap<>(sharedHeaders);
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsToRestIntegrations.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsToRestIntegrations.java
index f06aeb17985..f34c4b781ee 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsToRestIntegrations.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddCorsToRestIntegrations.java
@@ -47,11 +47,11 @@ public List getApiTypes() {
@Override
public OperationObject updateOperation(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operationObject,
- String httpMethod,
- String path
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operationObject,
+ String httpMethod,
+ String path
) {
CorsTrait cors = context.getService().getTrait(CorsTrait.class).orElse(null);
@@ -60,37 +60,37 @@ public OperationObject updateOperation(
}
return operationObject.getExtension(AddIntegrations.INTEGRATION_EXTENSION_NAME)
- .flatMap(Node::asObjectNode)
- .map(integrationObject -> updateOperation(context, shape, operationObject, cors, integrationObject))
- .orElse(operationObject);
+ .flatMap(Node::asObjectNode)
+ .map(integrationObject -> updateOperation(context, shape, operationObject, cors, integrationObject))
+ .orElse(operationObject);
}
private OperationObject updateOperation(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operationObject,
- CorsTrait cors,
- ObjectNode integrationObject
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operationObject,
+ CorsTrait cors,
+ ObjectNode integrationObject
) {
ObjectNode updated = updateIntegrationWithCors(
- context,
- operationObject,
- shape,
- integrationObject,
- cors
+ context,
+ operationObject,
+ shape,
+ integrationObject,
+ cors
);
return operationObject.toBuilder()
- .putExtension(AddIntegrations.INTEGRATION_EXTENSION_NAME, updated)
- .build();
+ .putExtension(AddIntegrations.INTEGRATION_EXTENSION_NAME, updated)
+ .build();
}
private ObjectNode updateIntegrationWithCors(
- Context extends Trait> context,
- OperationObject operationObject,
- OperationShape shape,
- ObjectNode integrationNode,
- CorsTrait cors
+ Context extends Trait> context,
+ OperationObject operationObject,
+ OperationShape shape,
+ ObjectNode integrationNode,
+ CorsTrait cors
) {
ObjectNode responses = integrationNode.getObjectMember(RESPONSES_KEY).orElse(Node.objectNode());
@@ -106,55 +106,55 @@ private ObjectNode updateIntegrationWithCors(
}
LOGGER.finer(
- () -> String.format(
- "Adding the following CORS headers to the API Gateway integration of %s: %s",
- shape.getId(),
- corsHeaders
- )
+ () -> String.format(
+ "Adding the following CORS headers to the API Gateway integration of %s: %s",
+ shape.getId(),
+ corsHeaders
+ )
);
Set deducedHeaders = CorsHeader.deduceOperationResponseHeaders(context, operationObject, shape, cors);
LOGGER.fine(
- () -> String.format(
- "Detected the following headers for operation %s: %s",
- shape.getId(),
- deducedHeaders
- )
+ () -> String.format(
+ "Detected the following headers for operation %s: %s",
+ shape.getId(),
+ deducedHeaders
+ )
);
// Update each response by adding CORS headers.
responses = responses.getMembers()
- .entrySet()
- .stream()
- .peek(
- entry -> LOGGER.fine(
- () -> String.format(
- "Updating integration response %s for `%s` with CORS",
- entry.getKey(),
- shape.getId()
- )
+ .entrySet()
+ .stream()
+ .peek(
+ entry -> LOGGER.fine(
+ () -> String.format(
+ "Updating integration response %s for `%s` with CORS",
+ entry.getKey(),
+ shape.getId()
+ )
+ )
)
- )
- .map(
- entry -> Pair.of(
- entry.getKey(),
- updateIntegrationResponse(
- shape,
- corsHeaders,
- deducedHeaders,
- entry.getValue().expectObjectNode()
- )
+ .map(
+ entry -> Pair.of(
+ entry.getKey(),
+ updateIntegrationResponse(
+ shape,
+ corsHeaders,
+ deducedHeaders,
+ entry.getValue().expectObjectNode()
+ )
+ )
)
- )
- .collect(ObjectNode.collect(Pair::getLeft, Pair::getRight));
+ .collect(ObjectNode.collect(Pair::getLeft, Pair::getRight));
return integrationNode.withMember(RESPONSES_KEY, responses);
}
private ObjectNode updateIntegrationResponse(
- OperationShape shape,
- Map corsHeaders,
- Set deduced,
- ObjectNode response
+ OperationShape shape,
+ Map corsHeaders,
+ Set deduced,
+ ObjectNode response
) {
Map responseHeaders = new HashMap<>(corsHeaders);
ObjectNode responseParams = response.getObjectMember(RESPONSE_PARAMETERS_KEY).orElseGet(Node::objectNode);
@@ -163,11 +163,11 @@ private ObjectNode updateIntegrationResponse(
Set headersToExpose = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
headersToExpose.addAll(deduced);
responseParams.getStringMap()
- .keySet()
- .stream()
- .filter(parameterName -> parameterName.startsWith(HEADER_PREFIX))
- .map(parameterName -> parameterName.substring(HEADER_PREFIX.length()))
- .forEach(headersToExpose::add);
+ .keySet()
+ .stream()
+ .filter(parameterName -> parameterName.startsWith(HEADER_PREFIX))
+ .map(parameterName -> parameterName.substring(HEADER_PREFIX.length()))
+ .forEach(headersToExpose::add);
String headersToExposeString = String.join(",", headersToExpose);
// If there are exposed headers, then add a new header to the integration
@@ -175,12 +175,12 @@ private ObjectNode updateIntegrationResponse(
if (!headersToExposeString.isEmpty()) {
responseHeaders.put(CorsHeader.EXPOSE_HEADERS, headersToExposeString);
LOGGER.fine(
- () -> String.format(
- "Adding `%s` header to `%s` with value of `%s`",
- CorsHeader.EXPOSE_HEADERS,
- shape.getId(),
- headersToExposeString
- )
+ () -> String.format(
+ "Adding `%s` header to `%s` with value of `%s`",
+ CorsHeader.EXPOSE_HEADERS,
+ shape.getId(),
+ headersToExposeString
+ )
);
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultConfigSettings.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultConfigSettings.java
index ff178551ede..6c2ba5869c5 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultConfigSettings.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultConfigSettings.java
@@ -33,10 +33,10 @@ public void updateDefaultSettings(Model model, OpenApiConfig openApiConfig) {
ApiGatewayConfig config = openApiConfig.getExtensions(ApiGatewayConfig.class);
if (config.getApiGatewayDefaults() == null) {
LOGGER.warning(
- String.format(
- "`apiGatewayDefaults` configuration not set for openapi plugin. Assuming %s.",
- DEFAULT_VERSION
- )
+ String.format(
+ "`apiGatewayDefaults` configuration not set for openapi plugin. Assuming %s.",
+ DEFAULT_VERSION
+ )
);
config.setApiGatewayDefaults(DEFAULT_VERSION);
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddIntegrations.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddIntegrations.java
index ef3bd78b21e..0b0c7fabfe9 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddIntegrations.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddIntegrations.java
@@ -37,23 +37,23 @@ public List getApiTypes() {
@Override
public OperationObject updateOperation(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operation,
- String httpMethod,
- String path
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operation,
+ String httpMethod,
+ String path
) {
IntegrationTraitIndex index = IntegrationTraitIndex.of(context.getModel());
return index.getIntegrationTrait(context.getService(), shape)
- .map(
- trait -> operation.toBuilder()
- .putExtension(INTEGRATION_EXTENSION_NAME, createIntegration(context, shape, trait))
- .build()
- )
- .orElseGet(() -> {
- LOGGER.warning("No API Gateway integration trait found for " + shape.getId());
- return operation;
- });
+ .map(
+ trait -> operation.toBuilder()
+ .putExtension(INTEGRATION_EXTENSION_NAME, createIntegration(context, shape, trait))
+ .build()
+ )
+ .orElseGet(() -> {
+ LOGGER.warning("No API Gateway integration trait found for " + shape.getId());
+ return operation;
+ });
}
static ObjectNode createIntegration(MockIntegrationTrait integration) {
@@ -63,9 +63,9 @@ static ObjectNode createIntegration(MockIntegrationTrait integration) {
}
private static ObjectNode createIntegration(
- Context extends Trait> context,
- OperationShape shape,
- Trait integration
+ Context extends Trait> context,
+ OperationShape shape,
+ Trait integration
) {
ObjectNode integrationNode;
if (integration instanceof MockIntegrationTrait) {
@@ -81,28 +81,28 @@ private static ObjectNode createIntegration(
Optional passthroughBehavior = integrationNode.getMember(INCORRECT_PASSTHROUGH_BEHAVIOR);
if (passthroughBehavior.isPresent()) {
integrationNode = integrationNode
- .withoutMember(INCORRECT_PASSTHROUGH_BEHAVIOR)
- .withMember(PASSTHROUGH_BEHAVIOR, passthroughBehavior.get());
+ .withoutMember(INCORRECT_PASSTHROUGH_BEHAVIOR)
+ .withMember(PASSTHROUGH_BEHAVIOR, passthroughBehavior.get());
}
return integrationNode;
}
private static void validateTraitConfiguration(
- IntegrationTrait trait,
- Context extends Trait> context,
- OperationShape operation
+ IntegrationTrait trait,
+ Context extends Trait> context,
+ OperationShape operation
) {
// For HTTP APIs, API Gateway requires that the payloadFormatVersion is set on integrations.
// https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration.html
// If the payloadFormatVersion has not been set on an integration and the apiGatewayType has been set to "HTTP",
// the conversion fails.
ApiGatewayConfig.ApiType apiType = context.getConfig()
- .getExtensions(ApiGatewayConfig.class)
- .getApiGatewayType();
+ .getExtensions(ApiGatewayConfig.class)
+ .getApiGatewayType();
if (!trait.getPayloadFormatVersion().isPresent() && apiType.equals(ApiGatewayConfig.ApiType.HTTP)) {
throw new OpenApiException(
- "When the 'apiGatewayType' OpenAPI conversion setting is 'HTTP', a "
- + "'payloadFormatVersion' must be set on the aws.apigateway#integration trait."
+ "When the 'apiGatewayType' OpenAPI conversion setting is 'HTTP', a "
+ + "'payloadFormatVersion' must be set on the aws.apigateway#integration trait."
);
}
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidators.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidators.java
index b9083954952..918ad261896 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidators.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidators.java
@@ -37,14 +37,14 @@ final class AddRequestValidators implements ApiGatewayMapper {
private static final String REQUEST_VALIDATOR = "x-amazon-apigateway-request-validator";
private static final String REQUEST_VALIDATORS = "x-amazon-apigateway-request-validators";
private static final Map KNOWN_VALIDATORS = MapUtils.of(
- "params-only",
- Node.objectNode().withMember("validateRequestParameters", Node.from(true)),
- "body-only",
- Node.objectNode().withMember("validateRequestBody", Node.from(true)),
- "full",
- Node.objectNode()
- .withMember("validateRequestParameters", Node.from(true))
- .withMember("validateRequestBody", Node.from(true))
+ "params-only",
+ Node.objectNode().withMember("validateRequestParameters", Node.from(true)),
+ "body-only",
+ Node.objectNode().withMember("validateRequestBody", Node.from(true)),
+ "full",
+ Node.objectNode()
+ .withMember("validateRequestParameters", Node.from(true))
+ .withMember("validateRequestBody", Node.from(true))
);
@Override
@@ -54,27 +54,27 @@ public List getApiTypes() {
@Override
public OperationObject updateOperation(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operation,
- String httpMethod,
- String path
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operation,
+ String httpMethod,
+ String path
) {
return shape.getTrait(RequestValidatorTrait.class)
- .map(RequestValidatorTrait::getValue)
- .map(value -> operation.toBuilder().putExtension(REQUEST_VALIDATOR, value).build())
- .orElse(operation);
+ .map(RequestValidatorTrait::getValue)
+ .map(value -> operation.toBuilder().putExtension(REQUEST_VALIDATOR, value).build())
+ .orElse(operation);
}
@Override
public OpenApi after(Context extends Trait> context, OpenApi openapi) {
// Find each known request validator on operation shapes.
Set validators = context.getModel()
- .shapes(OperationShape.class)
- .flatMap(shape -> OptionalUtils.stream(shape.getTrait(RequestValidatorTrait.class)))
- .map(RequestValidatorTrait::getValue)
- .filter(KNOWN_VALIDATORS::containsKey)
- .collect(Collectors.toSet());
+ .shapes(OperationShape.class)
+ .flatMap(shape -> OptionalUtils.stream(shape.getTrait(RequestValidatorTrait.class)))
+ .map(RequestValidatorTrait::getValue)
+ .filter(KNOWN_VALIDATORS::containsKey)
+ .collect(Collectors.toSet());
// Check if the service has a request validator.
String serviceValidator = null;
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayExtension.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayExtension.java
index f722c09253b..04ba4230471 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayExtension.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayExtension.java
@@ -15,31 +15,31 @@ public final class ApiGatewayExtension implements Smithy2OpenApiExtension {
@Override
public List getOpenApiMappers() {
return ListUtils.of(
- ApiGatewayMapper.wrap(new AddDefaultConfigSettings()),
- ApiGatewayMapper.wrap(new AddDefaultRestConfigSettings()),
- ApiGatewayMapper.wrap(new AddApiKeySource()),
- ApiGatewayMapper.wrap(new AddAuthorizers()),
- ApiGatewayMapper.wrap(new AddBinaryTypes()),
- ApiGatewayMapper.wrap(new AddIntegrations()),
+ ApiGatewayMapper.wrap(new AddDefaultConfigSettings()),
+ ApiGatewayMapper.wrap(new AddDefaultRestConfigSettings()),
+ ApiGatewayMapper.wrap(new AddApiKeySource()),
+ ApiGatewayMapper.wrap(new AddAuthorizers()),
+ ApiGatewayMapper.wrap(new AddBinaryTypes()),
+ ApiGatewayMapper.wrap(new AddIntegrations()),
- // CORS For REST APIs
- ApiGatewayMapper.wrap(new AddCorsToRestIntegrations()),
- ApiGatewayMapper.wrap(new AddCorsResponseHeaders()),
- ApiGatewayMapper.wrap(new AddCorsPreflightIntegration()),
- ApiGatewayMapper.wrap(new AddCorsToGatewayResponses()),
+ // CORS For REST APIs
+ ApiGatewayMapper.wrap(new AddCorsToRestIntegrations()),
+ ApiGatewayMapper.wrap(new AddCorsResponseHeaders()),
+ ApiGatewayMapper.wrap(new AddCorsPreflightIntegration()),
+ ApiGatewayMapper.wrap(new AddCorsToGatewayResponses()),
- ApiGatewayMapper.wrap(new AddRequestValidators()),
- ApiGatewayMapper.wrap(new CloudFormationSubstitution()),
+ ApiGatewayMapper.wrap(new AddRequestValidators()),
+ ApiGatewayMapper.wrap(new CloudFormationSubstitution()),
- // HTTP API mappers.
- ApiGatewayMapper.wrap(new CorsHttpIntegration())
+ // HTTP API mappers.
+ ApiGatewayMapper.wrap(new CorsHttpIntegration())
);
}
@Override
public List> getSecuritySchemeConverters() {
return ListUtils.of(
- new CognitoUserPoolsConverter()
+ new CognitoUserPoolsConverter()
);
}
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayMapper.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayMapper.java
index 72638af9602..d2eea9972ca 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayMapper.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayMapper.java
@@ -91,75 +91,75 @@ public void updateDefaultSettings(Model model, OpenApiConfig config) {
@Override
public OperationObject updateOperation(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operation,
- String httpMethodName,
- String path
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operation,
+ String httpMethodName,
+ String path
) {
return matchesApiType(context)
- ? delegate.updateOperation(context, shape, operation, httpMethodName, path)
- : operation;
+ ? delegate.updateOperation(context, shape, operation, httpMethodName, path)
+ : operation;
}
@Override
public OperationObject postProcessOperation(
- Context extends Trait> context,
- OperationShape shape,
- OperationObject operation,
- String httpMethodName,
- String path
+ Context extends Trait> context,
+ OperationShape shape,
+ OperationObject operation,
+ String httpMethodName,
+ String path
) {
return matchesApiType(context)
- ? delegate.postProcessOperation(context, shape, operation, httpMethodName, path)
- : operation;
+ ? delegate.postProcessOperation(context, shape, operation, httpMethodName, path)
+ : operation;
}
@Override
public PathItem updatePathItem(Context extends Trait> context, String path, PathItem pathItem) {
return matchesApiType(context)
- ? delegate.updatePathItem(context, path, pathItem)
- : pathItem;
+ ? delegate.updatePathItem(context, path, pathItem)
+ : pathItem;
}
@Override
public ParameterObject updateParameter(
- Context extends Trait> context,
- OperationShape operation,
- String httpMethodName,
- String path,
- ParameterObject parameterObject
+ Context extends Trait> context,
+ OperationShape operation,
+ String httpMethodName,
+ String path,
+ ParameterObject parameterObject
) {
return matchesApiType(context)
- ? delegate.updateParameter(context, operation, httpMethodName, path, parameterObject)
- : parameterObject;
+ ? delegate.updateParameter(context, operation, httpMethodName, path, parameterObject)
+ : parameterObject;
}
@Override
public RequestBodyObject updateRequestBody(
- Context extends Trait> context,
- OperationShape operation,
- String httpMethodName,
- String path,
- RequestBodyObject requestBody
+ Context extends Trait> context,
+ OperationShape operation,
+ String httpMethodName,
+ String path,
+ RequestBodyObject requestBody
) {
return matchesApiType(context)
- ? delegate.updateRequestBody(context, operation, httpMethodName, path, requestBody)
- : requestBody;
+ ? delegate.updateRequestBody(context, operation, httpMethodName, path, requestBody)
+ : requestBody;
}
@Override
public ResponseObject updateResponse(
- Context extends Trait> context,
- OperationShape operation,
- String status,
- String httpMethodName,
- String path,
- ResponseObject response
+ Context extends Trait> context,
+ OperationShape operation,
+ String status,
+ String httpMethodName,
+ String path,
+ ResponseObject response
) {
return matchesApiType(context)
- ? delegate.updateResponse(context, operation, status, httpMethodName, path, response)
- : response;
+ ? delegate.updateResponse(context, operation, status, httpMethodName, path, response)
+ : response;
}
@Override
@@ -171,39 +171,39 @@ public void before(Context extends Trait> context, OpenApi.Builder builder) {
@Override
public SecurityScheme updateSecurityScheme(
- Context extends Trait> context,
- Trait authTrait,
- SecurityScheme securityScheme
+ Context extends Trait> context,
+ Trait authTrait,
+ SecurityScheme securityScheme
) {
return matchesApiType(context)
- ? delegate.updateSecurityScheme(context, authTrait, securityScheme)
- : securityScheme;
+ ? delegate.updateSecurityScheme(context, authTrait, securityScheme)
+ : securityScheme;
}
@Override
public Map> updateSecurity(
- Context extends Trait> context,
- Shape shape,
- SecuritySchemeConverter extends Trait> converter,
- Map> requirement
+ Context extends Trait> context,
+ Shape shape,
+ SecuritySchemeConverter extends Trait> converter,
+ Map> requirement
) {
return matchesApiType(context)
- ? delegate.updateSecurity(context, shape, converter, requirement)
- : requirement;
+ ? delegate.updateSecurity(context, shape, converter, requirement)
+ : requirement;
}
@Override
public OpenApi after(Context extends Trait> context, OpenApi openapi) {
return matchesApiType(context)
- ? delegate.after(context, openapi)
- : openapi;
+ ? delegate.after(context, openapi)
+ : openapi;
}
@Override
public ObjectNode updateNode(Context extends Trait> context, OpenApi openapi, ObjectNode node) {
return matchesApiType(context)
- ? delegate.updateNode(context, openapi, node)
- : node;
+ ? delegate.updateNode(context, openapi, node)
+ : node;
}
};
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CloudFormationSubstitution.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CloudFormationSubstitution.java
index c3c54c25491..ed887db9d60 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CloudFormationSubstitution.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CloudFormationSubstitution.java
@@ -45,12 +45,12 @@ final class CloudFormationSubstitution implements ApiGatewayMapper {
* in this list.
*/
private static final List PATHS = Arrays.asList(
- "components/securitySchemes/*/x-amazon-apigateway-authorizer/providerARNs/*",
- "components/securitySchemes/*/x-amazon-apigateway-authorizer/authorizerCredentials",
- "components/securitySchemes/*/x-amazon-apigateway-authorizer/authorizerUri",
- "paths/*/*/x-amazon-apigateway-integration/connectionId",
- "paths/*/*/x-amazon-apigateway-integration/credentials",
- "paths/*/*/x-amazon-apigateway-integration/uri"
+ "components/securitySchemes/*/x-amazon-apigateway-authorizer/providerARNs/*",
+ "components/securitySchemes/*/x-amazon-apigateway-authorizer/authorizerCredentials",
+ "components/securitySchemes/*/x-amazon-apigateway-authorizer/authorizerUri",
+ "paths/*/*/x-amazon-apigateway-integration/connectionId",
+ "paths/*/*/x-amazon-apigateway-integration/credentials",
+ "paths/*/*/x-amazon-apigateway-integration/uri"
);
@Override
@@ -114,11 +114,11 @@ public Node objectNode(ObjectNode node) {
public Node stringNode(StringNode node) {
if (SUBSTITUTION_PATTERN.matcher(node.getValue()).find() && isInPath()) {
LOGGER.fine(
- () -> String.format(
- "Detected CloudFormation variable syntax in %s; replacing with a `Fn::Sub` "
- + "CloudFormation intrinsic function block",
- node.getValue()
- )
+ () -> String.format(
+ "Detected CloudFormation variable syntax in %s; replacing with a `Fn::Sub` "
+ + "CloudFormation intrinsic function block",
+ node.getValue()
+ )
);
return Node.objectNode().withMember(SUBSTITUTION_KEY, node);
}
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CognitoUserPoolsConverter.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CognitoUserPoolsConverter.java
index 07b400dcb6f..4066b05db66 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CognitoUserPoolsConverter.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CognitoUserPoolsConverter.java
@@ -37,21 +37,21 @@ public Class getAuthSchemeType() {
@Override
public SecurityScheme createSecurityScheme(Context extends Trait> context, CognitoUserPoolsTrait trait) {
return SecurityScheme.builder()
- .type("apiKey")
- .description("Amazon Cognito User Pools authentication")
- .name(AUTH_HEADER)
- .in("header")
- .putExtension("x-amazon-apigateway-authtype", Node.from(AUTH_TYPE))
- .putExtension(
- "x-amazon-apigateway-authorizer",
- Node.objectNode()
- .withMember("type", Node.from(AUTH_TYPE))
- .withMember(
- PROVIDER_ARNS_PROPERTY,
- trait.getProviderArns().stream().map(Node::from).collect(ArrayNode.collect())
- )
- )
- .build();
+ .type("apiKey")
+ .description("Amazon Cognito User Pools authentication")
+ .name(AUTH_HEADER)
+ .in("header")
+ .putExtension("x-amazon-apigateway-authtype", Node.from(AUTH_TYPE))
+ .putExtension(
+ "x-amazon-apigateway-authorizer",
+ Node.objectNode()
+ .withMember("type", Node.from(AUTH_TYPE))
+ .withMember(
+ PROVIDER_ARNS_PROPERTY,
+ trait.getProviderArns().stream().map(Node::from).collect(ArrayNode.collect())
+ )
+ )
+ .build();
}
@Override
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CorsHeader.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CorsHeader.java
index 0ef561af7e7..5afcc6d1404 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CorsHeader.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CorsHeader.java
@@ -34,10 +34,10 @@ public String toString() {
}
static Set deduceOperationResponseHeaders(
- Context context,
- OperationObject operationObject,
- OperationShape shape,
- CorsTrait cors
+ Context context,
+ OperationObject operationObject,
+ OperationShape shape,
+ CorsTrait cors
) {
// The deduced response headers of an operation consist of any headers
// returned by security schemes, any headers returned by the protocol,
diff --git a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CorsHttpIntegration.java b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CorsHttpIntegration.java
index b76624280e3..46ff76d5df7 100644
--- a/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CorsHttpIntegration.java
+++ b/smithy-aws-apigateway-openapi/src/main/java/software/amazon/smithy/aws/apigateway/openapi/CorsHttpIntegration.java
@@ -73,16 +73,16 @@ public List getApiTypes() {
@Override
public OpenApi after(Context extends Trait> context, OpenApi openapi) {
return context.getService()
- .getTrait(CorsTrait.class)
- .map(corsTrait -> addCors(context, openapi, corsTrait))
- .orElse(openapi);
+ .getTrait(CorsTrait.class)
+ .map(corsTrait -> addCors(context, openapi, corsTrait))
+ .orElse(openapi);
}
private OpenApi addCors(Context extends Trait> context, OpenApi openapi, CorsTrait trait) {
// Use any existing x-amazon-apigateway-cors value, if present.
Node alreadySetCorsValue = openapi.getExtension(CORS_HTTP_EXTENSION)
- .flatMap(Node::asObjectNode)
- .orElse(null);
+ .flatMap(Node::asObjectNode)
+ .orElse(null);
if (alreadySetCorsValue != null) {
return openapi;
@@ -93,19 +93,19 @@ private OpenApi addCors(Context extends Trait> context, OpenApi openapi, CorsT
Set exposedHeaders = getExposedHeaders(context, trait, openapi);
ObjectNode.Builder corsObjectBuilder = Node.objectNodeBuilder()
- .withMember("allowOrigins", Node.fromStrings(trait.getOrigin()))
- .withMember("maxAge", trait.getMaxAge())
- .withMember("allowMethods", Node.fromStrings(allowedMethodsInService))
- .withMember("exposeHeaders", Node.fromStrings(exposedHeaders))
- .withMember("allowHeaders", Node.fromStrings(allowedRequestHeaders));
+ .withMember("allowOrigins", Node.fromStrings(trait.getOrigin()))
+ .withMember("maxAge", trait.getMaxAge())
+ .withMember("allowMethods", Node.fromStrings(allowedMethodsInService))
+ .withMember("exposeHeaders", Node.fromStrings(exposedHeaders))
+ .withMember("allowHeaders", Node.fromStrings(allowedRequestHeaders));
if (context.usesHttpCredentials()) {
corsObjectBuilder.withMember("allowCredentials", true);
}
return openapi.toBuilder()
- .putExtension(CORS_HTTP_EXTENSION, corsObjectBuilder.build())
- .build();
+ .putExtension(CORS_HTTP_EXTENSION, corsObjectBuilder.build())
+ .build();
}
private Set getMethodsUsedInApi(Context context, OpenApi openApi) {
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddApiKeySourceTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddApiKeySourceTest.java
index b17715fb403..2fd2c690660 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddApiKeySourceTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddApiKeySourceTest.java
@@ -18,20 +18,20 @@ public class AddApiKeySourceTest {
@Test
public void addsApiKeySource() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("api-key-source.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("api-key-source.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
String source = result.getExtension("x-amazon-apigateway-api-key-source")
- .get()
- .expectStringNode()
- .getValue();
+ .get()
+ .expectStringNode()
+ .getValue();
assertThat(source, equalTo("HEADER"));
}
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddAuthorizersTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddAuthorizersTest.java
index 34b471d29f4..c08e637e6b9 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddAuthorizersTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddAuthorizersTest.java
@@ -30,16 +30,16 @@ public class AddAuthorizersTest {
@Test
public void addsAuthorizers() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("authorizers.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("authorizers.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("ns.foo#SomeService"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
SecurityScheme sigV4 = result.getComponents().getSecuritySchemes().get("sigv4");
assertThat(result.getComponents().getSecuritySchemes().get("aws.v4"), nullValue());
@@ -61,16 +61,16 @@ public void addsAuthorizers() {
@Test
public void addsOnlyAuthType() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("basic-authorizers.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("basic-authorizers.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("ns.foo#SomeService"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
SecurityScheme sigV4 = result.getComponents().getSecuritySchemes().get("sigv4");
assertThat(result.getComponents().getSecuritySchemes().get("aws.v4"), nullValue());
@@ -84,16 +84,16 @@ public void addsOnlyAuthType() {
@Test
public void addsCustomAuthType() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("custom-auth-type-authorizer.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("custom-auth-type-authorizer.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("ns.foo#SomeService"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
SecurityScheme sigV4 = result.getComponents().getSecuritySchemes().get("sigv4");
assertThat(result.getComponents().getSecuritySchemes().get("aws.v4"), nullValue());
@@ -107,16 +107,16 @@ public void addsCustomAuthType() {
@Test
public void emptyCustomAuthTypeNotSet() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("empty-custom-auth-type-authorizer.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("empty-custom-auth-type-authorizer.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("ns.foo#SomeService"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
SecurityScheme apiKey = result.getComponents().getSecuritySchemes().get("api_key");
assertThat(apiKey.getType(), equalTo("apiKey"));
@@ -129,20 +129,20 @@ public void emptyCustomAuthTypeNotSet() {
@Test
public void addsOperationLevelApiKeyScheme() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("operation-http-api-key-security.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("operation-http-api-key-security.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#Service"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("operation-http-api-key-security.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("operation-http-api-key-security.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -151,16 +151,16 @@ public void addsOperationLevelApiKeyScheme() {
@Test
public void resolvesEffectiveAuthorizersForEachOperation() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("effective-authorizers.smithy"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("effective-authorizers.smithy"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#ServiceA"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
// The security of the service is just "foo".
assertThat(result.getSecurity(), contains(MapUtils.of("foo", ListUtils.of())));
@@ -170,8 +170,8 @@ public void resolvesEffectiveAuthorizersForEachOperation() {
assertThat(result.getPaths().get("/operationA").getGet().get().getSecurity(), is(Optional.empty()));
// The security schemes of operationB must be "baz".
assertThat(
- result.getPaths().get("/operationB").getGet().get().getSecurity(),
- is(Optional.of(ListUtils.of(MapUtils.of("baz", ListUtils.of()))))
+ result.getPaths().get("/operationB").getGet().get().getSecurity(),
+ is(Optional.of(ListUtils.of(MapUtils.of("baz", ListUtils.of()))))
);
}
}
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddBinaryTypesTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddBinaryTypesTest.java
index 0b8117abeca..c8a7dc55317 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddBinaryTypesTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddBinaryTypesTest.java
@@ -20,22 +20,22 @@ public class AddBinaryTypesTest {
@Test
public void addsBinaryTypes() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("binary-types.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("binary-types.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
List types = result.getExtension("x-amazon-apigateway-binary-media-types")
- .get()
- .expectArrayNode()
- .getElementsAs(StringNode::getValue);
+ .get()
+ .expectArrayNode()
+ .getElementsAs(StringNode::getValue);
assertThat(types, containsInAnyOrder("application/zip", "image/*", "application/octet-stream"));
}
}
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultConfigSettingsTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultConfigSettingsTest.java
index 70e60d8d3a1..f4b230be536 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultConfigSettingsTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultConfigSettingsTest.java
@@ -18,17 +18,17 @@ public class AddDefaultConfigSettingsTest {
@Test
public void defaultsTo2023_08_11() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("default-config-settings.smithy"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("default-config-settings.smithy"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
config.setUseIntegerType(true);
ObjectNode result = OpenApiConverter.create()
- .config(config)
- .convertToNode(model);
+ .config(config)
+ .convertToNode(model);
Node.assertEquals(result, Node.parse(IoUtils.readUtf8Resource(getClass(), "2023-08-11.openapi.json")));
}
@@ -36,10 +36,10 @@ public void defaultsTo2023_08_11() {
@Test
public void usesVersion2023_08_11() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("default-config-settings.smithy"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("default-config-settings.smithy"))
+ .assemble()
+ .unwrap();
OpenApiConfig openApiConfig = new OpenApiConfig();
openApiConfig.setService(ShapeId.from("example.smithy#MyService"));
@@ -50,8 +50,8 @@ public void usesVersion2023_08_11() {
config.setApiGatewayDefaults(ApiGatewayDefaults.VERSION_2023_08_11);
openApiConfig.setExtensions(mapper.serialize(config).expectObjectNode());
ObjectNode result = OpenApiConverter.create()
- .config(openApiConfig)
- .convertToNode(model);
+ .config(openApiConfig)
+ .convertToNode(model);
Node.assertEquals(result, Node.parse(IoUtils.readUtf8Resource(getClass(), "2023-08-11.openapi.json")));
}
@@ -59,10 +59,10 @@ public void usesVersion2023_08_11() {
@Test
public void canDisableDefaults() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("default-config-settings.smithy"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("default-config-settings.smithy"))
+ .assemble()
+ .unwrap();
OpenApiConfig openApiConfig = new OpenApiConfig();
openApiConfig.setService(ShapeId.from("example.smithy#MyService"));
@@ -73,8 +73,8 @@ public void canDisableDefaults() {
config.setApiGatewayDefaults(ApiGatewayDefaults.DISABLED);
openApiConfig.setExtensions(mapper.serialize(config).expectObjectNode());
ObjectNode result = OpenApiConverter.create()
- .config(openApiConfig)
- .convertToNode(model);
+ .config(openApiConfig)
+ .convertToNode(model);
Node.assertEquals(result, Node.parse(IoUtils.readUtf8Resource(getClass(), "disabled-defaults.openapi.json")));
}
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultRestConfigSettingsTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultRestConfigSettingsTest.java
index 6e9c6191ba2..f1680629196 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultRestConfigSettingsTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddDefaultRestConfigSettingsTest.java
@@ -17,10 +17,10 @@ public class AddDefaultRestConfigSettingsTest {
@Test
public void addsDefaultConfigSettings() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("greedy-labels-for-rest.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("greedy-labels-for-rest.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#Service"));
@@ -30,9 +30,9 @@ public void addsDefaultConfigSettings() {
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("greedy-labels-for-rest.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("greedy-labels-for-rest.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddIntegrationsTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddIntegrationsTest.java
index e3846fccbb3..1b6d2386b05 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddIntegrationsTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddIntegrationsTest.java
@@ -22,17 +22,17 @@ public class AddIntegrationsTest {
@Test
public void addsIntegrations() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("integrations.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("integrations.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#Service"));
OpenApi result = OpenApiConverter.create().config(config).convert(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("integrations.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("integrations.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -41,17 +41,17 @@ public void addsIntegrations() {
@Test
public void addsIntegrationsWithoutCredentials() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("integrations-without-credentials.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("integrations-without-credentials.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#Service"));
OpenApi result = OpenApiConverter.create().config(config).convert(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("integrations-without-credentials.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("integrations-without-credentials.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -61,10 +61,10 @@ public void addsIntegrationsWithoutCredentials() {
public void throwsOnInvalidIntegrationTraitForHttpApi() {
OpenApiException thrown = assertThrows(OpenApiException.class, () -> {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("invalid-integration-for-http-api.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("invalid-integration-for-http-api.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#Service"));
ApiGatewayConfig apiGatewayConfig = new ApiGatewayConfig();
@@ -74,11 +74,11 @@ public void throwsOnInvalidIntegrationTraitForHttpApi() {
});
assertThat(
- thrown.getMessage(),
- containsString(
- "When the 'apiGatewayType' OpenAPI conversion setting is"
- + " 'HTTP', a 'payloadFormatVersion' must be set on the aws.apigateway#integration trait."
- )
+ thrown.getMessage(),
+ containsString(
+ "When the 'apiGatewayType' OpenAPI conversion setting is"
+ + " 'HTTP', a 'payloadFormatVersion' must be set on the aws.apigateway#integration trait."
+ )
);
}
}
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidatorsTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidatorsTest.java
index 12efe0f5420..318ae975637 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidatorsTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/AddRequestValidatorsTest.java
@@ -23,17 +23,17 @@ public class AddRequestValidatorsTest {
@Test
public void addsRequestValidators() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("request-validators.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("request-validators.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#Service"));
OpenApi result = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convert(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convert(model);
assertThat(result.getExtension("x-amazon-apigateway-request-validator").get(), equalTo(Node.from("full")));
ObjectNode validators = result.getExtension("x-amazon-apigateway-request-validators").get().expectObjectNode();
@@ -42,17 +42,17 @@ public void addsRequestValidators() {
assertFalse(validators.containsMember("params-only"));
Optional operation1Val = result.getPaths()
- .get("/1")
- .getPut()
- .get()
- .getExtension("x-amazon-apigateway-request-validator");
+ .get("/1")
+ .getPut()
+ .get()
+ .getExtension("x-amazon-apigateway-request-validator");
assertFalse(operation1Val.isPresent());
Optional operation2Val = result.getPaths()
- .get("/2")
- .getPut()
- .get()
- .getExtension("x-amazon-apigateway-request-validator");
+ .get("/2")
+ .getPut()
+ .get()
+ .getExtension("x-amazon-apigateway-request-validator");
assertThat(operation2Val.get(), equalTo(Node.from("body-only")));
}
}
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayMapperTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayMapperTest.java
index 4480126abcf..1a9c21864b9 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayMapperTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/ApiGatewayMapperTest.java
@@ -21,10 +21,10 @@ public class ApiGatewayMapperTest {
@Test
public void onlyCallsMappersWhenApiTypeMatches() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-model.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-model.json"))
+ .assemble()
+ .unwrap();
runTest(model, ApiGatewayConfig.ApiType.REST, true);
runTest(model, ApiGatewayConfig.ApiType.DISABLED, false);
@@ -39,8 +39,8 @@ private void runTest(Model model, ApiGatewayConfig.ApiType type, boolean present
config.putExtensions(apiGatewayConfig);
ObjectNode result = OpenApiConverter.create()
- .config(config)
- .convertToNode(model);
+ .config(config)
+ .convertToNode(model);
if (present) {
assertThat(result.getMember("x-amazon-apigateway-gateway-responses"), not(Optional.empty()));
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CloudFormationSubstitutionTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CloudFormationSubstitutionTest.java
index 06004314d58..7dd0fd408c1 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CloudFormationSubstitutionTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CloudFormationSubstitutionTest.java
@@ -17,21 +17,21 @@ public class CloudFormationSubstitutionTest {
@Test
public void performsSubstitutionsByDefault() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cloudformation-substitutions.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cloudformation-substitutions.json"))
+ .assemble()
+ .unwrap();
ObjectNode expected = Node.parse(
- IoUtils.readUtf8Resource(getClass(), "substitution-performed.json")
+ IoUtils.readUtf8Resource(getClass(), "substitution-performed.json")
)
- .expectObjectNode();
+ .expectObjectNode();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
ObjectNode actual = OpenApiConverter.create()
- .config(config)
- .classLoader(getClass().getClassLoader())
- .convertToNode(model);
+ .config(config)
+ .classLoader(getClass().getClassLoader())
+ .convertToNode(model);
Node.assertEquals(actual, expected);
}
@@ -39,15 +39,15 @@ public void performsSubstitutionsByDefault() {
@Test
public void pluginCanBeDisabled() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cloudformation-substitutions.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cloudformation-substitutions.json"))
+ .assemble()
+ .unwrap();
ObjectNode expected = Node.parse(
- IoUtils.readUtf8Resource(getClass(), "substitution-not-performed.json")
+ IoUtils.readUtf8Resource(getClass(), "substitution-not-performed.json")
)
- .expectObjectNode();
+ .expectObjectNode();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
@@ -56,9 +56,9 @@ public void pluginCanBeDisabled() {
config.putExtensions(apiGatewayConfig);
ObjectNode actual = OpenApiConverter.create()
- .classLoader(getClass().getClassLoader())
- .config(config)
- .convertToNode(model);
+ .classLoader(getClass().getClassLoader())
+ .config(config)
+ .convertToNode(model);
Node.assertEquals(expected, actual);
}
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CognitoUserPoolsConverterTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CognitoUserPoolsConverterTest.java
index a3c6e9edf24..3da97d561c3 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CognitoUserPoolsConverterTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CognitoUserPoolsConverterTest.java
@@ -19,17 +19,17 @@ public class CognitoUserPoolsConverterTest {
@Test
public void addsAwsV4() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cognito-user-pools-security.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cognito-user-pools-security.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#Service"));
OpenApi result = OpenApiConverter.create().config(config).convert(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("cognito-user-pools-security.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("cognito-user-pools-security.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -39,10 +39,10 @@ public void addsAwsV4() {
public void requiresProviderArns() {
Assertions.assertThrows(ValidatedResultException.class, () -> {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("invalid-cognito-user-pools-security.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("invalid-cognito-user-pools-security.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("smithy.example#Service"));
OpenApiConverter.create().config(config).convert(model);
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CorsHttpIntegrationTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CorsHttpIntegrationTest.java
index 225bc81fb91..8e3a24378e3 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CorsHttpIntegrationTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CorsHttpIntegrationTest.java
@@ -21,10 +21,10 @@ public class CorsHttpIntegrationTest {
@Test
public void generatesCorsForHttpApis() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-model.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-model.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
ApiGatewayConfig apiGatewayConfig = new ApiGatewayConfig();
@@ -34,9 +34,9 @@ public void generatesCorsForHttpApis() {
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("http-api-cors.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("http-api-cors.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -49,22 +49,22 @@ public void generatesCorsForHttpApisWithNoExplicitValues() {
// the conversion to "*" for the corresponding CORS headers rather
// than needing to enumerate them all.
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-model.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-model.json"))
+ .assemble()
+ .unwrap();
ModelTransformer transformer = ModelTransformer.create();
model = transformer.mapShapes(model, shape -> {
return shape.getTrait(CorsTrait.class)
- .map(cors -> {
- cors = cors.toBuilder()
- .additionalAllowedHeaders(Collections.emptySet())
- .additionalExposedHeaders(Collections.emptySet())
- .build();
- return Shape.shapeToBuilder(shape).addTrait(cors).build();
- })
- .orElse(shape);
+ .map(cors -> {
+ cors = cors.toBuilder()
+ .additionalAllowedHeaders(Collections.emptySet())
+ .additionalExposedHeaders(Collections.emptySet())
+ .build();
+ return Shape.shapeToBuilder(shape).addTrait(cors).build();
+ })
+ .orElse(shape);
});
OpenApiConfig config = new OpenApiConfig();
@@ -75,9 +75,9 @@ public void generatesCorsForHttpApisWithNoExplicitValues() {
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("http-api-cors-wildcards.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("http-api-cors-wildcards.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CorsTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CorsTest.java
index 78d744c1b11..dc8ae91cec5 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CorsTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/CorsTest.java
@@ -21,17 +21,17 @@ public class CorsTest {
@Test
public void corsIntegrationTest() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-model.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-model.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("cors-model.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("cors-model.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -40,17 +40,17 @@ public void corsIntegrationTest() {
@Test
public void skipsExplicitlyDefinedOptionsOperations() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-explicit-options.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-explicit-options.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("cors-explicit-options.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("cors-explicit-options.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -59,10 +59,10 @@ public void skipsExplicitlyDefinedOptionsOperations() {
@Test
public void setsConfiguredAdditionalAllowedHeaders() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-model.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-model.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
ApiGatewayConfig apiGatewayConfig = new ApiGatewayConfig();
@@ -70,9 +70,9 @@ public void setsConfiguredAdditionalAllowedHeaders() {
config.putExtensions(apiGatewayConfig);
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("cors-with-additional-headers.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("cors-with-additional-headers.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -88,14 +88,14 @@ public void setsConfiguredAdditionalAllowedHeaders() {
@Test
public void findsExistingGatewayHeaders() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-explicit-options.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-explicit-options.json"))
+ .assemble()
+ .unwrap();
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("cors-with-custom-gateway-response-headers.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("cors-with-custom-gateway-response-headers.openapi.json")
+ )
);
OpenApiConfig config = new OpenApiConfig();
@@ -103,40 +103,43 @@ public void findsExistingGatewayHeaders() {
// Create an OpenAPI model.
ObjectNode result = OpenApiConverter.create()
- .config(config)
- .addOpenApiMapper(new OpenApiMapper() {
- @Override
- public byte getOrder() {
- return -127;
- }
-
- @Override
- public OpenApi after(Context context, OpenApi openapi) {
- // Inject a gateway response into the model.
- return openapi.toBuilder()
- .putExtension(
- "x-amazon-apigateway-gateway-responses",
- Node.objectNodeBuilder()
- .withMember(
- "ACCESS_DENIED",
- Node.objectNode()
- .withMember("statusCode", 403)
- .withMember(
- "responseParameters",
- Node.objectNode()
+ .config(config)
+ .addOpenApiMapper(new OpenApiMapper() {
+ @Override
+ public byte getOrder() {
+ return -127;
+ }
+
+ @Override
+ public OpenApi after(Context context, OpenApi openapi) {
+ // Inject a gateway response into the model.
+ return openapi.toBuilder()
+ .putExtension(
+ "x-amazon-apigateway-gateway-responses",
+ Node.objectNodeBuilder()
.withMember(
- "gatewayresponse.header.Access-Control-Allow-Origin",
- "'domain.com'"
+ "ACCESS_DENIED",
+ Node.objectNode()
+ .withMember("statusCode", 403)
+ .withMember(
+ "responseParameters",
+ Node.objectNode()
+ .withMember(
+ "gatewayresponse.header.Access-Control-Allow-Origin",
+ "'domain.com'"
+ )
+ .withMember(
+ "gatewayresponse.header.Foo",
+ "'baz'"
+ )
+ )
)
- .withMember("gatewayresponse.header.Foo", "'baz'")
- )
+ .build()
)
- .build()
- )
- .build();
- }
- })
- .convertToNode(model);
+ .build();
+ }
+ })
+ .convertToNode(model);
Node.assertEquals(result, expectedNode);
}
@@ -144,18 +147,18 @@ public OpenApi after(Context context, OpenApi openapi) {
@Test
public void withPreflightIntegrationSync() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-with-multi-request-templates.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-with-multi-request-templates.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
config.setSyncCorsPreflightIntegration(true);
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("cors-with-preflight-sync.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("cors-with-preflight-sync.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
@@ -164,17 +167,17 @@ public void withPreflightIntegrationSync() {
@Test
public void withoutPreflightIntegrationSync() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("cors-with-multi-request-templates.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("cors-with-multi-request-templates.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("cors-without-preflight-sync.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("cors-without-preflight-sync.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/NonNumericFloatsTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/NonNumericFloatsTest.java
index ecc13a48534..6d54a0f6654 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/NonNumericFloatsTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/NonNumericFloatsTest.java
@@ -17,18 +17,18 @@ public class NonNumericFloatsTest {
@Test
public void handlesNonNumericFloats() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("non-numeric-floats.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("non-numeric-floats.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
config.setSupportNonNumericFloats(true);
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("non-numeric-floats.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("non-numeric-floats.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/PayloadsTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/PayloadsTest.java
index ec0f5d166f2..98461906bfb 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/PayloadsTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/PayloadsTest.java
@@ -17,17 +17,17 @@ public class PayloadsTest {
@Test
public void payloadsStructureTargetTest() {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("payloads.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("payloads.json"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
ObjectNode result = OpenApiConverter.create().config(config).convertToNode(model);
Node expectedNode = Node.parse(
- IoUtils.toUtf8String(
- getClass().getResourceAsStream("payloads.openapi.json")
- )
+ IoUtils.toUtf8String(
+ getClass().getResourceAsStream("payloads.openapi.json")
+ )
);
Node.assertEquals(result, expectedNode);
diff --git a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/UnsupportedTraitsTest.java b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/UnsupportedTraitsTest.java
index 335c64731a9..b4602c76414 100644
--- a/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/UnsupportedTraitsTest.java
+++ b/smithy-aws-apigateway-openapi/src/test/java/software/amazon/smithy/aws/apigateway/openapi/UnsupportedTraitsTest.java
@@ -17,10 +17,10 @@ public class UnsupportedTraitsTest {
public void failsOnHttpChecksumTrait() {
Exception thrown = Assertions.assertThrows(OpenApiException.class, () -> {
Model model = Model.assembler(getClass().getClassLoader())
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("unsupported-http-checksum.smithy"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("unsupported-http-checksum.smithy"))
+ .assemble()
+ .unwrap();
OpenApiConfig config = new OpenApiConfig();
config.setService(ShapeId.from("example.smithy#MyService"));
OpenApiConverter.create().config(config).convertToNode(model);
diff --git a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerDefinition.java b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerDefinition.java
index be132044120..8b9ece85ade 100644
--- a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerDefinition.java
+++ b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerDefinition.java
@@ -177,16 +177,16 @@ public Optional getEnableSimpleResponses() {
@Override
public Builder toBuilder() {
return builder()
- .scheme(scheme)
- .type(type)
- .uri(uri)
- .customAuthType(customAuthType)
- .credentials(credentials)
- .identitySource(identitySource)
- .identityValidationExpression(identityValidationExpression)
- .resultTtlInSeconds(resultTtlInSeconds)
- .authorizerPayloadFormatVersion(authorizerPayloadFormatVersion)
- .enableSimpleResponses(enableSimpleResponses);
+ .scheme(scheme)
+ .type(type)
+ .uri(uri)
+ .customAuthType(customAuthType)
+ .credentials(credentials)
+ .identitySource(identitySource)
+ .identityValidationExpression(identityValidationExpression)
+ .resultTtlInSeconds(resultTtlInSeconds)
+ .authorizerPayloadFormatVersion(authorizerPayloadFormatVersion)
+ .enableSimpleResponses(enableSimpleResponses);
}
@Override
@@ -206,15 +206,15 @@ public boolean equals(Object o) {
AuthorizerDefinition that = (AuthorizerDefinition) o;
return scheme.equals(that.scheme)
- && Objects.equals(type, that.type)
- && Objects.equals(uri, that.uri)
- && Objects.equals(customAuthType, that.customAuthType)
- && Objects.equals(credentials, that.credentials)
- && Objects.equals(identitySource, that.identitySource)
- && Objects.equals(identityValidationExpression, that.identityValidationExpression)
- && Objects.equals(resultTtlInSeconds, that.resultTtlInSeconds)
- && Objects.equals(authorizerPayloadFormatVersion, that.authorizerPayloadFormatVersion)
- && Objects.equals(enableSimpleResponses, that.enableSimpleResponses);
+ && Objects.equals(type, that.type)
+ && Objects.equals(uri, that.uri)
+ && Objects.equals(customAuthType, that.customAuthType)
+ && Objects.equals(credentials, that.credentials)
+ && Objects.equals(identitySource, that.identitySource)
+ && Objects.equals(identityValidationExpression, that.identityValidationExpression)
+ && Objects.equals(resultTtlInSeconds, that.resultTtlInSeconds)
+ && Objects.equals(authorizerPayloadFormatVersion, that.authorizerPayloadFormatVersion)
+ && Objects.equals(enableSimpleResponses, that.enableSimpleResponses);
}
@Override
diff --git a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerIndex.java b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerIndex.java
index 79145cc5f92..91977e2f1f1 100644
--- a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerIndex.java
+++ b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerIndex.java
@@ -44,7 +44,7 @@ public AuthorizerIndex(Model model) {
// Account for the edge case of no operations on the service.
service.getTrait(AuthorizerTrait.class)
- .ifPresent(trait -> serviceMap.put(service.getId(), trait.getValue()));
+ .ifPresent(trait -> serviceMap.put(service.getId(), trait.getValue()));
for (PathFinder.Path path : finder.search(service, SELECTOR)) {
String effectiveAuthorizer = null;
@@ -78,7 +78,7 @@ private static String getNullableAuthorizerValue(Shape shape, String previous) {
*/
public Optional getAuthorizer(ToShapeId service, ToShapeId shape) {
return Optional.ofNullable(authorizers.get(service.toShapeId()))
- .flatMap(mappings -> Optional.ofNullable(mappings.get(shape.toShapeId())));
+ .flatMap(mappings -> Optional.ofNullable(mappings.get(shape.toShapeId())));
}
/**
@@ -110,9 +110,9 @@ public Optional getAuthorizerValue(ToShapeId service) {
*/
public Optional getAuthorizerValue(ToShapeId service, ToShapeId shape) {
return getAuthorizer(service, shape)
- .flatMap(
- name -> Optional.ofNullable(authorizerTraits.get(service.toShapeId()))
- .flatMap(trait -> trait.getAuthorizer(name))
- );
+ .flatMap(
+ name -> Optional.ofNullable(authorizerTraits.get(service.toShapeId()))
+ .flatMap(trait -> trait.getAuthorizer(name))
+ );
}
}
diff --git a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTrait.java b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTrait.java
index eec167efd12..94286f2aaa1 100644
--- a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTrait.java
+++ b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTrait.java
@@ -98,12 +98,12 @@ public Builder toBuilder() {
@Override
protected Node createNode() {
return authorizers.entrySet()
- .stream()
- .sorted(Comparator.comparing(Map.Entry::getKey))
- .collect(ObjectNode.collectStringKeys(Map.Entry::getKey, Map.Entry::getValue))
- .toBuilder()
- .sourceLocation(getSourceLocation())
- .build();
+ .stream()
+ .sorted(Comparator.comparing(Map.Entry::getKey))
+ .collect(ObjectNode.collectStringKeys(Map.Entry::getKey, Map.Entry::getValue))
+ .toBuilder()
+ .sourceLocation(getSourceLocation())
+ .build();
}
/**
diff --git a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitValidator.java b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitValidator.java
index 1c50c71f1d9..5545acd849a 100644
--- a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitValidator.java
+++ b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitValidator.java
@@ -28,15 +28,15 @@ public final class AuthorizersTraitValidator extends AbstractValidator {
@Override
public List validate(Model model) {
return model.shapes(ServiceShape.class)
- .map(service -> validate(model, service))
- .flatMap(List::stream)
- .collect(Collectors.toList());
+ .map(service -> validate(model, service))
+ .flatMap(List::stream)
+ .collect(Collectors.toList());
}
private List validate(Model model, ServiceShape service) {
Map authorizers = service.getTrait(AuthorizersTrait.class)
- .map(AuthorizersTrait::getAuthorizers)
- .orElseGet(HashMap::new);
+ .map(AuthorizersTrait::getAuthorizers)
+ .orElseGet(HashMap::new);
List validationEvents = new ArrayList<>();
@@ -44,8 +44,8 @@ private List validate(Model model, ServiceShape service) {
authSchemaValidation.ifPresent(validationEvents::add);
Optional enableSimpleResponsesValidation = validateEnableSimpleResponsesConfig(
- authorizers,
- service
+ authorizers,
+ service
);
enableSimpleResponsesValidation.ifPresent(validationEvents::add);
@@ -57,18 +57,18 @@ private List validate(Model model, ServiceShape service) {
* matches one of the schemes of the protocols of the service.
*/
private Optional validateAuthSchema(
- Map authorizers,
- Model model,
- ServiceShape service
+ Map authorizers,
+ Model model,
+ ServiceShape service
) {
Set authSchemes = ServiceIndex.of(model).getAuthSchemes(service).keySet();
String invalidMappings = authorizers.entrySet()
- .stream()
- .filter(entry -> !authSchemes.contains(entry.getValue().getScheme()))
- .map(entry -> entry.getKey() + " -> " + entry.getValue().getScheme())
- .sorted()
- .collect(Collectors.joining(", "));
+ .stream()
+ .filter(entry -> !authSchemes.contains(entry.getValue().getScheme()))
+ .map(entry -> entry.getKey() + " -> " + entry.getValue().getScheme())
+ .sorted()
+ .collect(Collectors.joining(", "));
if (invalidMappings.isEmpty()) {
return Optional.empty();
@@ -76,17 +76,17 @@ private Optional validateAuthSchema(
AuthorizersTrait authorizersTrait = service.getTrait(AuthorizersTrait.class).get();
return Optional.of(
- error(
- service,
- authorizersTrait,
- String.format(
- "Each `scheme` of the `%s` trait must target one of the auth schemes applied to the service "
- + "(i.e., [%s]). The following mappings of authorizer names to schemes are invalid: %s",
- AuthorizersTrait.ID,
- ValidationUtils.tickedList(authSchemes),
- invalidMappings
+ error(
+ service,
+ authorizersTrait,
+ String.format(
+ "Each `scheme` of the `%s` trait must target one of the auth schemes applied to the service "
+ + "(i.e., [%s]). The following mappings of authorizer names to schemes are invalid: %s",
+ AuthorizersTrait.ID,
+ ValidationUtils.tickedList(authSchemes),
+ invalidMappings
+ )
)
- )
);
}
@@ -95,17 +95,17 @@ private Optional validateAuthSchema(
* should have the authorizedPayloadFormatVersion member set to 2.0.
*/
private Optional validateEnableSimpleResponsesConfig(
- Map authorizers,
- ServiceShape service
+ Map authorizers,
+ ServiceShape service
) {
String invalidConfigs = authorizers.entrySet()
- .stream()
- .filter(entry -> entry.getValue().getEnableSimpleResponses().isPresent())
- .filter(entry -> entry.getValue().getAuthorizerPayloadFormatVersion().isPresent())
- .filter(entry -> !entry.getValue().getAuthorizerPayloadFormatVersion().get().equals("2.0"))
- .map(Map.Entry::getKey)
- .sorted()
- .collect(Collectors.joining(", "));
+ .stream()
+ .filter(entry -> entry.getValue().getEnableSimpleResponses().isPresent())
+ .filter(entry -> entry.getValue().getAuthorizerPayloadFormatVersion().isPresent())
+ .filter(entry -> !entry.getValue().getAuthorizerPayloadFormatVersion().get().equals("2.0"))
+ .map(Map.Entry::getKey)
+ .sorted()
+ .collect(Collectors.joining(", "));
if (invalidConfigs.isEmpty()) {
return Optional.empty();
@@ -113,16 +113,16 @@ private Optional validateEnableSimpleResponsesConfig(
AuthorizersTrait authorizersTrait = service.getTrait(AuthorizersTrait.class).get();
return Optional.of(
- error(
- service,
- authorizersTrait,
- String.format(
- "The enableSimpleResponses member of %s is only supported when authorizedPayloadFormatVersion "
- + "is 2.0. The following authorizers are misconfigured: %s",
- AuthorizersTrait.ID,
- invalidConfigs
+ error(
+ service,
+ authorizersTrait,
+ String.format(
+ "The enableSimpleResponses member of %s is only supported when authorizedPayloadFormatVersion "
+ + "is 2.0. The following authorizers are misconfigured: %s",
+ AuthorizersTrait.ID,
+ invalidConfigs
+ )
)
- )
);
}
diff --git a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationResponse.java b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationResponse.java
index 12ef3f12245..3b916df36b4 100644
--- a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationResponse.java
+++ b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationResponse.java
@@ -115,9 +115,9 @@ public Builder toBuilder() {
responseTemplates.forEach(builder::putResponseTemplate);
responseParameters.forEach(builder::putResponseParameter);
return builder
- .sourceLocation(sourceLocation)
- .contentHandling(contentHandling)
- .statusCode(statusCode);
+ .sourceLocation(sourceLocation)
+ .contentHandling(contentHandling)
+ .statusCode(statusCode);
}
@Override
diff --git a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTrait.java b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTrait.java
index 34d9da3ee07..5b50e5f56f9 100644
--- a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTrait.java
+++ b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTrait.java
@@ -300,21 +300,21 @@ public Optional getResponse(String statusCode) {
public ObjectNode toExpandedNode(ToShapeId service, ToShapeId operation) {
ObjectNode result = toNode().expectObjectNode();
result = result.withMember(
- URI_KEY,
- formatComponent(
- service,
- operation,
- result.expectStringMember(URI_KEY).getValue()
- )
+ URI_KEY,
+ formatComponent(
+ service,
+ operation,
+ result.expectStringMember(URI_KEY).getValue()
+ )
);
if (result.containsMember(CREDENTIALS_KEY)) {
result = result.withMember(
- CREDENTIALS_KEY,
- formatComponent(
- service,
- operation,
- result.expectStringMember(CREDENTIALS_KEY).getValue()
- )
+ CREDENTIALS_KEY,
+ formatComponent(
+ service,
+ operation,
+ result.expectStringMember(CREDENTIALS_KEY).getValue()
+ )
);
}
return result;
@@ -330,8 +330,8 @@ public ObjectNode toExpandedNode(ToShapeId service, ToShapeId operation) {
*/
public static String formatComponent(ToShapeId service, ToShapeId operation, String component) {
return component
- .replace(SERVICE_NAME_LABEL, service.toShapeId().getName())
- .replace(OPERATION_NAME_LABEL, operation.toShapeId().getName());
+ .replace(SERVICE_NAME_LABEL, service.toShapeId().getName())
+ .replace(OPERATION_NAME_LABEL, operation.toShapeId().getName());
}
@Override
@@ -345,22 +345,22 @@ protected ObjectNode createNode() {
@Override
public Builder toBuilder() {
return builder()
- .sourceLocation(getSourceLocation())
- .type(type)
- .uri(uri)
- .credentials(credentials)
- .httpMethod(httpMethod)
- .passThroughBehavior(passThroughBehavior)
- .contentHandling(contentHandling)
- .timeoutInMillis(timeoutInMillis)
- .connectionId(connectionId)
- .connectionType(connectionType)
- .cacheNamespace(cacheNamespace)
- .payloadFormatVersion(payloadFormatVersion)
- .requestParameters(requestParameters)
- .requestTemplates(requestTemplates)
- .responses(responses)
- .cacheKeyParameters(cacheKeyParameters);
+ .sourceLocation(getSourceLocation())
+ .type(type)
+ .uri(uri)
+ .credentials(credentials)
+ .httpMethod(httpMethod)
+ .passThroughBehavior(passThroughBehavior)
+ .contentHandling(contentHandling)
+ .timeoutInMillis(timeoutInMillis)
+ .connectionId(connectionId)
+ .connectionType(connectionType)
+ .cacheNamespace(cacheNamespace)
+ .payloadFormatVersion(payloadFormatVersion)
+ .requestParameters(requestParameters)
+ .requestTemplates(requestTemplates)
+ .responses(responses)
+ .cacheKeyParameters(cacheKeyParameters);
}
public static final class Builder extends AbstractTraitBuilder {
diff --git a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitIndex.java b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitIndex.java
index 48ab863aeb5..e8f81694b8f 100644
--- a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitIndex.java
+++ b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitIndex.java
@@ -49,8 +49,8 @@ public static IntegrationTraitIndex of(Model model) {
*/
public Optional getIntegrationTrait(ToShapeId service, ToShapeId shape) {
return Optional.ofNullable(
- traits.getOrDefault(service.toShapeId(), MapUtils.of())
- .get(shape.toShapeId())
+ traits.getOrDefault(service.toShapeId(), MapUtils.of())
+ .get(shape.toShapeId())
);
}
@@ -79,8 +79,8 @@ private void walk(Model model, ShapeId service, EntityShape current, Trait trait
for (ShapeId resource : current.getResources()) {
model.getShape(resource)
- .flatMap(Shape::asResourceShape)
- .ifPresent(resourceShape -> walk(model, service, resourceShape, updatedTrait));
+ .flatMap(Shape::asResourceShape)
+ .ifPresent(resourceShape -> walk(model, service, resourceShape, updatedTrait));
}
for (ShapeId operation : current.getAllOperations()) {
@@ -90,11 +90,11 @@ private void walk(Model model, ShapeId service, EntityShape current, Trait trait
private static Trait extractTrait(Shape shape, Trait defaultValue) {
return shape.getTrait(MockIntegrationTrait.class)
- .map(trait -> (Trait) trait)
- .orElseGet(
- () -> shape.getTrait(IntegrationTrait.class)
- .map(trait -> (Trait) trait)
- .orElse(defaultValue)
- );
+ .map(trait -> (Trait) trait)
+ .orElseGet(
+ () -> shape.getTrait(IntegrationTrait.class)
+ .map(trait -> (Trait) trait)
+ .orElse(defaultValue)
+ );
}
}
diff --git a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/MockIntegrationTrait.java b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/MockIntegrationTrait.java
index 241a3696b7e..34a48b3c6f9 100644
--- a/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/MockIntegrationTrait.java
+++ b/smithy-aws-apigateway-traits/src/main/java/software/amazon/smithy/aws/apigateway/traits/MockIntegrationTrait.java
@@ -154,12 +154,12 @@ protected ObjectNode createNode() {
@Override
public Builder toBuilder() {
return builder()
- .sourceLocation(getSourceLocation())
- .passThroughBehavior(passThroughBehavior)
- .contentHandling(contentHandling)
- .requestParameters(requestParameters)
- .requestTemplates(requestTemplates)
- .responses(responses);
+ .sourceLocation(getSourceLocation())
+ .passThroughBehavior(passThroughBehavior)
+ .contentHandling(contentHandling)
+ .requestParameters(requestParameters)
+ .requestTemplates(requestTemplates)
+ .responses(responses);
}
public static final class Builder extends AbstractTraitBuilder {
diff --git a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerIndexTest.java b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerIndexTest.java
index b0f1e0d889e..27762fe3636 100644
--- a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerIndexTest.java
+++ b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizerIndexTest.java
@@ -17,10 +17,10 @@ public class AuthorizerIndexTest {
@Test
public void computesAuthorizers() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("effective-authorizers.smithy"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("effective-authorizers.smithy"))
+ .assemble()
+ .unwrap();
AuthorizerIndex index = AuthorizerIndex.of(model);
ShapeId serviceA = ShapeId.from("smithy.example#ServiceA");
@@ -37,8 +37,8 @@ public void computesAuthorizers() {
// Resolves service value.
assertThat(index.getAuthorizer(serviceA).get(), equalTo("foo"));
assertThat(
- index.getAuthorizerValue(serviceA).map(AuthorizerDefinition::getScheme),
- equalTo(Optional.of(SigV4Trait.ID))
+ index.getAuthorizerValue(serviceA).map(AuthorizerDefinition::getScheme),
+ equalTo(Optional.of(SigV4Trait.ID))
);
assertThat(index.getAuthorizer(serviceB), equalTo(Optional.empty()));
assertThat(index.getAuthorizerValue(serviceB), equalTo(Optional.empty()));
diff --git a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitTest.java b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitTest.java
index 805cb4d8bee..637a6ca0310 100644
--- a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitTest.java
+++ b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitTest.java
@@ -21,21 +21,21 @@ public void registersTrait() {
TraitFactory factory = TraitFactory.createServiceFactory();
ShapeId id = ShapeId.from("smithy.example#Foo");
ObjectNode node = Node.objectNodeBuilder()
- .withMember(
- "aws.v4",
- Node.objectNodeBuilder()
- .withMember("scheme", "aws.auth#sigv4")
- .withMember("type", "request")
- .withMember("uri", "arn:foo:baz")
- .withMember("credentials", "arn:foo:bar")
- .withMember("identitySource", "mapping.expression")
- .withMember("identityValidationExpression", "[A-Z]+")
- .withMember("resultTtlInSeconds", 100)
- .withMember("authorizerPayloadFormatVersion", "format.version")
- .withMember("enableSimpleResponse", true)
- .build()
- )
- .build();
+ .withMember(
+ "aws.v4",
+ Node.objectNodeBuilder()
+ .withMember("scheme", "aws.auth#sigv4")
+ .withMember("type", "request")
+ .withMember("uri", "arn:foo:baz")
+ .withMember("credentials", "arn:foo:bar")
+ .withMember("identitySource", "mapping.expression")
+ .withMember("identityValidationExpression", "[A-Z]+")
+ .withMember("resultTtlInSeconds", 100)
+ .withMember("authorizerPayloadFormatVersion", "format.version")
+ .withMember("enableSimpleResponse", true)
+ .build()
+ )
+ .build();
Trait trait = factory.createTrait(AuthorizersTrait.ID, id, node).get();
assertThat(trait, instanceOf(AuthorizersTrait.class));
diff --git a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitIndexTest.java b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitIndexTest.java
index e7e5abb4855..fd14569099c 100644
--- a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitIndexTest.java
+++ b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitIndexTest.java
@@ -15,10 +15,10 @@ public class IntegrationTraitIndexTest {
@Test
public void resolvesTraits() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(getClass().getResource("integration-index.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(getClass().getResource("integration-index.json"))
+ .assemble()
+ .unwrap();
IntegrationTraitIndex index = IntegrationTraitIndex.of(model);
ShapeId service = ShapeId.from("ns.foo#Service");
diff --git a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitTest.java b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitTest.java
index d5fba0bba47..38f790ae975 100644
--- a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitTest.java
+++ b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/IntegrationTraitTest.java
@@ -14,25 +14,25 @@ public class IntegrationTraitTest {
@Test
public void loadsValidTrait() {
IntegrationTrait trait = IntegrationTrait.builder()
- .type("aws_proxy")
- .uri("foo")
- .httpMethod("POST")
- .addCacheKeyParameter("foo")
- .cacheNamespace("baz")
- .connectionId("id")
- .connectionType("xyz")
- .contentHandling("CONVERT_TO_TEXT")
- .credentials("abc")
- .payloadFormatVersion("1.0")
- .passThroughBehavior("when_no_templates")
- .putRequestParameter("x", "y")
- .build();
+ .type("aws_proxy")
+ .uri("foo")
+ .httpMethod("POST")
+ .addCacheKeyParameter("foo")
+ .cacheNamespace("baz")
+ .connectionId("id")
+ .connectionType("xyz")
+ .contentHandling("CONVERT_TO_TEXT")
+ .credentials("abc")
+ .payloadFormatVersion("1.0")
+ .passThroughBehavior("when_no_templates")
+ .putRequestParameter("x", "y")
+ .build();
assertThat(trait.toBuilder().build(), equalTo(trait));
// Test round-tripping from/to node.
assertThat(
- new IntegrationTrait.Provider().createTrait(ShapeId.from("ns.foo#Operation"), trait.toNode()),
- equalTo(trait)
+ new IntegrationTrait.Provider().createTrait(ShapeId.from("ns.foo#Operation"), trait.toNode()),
+ equalTo(trait)
);
}
}
diff --git a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/MockIntegrationTraitTest.java b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/MockIntegrationTraitTest.java
index f707993a073..0b54983b923 100644
--- a/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/MockIntegrationTraitTest.java
+++ b/smithy-aws-apigateway-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/MockIntegrationTraitTest.java
@@ -15,46 +15,46 @@ public class MockIntegrationTraitTest {
@Test
public void loadsValidTrait() {
MockIntegrationTrait trait = MockIntegrationTrait.builder()
- .contentHandling("CONVERT_TO_TEXT")
- .passThroughBehavior("when_no_templates")
- .putRequestParameter("x", "y")
- .putRequestTemplate("application/json", "{}")
- .putRequestParameter("foo", "baz")
- .putResponse(
- "[A-Z]+",
- IntegrationResponse.builder()
- .statusCode("200")
- .contentHandling("CONVERT_TO_TEXT")
- .build()
- )
- .build();
+ .contentHandling("CONVERT_TO_TEXT")
+ .passThroughBehavior("when_no_templates")
+ .putRequestParameter("x", "y")
+ .putRequestTemplate("application/json", "{}")
+ .putRequestParameter("foo", "baz")
+ .putResponse(
+ "[A-Z]+",
+ IntegrationResponse.builder()
+ .statusCode("200")
+ .contentHandling("CONVERT_TO_TEXT")
+ .build()
+ )
+ .build();
assertThat(trait.toBuilder().build(), equalTo(trait));
// Test round-tripping from/to node.
assertThat(
- new MockIntegrationTrait.Provider().createTrait(ShapeId.from("com.foo#Baz"), trait.toNode()),
- equalTo(trait)
+ new MockIntegrationTrait.Provider().createTrait(ShapeId.from("com.foo#Baz"), trait.toNode()),
+ equalTo(trait)
);
}
@Test
public void loadsTraitFromModel() {
Model model = Model.assembler()
- .discoverModels(getClass().getClassLoader())
- .addImport(TestRunnerTest.class.getResource("errorfiles/valid-integration.json"))
- .assemble()
- .unwrap();
+ .discoverModels(getClass().getClassLoader())
+ .addImport(TestRunnerTest.class.getResource("errorfiles/valid-integration.json"))
+ .assemble()
+ .unwrap();
MockIntegrationTrait trait = model.expectShape(ShapeId.from("ns.foo#Operation"))
- .getTrait(MockIntegrationTrait.class)
- .get();
+ .getTrait(MockIntegrationTrait.class)
+ .get();
assertThat(trait.toBuilder().build(), equalTo(trait));
// Test round-tripping from/to node.
assertThat(
- new MockIntegrationTrait.Provider().createTrait(ShapeId.from("ns.foo#Operation"), trait.toNode()),
- equalTo(trait)
+ new MockIntegrationTrait.Provider().createTrait(ShapeId.from("ns.foo#Operation"), trait.toNode()),
+ equalTo(trait)
);
}
}
diff --git a/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnMutabilityTraitValidator.java b/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnMutabilityTraitValidator.java
index b9edba58247..973e31377fd 100644
--- a/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnMutabilityTraitValidator.java
+++ b/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnMutabilityTraitValidator.java
@@ -26,15 +26,15 @@ public List validate(Model model) {
// create mutabilities cannot overlap.
if (shape.hasTrait(CfnAdditionalIdentifierTrait.ID) && (trait.isWrite() || trait.isCreate())) {
events.add(
- error(
- shape,
- trait,
- String.format(
- "Member with the mutability value of \"%s\" "
- + "is also marked as an additional identifier",
- trait.getValue()
+ error(
+ shape,
+ trait,
+ String.format(
+ "Member with the mutability value of \"%s\" "
+ + "is also marked as an additional identifier",
+ trait.getValue()
+ )
)
- )
);
}
}
diff --git a/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResource.java b/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResource.java
index 21710a5b628..d1a055beb0b 100644
--- a/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResource.java
+++ b/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResource.java
@@ -42,9 +42,9 @@ private CfnResource(Builder builder) {
if (excludedProperties.contains(shapeId)) {
// Remove an excluded ShapeId for validation.
CfnResourceProperty updatedDefinition = propertyDefinition.getValue()
- .toBuilder()
- .removeShapeId(shapeId)
- .build();
+ .toBuilder()
+ .removeShapeId(shapeId)
+ .build();
propertyDefinitions.put(propertyDefinition.getKey(), updatedDefinition);
// Update any definition in available properties to also
@@ -109,7 +109,7 @@ public Set getCreateOnlyProperties() {
return getConstrainedProperties(definition -> {
Set mutabilities = definition.getMutabilities();
return mutabilities.contains(CfnResourceIndex.Mutability.CREATE)
- && !mutabilities.contains(CfnResourceIndex.Mutability.WRITE);
+ && !mutabilities.contains(CfnResourceIndex.Mutability.WRITE);
});
}
@@ -148,16 +148,16 @@ public Set getWriteOnlyProperties() {
// Otherwise, create and update, or update only become writeOnly.
return mutabilities.contains(CfnResourceIndex.Mutability.WRITE)
- && !mutabilities.contains(CfnResourceIndex.Mutability.READ);
+ && !mutabilities.contains(CfnResourceIndex.Mutability.READ);
});
}
private Set getConstrainedProperties(Predicate constraint) {
return getProperties().entrySet()
- .stream()
- .filter(property -> constraint.test(property.getValue()))
- .map(Map.Entry::getKey)
- .collect(Collectors.toSet());
+ .stream()
+ .filter(property -> constraint.test(property.getValue()))
+ .map(Map.Entry::getKey)
+ .collect(Collectors.toSet());
}
/**
@@ -197,10 +197,10 @@ public List> getAdditionalIdentifiers() {
@Override
public Builder toBuilder() {
return builder()
- .propertyDefinitions(propertyDefinitions)
- .excludedProperties(excludedProperties)
- .primaryIdentifiers(primaryIdentifiers)
- .additionalIdentifiers(additionalIdentifiers);
+ .propertyDefinitions(propertyDefinitions)
+ .excludedProperties(excludedProperties)
+ .primaryIdentifiers(primaryIdentifiers)
+ .additionalIdentifiers(additionalIdentifiers);
}
public static final class Builder implements SmithyBuilder {
@@ -221,8 +221,8 @@ public Builder putPropertyDefinition(String propertyName, CfnResourceProperty de
}
public Builder updatePropertyDefinition(
- String propertyName,
- Function updater
+ String propertyName,
+ Function updater
) {
CfnResourceProperty definition = propertyDefinitions.get(propertyName);
diff --git a/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResourceIndex.java b/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResourceIndex.java
index 7c629d3a51b..20bf56ff055 100644
--- a/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResourceIndex.java
+++ b/smithy-aws-cloudformation-traits/src/main/java/software/amazon/smithy/aws/cloudformation/traits/CfnResourceIndex.java
@@ -39,13 +39,13 @@
public final class CfnResourceIndex implements KnowledgeIndex {
static final Set FULLY_MUTABLE = SetUtils.of(
- Mutability.CREATE,
- Mutability.READ,
- Mutability.WRITE
+ Mutability.CREATE,
+ Mutability.READ,
+ Mutability.WRITE
);
static final Set INHERITED_MUTABILITY = SetUtils.of(
- Mutability.CREATE,
- Mutability.READ
+ Mutability.CREATE,
+ Mutability.READ
);
private final Map resourceDefinitions = new HashMap<>();
@@ -86,108 +86,108 @@ public CfnResourceIndex(Model model) {
PropertyBindingIndex propertyIndex = PropertyBindingIndex.of(model);
BottomUpIndex bottomUpIndex = BottomUpIndex.of(model);
model.shapes(ResourceShape.class)
- .filter(shape -> shape.hasTrait(CfnResourceTrait.ID))
- .forEach(resource -> {
- CfnResource.Builder builder = CfnResource.builder();
- ShapeId resourceId = resource.getId();
-
- Set parentResources = model.getServiceShapes()
- .stream()
- .map(service -> bottomUpIndex.getResourceBinding(service, resourceId))
- .flatMap(OptionalUtils::stream)
- .collect(Collectors.toSet());
-
- // Start with the explicit resource identifiers.
- builder.primaryIdentifiers(resource.getIdentifiers().keySet());
- setIdentifierMutabilities(builder, resource, parentResources);
-
- // Use the read lifecycle's input to collect the additional identifiers
- // and its output to collect readable properties.
- resource.getRead().ifPresent(operationId -> {
- OperationShape operation = model.expectShape(operationId, OperationShape.class);
- StructureShape input = model.expectShape(operation.getInputShape(), StructureShape.class);
- addAdditionalIdentifiers(builder, computeResourceAdditionalIdentifiers(input));
-
- StructureShape output = propertyIndex.getOutputPropertiesShape(operation);
- updatePropertyMutabilities(
- builder,
- model,
- resourceId,
- operationId,
- output,
- SetUtils.of(Mutability.READ),
- this::addReadMutability
- );
- });
-
- // Use the put lifecycle's input to collect put-able properties.
- resource.getPut().ifPresent(operationId -> {
- OperationShape operation = model.expectShape(operationId, OperationShape.class);
- StructureShape input = propertyIndex.getInputPropertiesShape(operation);
- updatePropertyMutabilities(
- builder,
- model,
- resourceId,
- operationId,
- input,
- SetUtils.of(Mutability.CREATE, Mutability.WRITE),
- this::addPutMutability
- );
- });
-
- // Use the create lifecycle's input to collect creatable properties.
- resource.getCreate().ifPresent(operationId -> {
- OperationShape operation = model.expectShape(operationId, OperationShape.class);
- StructureShape input = propertyIndex.getInputPropertiesShape(operation);
- updatePropertyMutabilities(
- builder,
- model,
- resourceId,
- operationId,
- input,
- SetUtils.of(Mutability.CREATE),
- this::addCreateMutability
- );
- });
-
- // Use the update lifecycle's input to collect writeable properties.
- resource.getUpdate().ifPresent(operationId -> {
- OperationShape operation = model.expectShape(operationId, OperationShape.class);
- StructureShape input = propertyIndex.getInputPropertiesShape(operation);
- updatePropertyMutabilities(
- builder,
- model,
- resourceId,
- operationId,
- input,
- SetUtils.of(Mutability.WRITE),
- this::addWriteMutability
- );
- });
-
- // Apply any members found through the trait's additionalSchemas property.
- CfnResourceTrait trait = resource.expectTrait(CfnResourceTrait.class);
- for (ShapeId additionalSchema : trait.getAdditionalSchemas()) {
- // These shapes should be present given the @idRef failWhenMissing
- // setting, but gracefully handle if they're not.
- model.getShape(additionalSchema)
- .flatMap(Shape::asStructureShape)
- .ifPresent(shape -> {
- addAdditionalIdentifiers(builder, computeResourceAdditionalIdentifiers(shape));
- updatePropertyMutabilities(
+ .filter(shape -> shape.hasTrait(CfnResourceTrait.ID))
+ .forEach(resource -> {
+ CfnResource.Builder builder = CfnResource.builder();
+ ShapeId resourceId = resource.getId();
+
+ Set parentResources = model.getServiceShapes()
+ .stream()
+ .map(service -> bottomUpIndex.getResourceBinding(service, resourceId))
+ .flatMap(OptionalUtils::stream)
+ .collect(Collectors.toSet());
+
+ // Start with the explicit resource identifiers.
+ builder.primaryIdentifiers(resource.getIdentifiers().keySet());
+ setIdentifierMutabilities(builder, resource, parentResources);
+
+ // Use the read lifecycle's input to collect the additional identifiers
+ // and its output to collect readable properties.
+ resource.getRead().ifPresent(operationId -> {
+ OperationShape operation = model.expectShape(operationId, OperationShape.class);
+ StructureShape input = model.expectShape(operation.getInputShape(), StructureShape.class);
+ addAdditionalIdentifiers(builder, computeResourceAdditionalIdentifiers(input));
+
+ StructureShape output = propertyIndex.getOutputPropertiesShape(operation);
+ updatePropertyMutabilities(
builder,
model,
resourceId,
- null,
- shape,
- SetUtils.of(),
- Function.identity()
- );
- });
- }
-
- resourceDefinitions.put(resourceId, builder.build());
- });
+ operationId,
+ output,
+ SetUtils.of(Mutability.READ),
+ this::addReadMutability
+ );
+ });
+
+ // Use the put lifecycle's input to collect put-able properties.
+ resource.getPut().ifPresent(operationId -> {
+ OperationShape operation = model.expectShape(operationId, OperationShape.class);
+ StructureShape input = propertyIndex.getInputPropertiesShape(operation);
+ updatePropertyMutabilities(
+ builder,
+ model,
+ resourceId,
+ operationId,
+ input,
+ SetUtils.of(Mutability.CREATE, Mutability.WRITE),
+ this::addPutMutability
+ );
+ });
+
+ // Use the create lifecycle's input to collect creatable properties.
+ resource.getCreate().ifPresent(operationId -> {
+ OperationShape operation = model.expectShape(operationId, OperationShape.class);
+ StructureShape input = propertyIndex.getInputPropertiesShape(operation);
+ updatePropertyMutabilities(
+ builder,
+ model,
+ resourceId,
+ operationId,
+ input,
+ SetUtils.of(Mutability.CREATE),
+ this::addCreateMutability
+ );
+ });
+
+ // Use the update lifecycle's input to collect writeable properties.
+ resource.getUpdate().ifPresent(operationId -> {
+ OperationShape operation = model.expectShape(operationId, OperationShape.class);
+ StructureShape input = propertyIndex.getInputPropertiesShape(operation);
+ updatePropertyMutabilities(
+ builder,
+ model,
+ resourceId,
+ operationId,
+ input,
+ SetUtils.of(Mutability.WRITE),
+ this::addWriteMutability
+ );
+ });
+
+ // Apply any members found through the trait's additionalSchemas property.
+ CfnResourceTrait trait = resource.expectTrait(CfnResourceTrait.class);
+ for (ShapeId additionalSchema : trait.getAdditionalSchemas()) {
+ // These shapes should be present given the @idRef failWhenMissing
+ // setting, but gracefully handle if they're not.
+ model.getShape(additionalSchema)
+ .flatMap(Shape::asStructureShape)
+ .ifPresent(shape -> {
+ addAdditionalIdentifiers(builder, computeResourceAdditionalIdentifiers(shape));
+ updatePropertyMutabilities(
+ builder,
+ model,
+ resourceId,
+ null,
+ shape,
+ SetUtils.of(),
+ Function.identity()
+ );
+ });
+ }
+
+ resourceDefinitions.put(resourceId, builder.build());
+ });
}
public static CfnResourceIndex of(Model model) {
@@ -206,28 +206,28 @@ public Optional getResource(ToShapeId resource) {
private boolean identifierIsInherited(String identifier, Set parentResources) {
return parentResources.stream()
- .anyMatch(parentResource -> parentResource.getIdentifiers().containsKey(identifier));
+ .anyMatch(parentResource -> parentResource.getIdentifiers().containsKey(identifier));
}
private void setIdentifierMutabilities(
- CfnResource.Builder builder,
- ResourceShape resource,
- Set parentResources
+ CfnResource.Builder builder,
+ ResourceShape resource,
+ Set parentResources
) {
Set defaultIdentifierMutability = getDefaultIdentifierMutabilities(resource);
resource.getIdentifiers().forEach((name, shape) -> {
builder.putPropertyDefinition(
- name,
- CfnResourceProperty.builder()
- .hasExplicitMutability(true)
- .mutabilities(
- identifierIsInherited(name, parentResources)
- ? INHERITED_MUTABILITY
- : defaultIdentifierMutability
- )
- .addShapeId(shape)
- .build()
+ name,
+ CfnResourceProperty.builder()
+ .hasExplicitMutability(true)
+ .mutabilities(
+ identifierIsInherited(name, parentResources)
+ ? INHERITED_MUTABILITY
+ : defaultIdentifierMutability
+ )
+ .addShapeId(shape)
+ .build()
);
});
}
@@ -255,8 +255,8 @@ private List