Skip to content

Commit 049533d

Browse files
authored
feat(client-nimble): change StudioComponentConfiguration from union to structure (#2971)
1 parent 0dd68ef commit 049533d

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.smithy.aws.typescript.codegen;
17+
18+
import java.util.Map;
19+
import software.amazon.smithy.aws.traits.ServiceTrait;
20+
import software.amazon.smithy.build.PluginContext;
21+
import software.amazon.smithy.model.Model;
22+
import software.amazon.smithy.model.shapes.ServiceShape;
23+
import software.amazon.smithy.model.shapes.ShapeId;
24+
import software.amazon.smithy.model.shapes.ShapeType;
25+
import software.amazon.smithy.model.transform.ModelTransformer;
26+
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
27+
import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration;
28+
import software.amazon.smithy.utils.MapUtils;
29+
import software.amazon.smithy.utils.SmithyInternalApi;
30+
31+
/**
32+
* Add Nimble customization.
33+
*/
34+
@SmithyInternalApi
35+
public class AddNimbleCustomizations implements TypeScriptIntegration {
36+
37+
@Override
38+
public Model preprocessModel(PluginContext context, TypeScriptSettings settings) {
39+
Model model = context.getModel();
40+
ServiceShape service = settings.getService(model);
41+
String serviceId = service.getTrait(ServiceTrait.class).map(ServiceTrait::getSdkId).orElse("");
42+
if (!serviceId.equals("nimble")) {
43+
return context.getModel();
44+
}
45+
Map<ShapeId, ShapeType> overWriteTypeMap = MapUtils.of(
46+
ShapeId.from("com.amazonaws.nimble#StudioComponentConfiguration"), ShapeType.STRUCTURE);
47+
return ModelTransformer.create().changeShapeType(model, overWriteTypeMap);
48+
}
49+
}

codegen/smithy-aws-typescript-codegen/src/main/resources/META-INF/services/software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ software.amazon.smithy.aws.typescript.codegen.AddBuiltinPlugins
44
software.amazon.smithy.aws.typescript.codegen.AddAwsAuthPlugin
55
software.amazon.smithy.aws.typescript.codegen.AddProtocols
66
software.amazon.smithy.aws.typescript.codegen.AwsEndpointGeneratorIntegration
7+
software.amazon.smithy.aws.typescript.codegen.AddNimbleCustomizations
78
software.amazon.smithy.aws.typescript.codegen.AwsServiceIdIntegration
89
software.amazon.smithy.aws.typescript.codegen.AwsPackageFixturesGeneratorIntegration
910
software.amazon.smithy.aws.typescript.codegen.AddSqsDependency

0 commit comments

Comments
 (0)