Skip to content

Commit

Permalink
codegen: Upgrade to smithy 1.25.0 (#1835)
Browse files Browse the repository at this point in the history
* Upgrade to smithy 1.25.0

Update EC2 unboxed shapes to boxed shapes backfill customization

Due to changes in smithy 2.0 nullability semantics around the
`@box` trait, the generated code for `ec2.json` generated
incorrect code.

Instead of adding `@box` traits to certain members in the
customization, the `@clientOptional` trait is added to members
of all structure shapes.

Chores:

- Add mavenLocal to codegen build files
- Update .gitignore to ignore .idea/

* Regenerate clients with break/fix's

Due to prior bugs for `@box` members not being serialized as a
pointer type and incorrect pagination serialization, the clients
in this commit are regenerated with the break/fix's.
  • Loading branch information
Steven Yuan authored Sep 14, 2022
1 parent 296bfb3 commit a13b7a4
Show file tree
Hide file tree
Showing 327 changed files with 2,285 additions and 1,650 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Gemfile.lock
/private/model/cli/gen-api/gen-api
.gradle/
build/
.idea/
2 changes: 1 addition & 1 deletion codegen/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
smithyVersion=1.23.1
smithyVersion=1.25.0
smithyGradleVersion=0.6.0
1 change: 1 addition & 0 deletions codegen/protocol-test-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ val smithyVersion: String by project
buildscript {
val smithyVersion: String by project
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
Expand Down
1 change: 1 addition & 0 deletions codegen/sdk-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ val smithyVersion: String by project
buildscript {
val smithyVersion: String by project
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package software.amazon.smithy.aws.go.codegen.customization;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
import software.amazon.smithy.codegen.core.CodegenException;
import software.amazon.smithy.go.codegen.CodegenUtils;
import software.amazon.smithy.go.codegen.GoSettings;
import software.amazon.smithy.go.codegen.integration.GoIntegration;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.transform.ModelTransformer;
import software.amazon.smithy.model.shapes.MemberShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.model.shapes.ShapeType;
import software.amazon.smithy.model.traits.BoxTrait;
import software.amazon.smithy.model.shapes.StructureShape;
import software.amazon.smithy.model.traits.ClientOptionalTrait;
import software.amazon.smithy.utils.SetUtils;

public class BackfillEc2UnboxedToBoxedShapes implements GoIntegration {
Expand All @@ -26,7 +28,7 @@ public class BackfillEc2UnboxedToBoxedShapes implements GoIntegration {

/**
* /**
* Updates the API model to customize all number and boolean unboxed shapes to be boxed.
* Updates the API model to customize all structured members to be nullable.
*
* @param model API model
* @param settings Go codegen settings
Expand All @@ -39,63 +41,12 @@ public Model preprocessModel(Model model, GoSettings settings) {
return model;
}

Model.Builder builder = model.toBuilder();

for (Shape shape : model.toSet()) {
// Only consider number and boolean shapes that are unboxed
if (shape.isMemberShape()) {
continue;
}
if (!(CodegenUtils.isNumber(shape) || shape.getType() == ShapeType.BOOLEAN)) {
continue;
List<Shape> updates = new ArrayList<>();
for (StructureShape struct : model.getStructureShapes()) {
for (MemberShape member : struct.getAllMembers().values()) {
updates.add(member.toBuilder().addTrait(new ClientOptionalTrait()).build());
}
if (shape.hasTrait(BoxTrait.class)) {
continue;
}

switch (shape.getType()) {
case BYTE:
shape = shape.asByteShape().get().toBuilder()
.addTrait(new BoxTrait())
.build();
break;
case SHORT:
shape = shape.asShortShape().get().toBuilder()
.addTrait(new BoxTrait())
.build();
break;
case INTEGER:
shape = shape.asIntegerShape().get().toBuilder()
.addTrait(new BoxTrait())
.build();
break;
case LONG:
shape = shape.asLongShape().get().toBuilder()
.addTrait(new BoxTrait())
.build();
break;
case FLOAT:
shape = shape.asFloatShape().get().toBuilder()
.addTrait(new BoxTrait())
.build();
break;
case DOUBLE:
shape = shape.asDoubleShape().get().toBuilder()
.addTrait(new BoxTrait())
.build();
break;
case BOOLEAN:
shape = shape.asBooleanShape().get().toBuilder()
.addTrait(new BoxTrait())
.build();
break;
default:
throw new CodegenException("unexpected shape type for " + shape.getId() + ", " + shape.getType());
}

builder.addShape(shape);
}

return builder.build();
return ModelTransformer.create().replaceShapes(model, updates);
}
}
4 changes: 2 additions & 2 deletions service/acmpca/deserializers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions service/acmpca/serializers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions service/acmpca/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions service/acmpca/validators.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions service/appconfig/api_op_CreateDeploymentStrategy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/appconfig/api_op_CreateExtension.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/appconfig/api_op_CreateExtensionAssociation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/appconfig/api_op_DeleteExtension.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/appconfig/api_op_GetDeployment.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/appconfig/api_op_GetExtension.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions service/appconfig/api_op_ListApplications.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions service/appconfig/api_op_ListConfigurationProfiles.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions service/appconfig/api_op_ListDeploymentStrategies.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a13b7a4

Please sign in to comment.