Skip to content

Commit 6f55b49

Browse files
committed
Instantiate APIOperation instead of subclassing it
1 parent 10103d0 commit 6f55b49

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import software.amazon.smithy.model.shapes.OperationShape;
1313
import software.amazon.smithy.model.shapes.ShapeId;
1414
import software.amazon.smithy.python.codegen.GenerationContext;
15+
import software.amazon.smithy.python.codegen.SmithyPythonDependency;
1516
import software.amazon.smithy.python.codegen.SymbolProperties;
1617
import software.amazon.smithy.python.codegen.writer.PythonWriter;
1718
import software.amazon.smithy.utils.SmithyInternalApi;
@@ -41,23 +42,24 @@ public void run() {
4142
var outSymbol = symbolProvider.toSymbol(model.expectShape(shape.getOutputShape()));
4243

4344
writer.addStdlibImport("dataclasses", "dataclass");
45+
writer.addDependency(SmithyPythonDependency.SMITHY_CORE);
4446
writer.addImport("smithy_core.schemas", "APIOperation");
45-
writer.addImport("smithy_core.type_registry", "TypeRegistry");
47+
writer.addImport("smithy_core.documents", "TypeRegistry");
4648

4749
writer.write("""
48-
@dataclass(kw_only=True, frozen=True)
49-
class $1L(APIOperation["$2T", "$3T"]):
50-
input = $2T
51-
output = $3T
52-
schema = $4T
53-
input_schema = $5T
54-
output_schema = $6T
50+
$1L = APIOperation(
51+
input = $2T,
52+
output = $3T,
53+
schema = $4T,
54+
input_schema = $5T,
55+
output_schema = $6T,
5556
error_registry = TypeRegistry({
5657
$7C
57-
})
58+
}),
5859
effective_auth_schemes = [
5960
$8C
6061
]
62+
)
6163
""",
6264
opSymbol.getName(),
6365
inSymbol,
@@ -67,8 +69,6 @@ class $1L(APIOperation["$2T", "$3T"]):
6769
outSymbol.expectProperty(SymbolProperties.SCHEMA),
6870
writer.consumer(this::writeErrorTypeRegistry),
6971
writer.consumer(this::writeAuthSchemes)
70-
// TODO: Docs? Maybe not necessary on the operation type itself
71-
// TODO: Singleton?
7272
);
7373
}
7474

0 commit comments

Comments
 (0)