Skip to content

Commit abd250a

Browse files
committed
Add support for generating schemas for operations and service shapes
1 parent 522b085 commit abd250a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

codegen/core/src/main/java/software/amazon/smithy/python/codegen/generators/SchemaGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ public static void generateAll(
8383
var index = TopologicalIndex.of(context.model());
8484
Stream.concat(index.getOrderedShapes().stream(), index.getRecursiveShapes().stream())
8585
.filter(shapes::contains)
86-
.filter(shape -> !shape.isOperationShape() && !shape.isResourceShape()
87-
&& !shape.isServiceShape()
86+
.filter(shape -> !shape.isResourceShape()
8887
&& !shape.isMemberShape()
8988
&& !Prelude.isPreludeShape(shape))
9089
.filter(filter::apply)

packages/smithy-core/src/smithy_core/documents.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ def __init__(
9494
else:
9595
self._value = value
9696

97-
if self._schema.shape_type is not ShapeType.DOCUMENT:
97+
if self._schema.shape_type not in (
98+
ShapeType.DOCUMENT,
99+
ShapeType.OPERATION,
100+
ShapeType.SERVICE,
101+
):
98102
self._type = self._schema.shape_type
99103
else:
100104
# TODO: set an appropriate schema if one was not provided
@@ -311,6 +315,10 @@ def serialize_contents(self, serializer: ShapeSerializer) -> None:
311315
raise SmithyException(
312316
f"Unexpexcted DOCUMENT shape type for document value: {self.as_value()}"
313317
)
318+
case ShapeType.OPERATION | ShapeType.SERVICE:
319+
raise SmithyException(
320+
f"Unexpected {self._type} shape type for document value: {self.as_value()}"
321+
)
314322

315323
def serialize_members(self, serializer: ShapeSerializer) -> None:
316324
for value in self.as_map().values():

packages/smithy-core/src/smithy_core/shapes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ class ShapeType(Enum):
122122

123123
# We won't acutally be using these, probably
124124
# MEMBER = 20
125-
# SERVICE = 21
125+
SERVICE = 21
126126
# RESOURCE = 22
127-
# OPERATION = 23
127+
OPERATION = 23

0 commit comments

Comments
 (0)