Skip to content

Commit

Permalink
feat(smithydotnet): add dependency error from localservice trait (#288)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Lucas McDonald <[email protected]>
  • Loading branch information
josecorella and lucasmcdonald3 authored Sep 20, 2023
1 parent c32e241 commit be60f69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions TestModels/Dependencies/Model/Dependencies.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace simple.dependencies
use simple.resources#SimpleResources
use simple.constraints#SimpleConstraints
use simple.extendable.resources#SimpleExtendableResources
use simple.errors#SimpleErrors
// TODO: Uncomment out as part of https://sim.amazon.com/issues/CrypTool-5231
//use simple.errors#SimpleErrors

@aws.polymorph#localService(
sdkId: "SimpleDependencies",
Expand All @@ -14,7 +15,8 @@ use simple.errors#SimpleErrors
SimpleResources,
SimpleConstraints,
SimpleExtendableResources,
SimpleErrors
// TODO: Uncomment out as part of https://sim.amazon.com/issues/CrypTool-5231
// SimpleErrors
]
)
service SimpleDependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,17 @@ protected TokenTree errorFromDanyBody(final TreeSet<StructureShape> errorShapes)
Set<String> dependentNamespaces = ModelUtils.findAllDependentNamespaces(
new HashSet<ShapeId>(Collections.singleton(localServiceTrait.getConfigId())), model);

if (localServiceTrait.getDependencies() != null) {
localServiceTrait.getDependencies().stream()
.map(model::expectShape)
.map(Shape::asServiceShape)
.filter(Optional::isPresent)
.map(Optional::get)
.forEach( serviceShape ->
dependentNamespaces.add(serviceShape.getId().getNamespace())
);
}

if (dependentNamespaces.size() > 0) {
Set<TokenTree> cases = new HashSet<>();
for (String dependentNamespace : dependentNamespaces) {
Expand Down

0 comments on commit be60f69

Please sign in to comment.