Skip to content

Commit 9e1bc18

Browse files
committed
Add support for generating schemas for operations and service shapes
1 parent ce03fcb commit 9e1bc18

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-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)

codegen/plugins/types/src/main/java/software/amazon/smithy/python/codegen/types/DirectedPythonTypeCodegen.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public GenerationContext createContext(CreateContextDirective<PythonSettings, Py
6464
public void customizeBeforeShapeGeneration(CustomizeDirective<GenerationContext, PythonSettings> directive) {
6565
new ServiceErrorGenerator(directive.settings(), directive.context().writerDelegator()).run();
6666
SchemaGenerator.generateAll(directive.context(), directive.connectedShapes().values(), shape -> {
67+
if (shape.isOperationShape() || shape.isServiceShape()) {
68+
return false;
69+
}
6770
if (shape.isStructureShape()) {
6871
return shouldGenerateStructure(directive.settings(), shape);
6972
}

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 _:
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)