Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Smithy Changelog

## 1.0.7 (TBD)

### Bug Fixes

* Fixed a bug where `passthroughBehavior` was misspelled as `passThroughBehavior`
in APIGateway OpenAPI output for integrations and mock integrations.

## 1.0.6 (2020-06-24)

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Logger;
Expand Down Expand Up @@ -54,6 +55,8 @@ final class AddIntegrations implements ApiGatewayMapper {
private static final String DEFAULT_KEY = "default";
private static final String STATUS_CODE_KEY = "statusCode";
private static final String RESPONSE_PARAMETERS_KEY = "responseParameters";
private static final String PASSTHROUGH_BEHAVIOR = "passthroughBehavior";
private static final String INCORRECT_PASSTHROUGH_BEHAVIOR = "passThroughBehavior";

@Override
public List<ApiGatewayConfig.ApiType> getApiTypes() {
Expand Down Expand Up @@ -98,13 +101,23 @@ private static ObjectNode getIntegrationAsObject(
OperationShape shape,
Trait integration
) {
ObjectNode integrationNode;
if (integration instanceof MockIntegrationTrait) {
return integration.toNode().expectObjectNode().withMember("type", Node.from("mock"));
integrationNode = integration.toNode().expectObjectNode().withMember("type", Node.from("mock"));
} else if (integration instanceof IntegrationTrait) {
return ((IntegrationTrait) integration).toExpandedNode(context.getService(), shape);
integrationNode = ((IntegrationTrait) integration).toExpandedNode(context.getService(), shape);
} else {
throw new OpenApiException("Unexpected integration trait: " + integration);
}

// Fix a naming issue where the Smithy trait uses a different casing for "passthroughBehavior"
Optional<Node> passthroughBehavior = integrationNode.getMember(INCORRECT_PASSTHROUGH_BEHAVIOR);
if (passthroughBehavior.isPresent()) {
integrationNode = integrationNode
.withoutMember(INCORRECT_PASSTHROUGH_BEHAVIOR)
.withMember(PASSTHROUGH_BEHAVIOR, passthroughBehavior.get());
}
return integrationNode;
}

private ObjectNode updateIntegrationWithCors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"cacheNamespace": "cache namespace",
"cacheKeyParameters": [],
"passThroughBehavior": "never",
"responses": {
"2\\d{2}": {
"statusCode": "200",
Expand Down Expand Up @@ -112,6 +113,7 @@
"integration.request.path.stage": "method.request.querystring.version",
"integration.request.querystring.provider": "method.request.querystring.vendor"
},
"passThroughBehavior": "when_no_match",
"responses": {
"2\\d{2}": {
"statusCode": "200",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"application/xml": "#set ($root=$input.path('$')) <stage>$root.name</stage> ",
"application/json": "#set ($root=$input.path('$')) { \"stage\": \"$root.name\", \"user-id\": \"$root.key\" }"
},
"passthroughBehavior": "never",
"responses": {
"302": {
"statusCode": "302",
Expand Down Expand Up @@ -169,6 +170,7 @@
"application/xml": "#set ($root=$input.path('$')) <stage>$root.name</stage> ",
"application/json": "#set ($root=$input.path('$')) { \"stage\": \"$root.name\", \"user-id\": \"$root.key\" }"
},
"passthroughBehavior": "when_no_match",
"responses": {
"302": {
"statusCode": "302",
Expand Down