Skip to content

Revert "Use standardized REST-JSON behavior (#2783)" #2795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,11 @@ public List<MemberModel> getUnboundMembers() {
List<MemberModel> unboundMembers = new ArrayList<>();
if (members != null) {
for (MemberModel member : members) {
if (member.getHttp().getLocation() == null && !member.getHttp().getIsPayload()) {
if (member.getHttp().getLocation() == null) {
if (hasPayloadMember) {
// There is an explicit payload, but this unbound
// member isn't it.
// Note: Somewhat unintuitive, explicit payloads don't
// have an explicit location; they're identified by
// the payload HTTP trait being true.
throw new IllegalStateException(String.format(
"C2J Shape %s has both an explicit payload member and unbound (no explicit location) member, %s."
+ " This is undefined behavior, verify the correctness of the C2J model.",
c2jName, member.getName()));
"C2J Shape %s has both an explicit payload member and unbound (no explicit location) members. "
+ "This is undefined behavior, verify the correctness of the C2J model", c2jName));
}
unboundMembers.add(member);
}
Expand Down Expand Up @@ -227,12 +221,7 @@ public List<MemberModel> getUnboundEventMembers() {
public boolean hasPayloadMembers() {
return hasPayloadMember ||
getExplicitEventPayloadMember() != null ||
hasImplicitPayloadMembers();

}

public boolean hasImplicitPayloadMembers() {
return !getUnboundMembers().isEmpty() ||
!getUnboundMembers().isEmpty() ||
(isEvent() && !getUnboundEventMembers().isEmpty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ protected FieldSpec operationInfoField() {
.add(".httpMethod($T.$L)", SdkHttpMethod.class, shapeModel.getMarshaller().getVerb())
.add(".hasExplicitPayloadMember($L)", shapeModel.isHasPayloadMember() ||
shapeModel.getExplicitEventPayloadMember() != null)
.add(".hasImplicitPayloadMembers($L)", shapeModel.hasImplicitPayloadMembers())
.add(".hasPayloadMembers($L)", shapeModel.hasPayloadMembers());

if (StringUtils.isNotBlank(shapeModel.getMarshaller().getTarget())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
@SdkInternalApi
public class AllTypesRequestMarshaller implements Marshaller<AllTypesRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true)
.hasPayloadMembers(true).build();
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasPayloadMembers(true).build();

private final BaseAwsJsonProtocolFactory protocolFactory;

Expand All @@ -33,10 +32,11 @@ public SdkHttpFullRequest marshall(AllTypesRequest allTypesRequest) {
Validate.paramNotNull(allTypesRequest, "allTypesRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(allTypesRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
@SdkInternalApi
public class EventStreamOperationRequestMarshaller implements Marshaller<EventStreamOperationRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
.requestUri("/2016-03-11/eventStreamOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
.hasImplicitPayloadMembers(false).hasPayloadMembers(true).hasEventStreamingInput(true).build();
.requestUri("/2016-03-11/eventStreamOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
.hasPayloadMembers(true).hasEventStreamingInput(true).build();

private final BaseAwsJsonProtocolFactory protocolFactory;

Expand All @@ -33,7 +33,7 @@ public SdkHttpFullRequest marshall(EventStreamOperationRequest eventStreamOperat
Validate.paramNotNull(eventStreamOperationRequest, "eventStreamOperationRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(eventStreamOperationRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class EventStreamOperationWithOnlyInputRequestMarshaller implements Marshaller<EventStreamOperationWithOnlyInputRequest> {
public class EventStreamOperationWithOnlyInputRequestMarshaller implements
Marshaller<EventStreamOperationWithOnlyInputRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
.requestUri("/2016-03-11/EventStreamOperationWithOnlyInput").httpMethod(SdkHttpMethod.POST)
.hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true).hasPayloadMembers(true).hasEventStreamingInput(true)
.build();
.requestUri("/2016-03-11/EventStreamOperationWithOnlyInput").httpMethod(SdkHttpMethod.POST)
.hasExplicitPayloadMember(false).hasPayloadMembers(true).hasEventStreamingInput(true).build();

private final BaseAwsJsonProtocolFactory protocolFactory;

Expand All @@ -34,10 +34,11 @@ public SdkHttpFullRequest marshall(EventStreamOperationWithOnlyInputRequest even
Validate.paramNotNull(eventStreamOperationWithOnlyInputRequest, "eventStreamOperationWithOnlyInputRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(eventStreamOperationWithOnlyInputRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
@SdkInternalApi
public class NestedContainersRequestMarshaller implements Marshaller<NestedContainersRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true)
.hasPayloadMembers(true).build();
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasPayloadMembers(true).build();

private final BaseAwsJsonProtocolFactory protocolFactory;

Expand All @@ -33,10 +32,11 @@ public SdkHttpFullRequest marshall(NestedContainersRequest nestedContainersReque
Validate.paramNotNull(nestedContainersRequest, "nestedContainersRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(nestedContainersRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public class OperationWithNoInputOrOutputRequestMarshaller implements Marshaller<OperationWithNoInputOrOutputRequest> {
public class OperationWithNoInputOrOutputRequestMarshaller implements
Marshaller<OperationWithNoInputOrOutputRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/")
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(false)
.hasPayloadMembers(false).build();
.httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasPayloadMembers(false).build();

private final BaseAwsJsonProtocolFactory protocolFactory;

Expand All @@ -33,10 +33,11 @@ public SdkHttpFullRequest marshall(OperationWithNoInputOrOutputRequest operation
Validate.paramNotNull(operationWithNoInputOrOutputRequest, "operationWithNoInputOrOutputRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(operationWithNoInputOrOutputRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
@SdkInternalApi
public class StreamingInputOperationRequestMarshaller implements Marshaller<StreamingInputOperationRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
.requestUri("/2016-03-11/streamingInputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
.hasImplicitPayloadMembers(false).hasPayloadMembers(true).hasStreamingInput(true).build();
.requestUri("/2016-03-11/streamingInputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true)
.hasPayloadMembers(true).hasStreamingInput(true).build();

private final BaseAwsJsonProtocolFactory protocolFactory;

Expand All @@ -33,10 +33,11 @@ public SdkHttpFullRequest marshall(StreamingInputOperationRequest streamingInput
Validate.paramNotNull(streamingInputOperationRequest, "streamingInputOperationRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(streamingInputOperationRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
@SdkInternalApi
public class StreamingOutputOperationRequestMarshaller implements Marshaller<StreamingOutputOperationRequest> {
private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder()
.requestUri("/2016-03-11/streamingOutputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false)
.hasImplicitPayloadMembers(false).hasPayloadMembers(false).build();
.requestUri("/2016-03-11/streamingOutputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false)
.hasPayloadMembers(false).build();

private final BaseAwsJsonProtocolFactory protocolFactory;

Expand All @@ -33,10 +33,11 @@ public SdkHttpFullRequest marshall(StreamingOutputOperationRequest streamingOutp
Validate.paramNotNull(streamingOutputOperationRequest, "streamingOutputOperationRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(streamingOutputOperationRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
@SdkProtectedApi
public class DefaultJsonContentTypeResolver implements JsonContentTypeResolver {
private static final String REST_JSON_CONTENT_TYPE = "application/json";

private final String prefix;

Expand All @@ -33,9 +32,7 @@ public DefaultJsonContentTypeResolver(String prefix) {

@Override
public String resolveContentType(AwsJsonProtocolMetadata protocolMetadata) {
if (AwsJsonProtocol.REST_JSON.equals(protocolMetadata.protocol())) {
return REST_JSON_CONTENT_TYPE;
}
//Changing this to 'application/json' may break clients expecting 'application/x-amz-json-1.1'
return prefix + protocolMetadata.protocolVersion();
}
}
Loading