Smithy Model Gen Part 2 - #3883
Open
sbaluja wants to merge 18 commits into
Open
Conversation
- Fix typos in EnumRenderer FORBIDDEN_WORDS: co_yeild->co_yield, moduel->module - Make generateResultSource/Header protocol-aware (was hardcoded to JSON) - Fix endpoint context param accessor casing (need PascalCase for C++ accessors)
Composable model-to-model transform chain that runs before code generation. Service-level transforms will implement ModelTransform and register in the pipeline.
ModelGenerator is now a thin dispatcher that routes classified shapes to registered ShapeRenderer implementations. Adding new classification types (e.g., event streams) requires only a new renderer class, not editing the orchestrator. - EnumShapeRenderer, SubObjectRenderer, RequestRenderer, ResultRenderer - Consolidate isPrimitive() into CppTypeMapper - Promote writeDocComment/collapseWhitespace to public in MemberRenderer - No behavioral change to generated output
Transforms run before generation, per-service. Service-level transforms (S3, EC2, etc.) will implement ModelTransform and register in the pipeline. Also deduplicate sanitize() between ModelCodegenPlugin and ServiceNameUtil.
Extract shared logic into renderMembers(emitHasBeenSet) to eliminate ~100 lines of near-identical code between request and result rendering.
Enables Smithy's built-in change detection and file tracking instead of raw Files.writeString().
Add response-side event stream generation (handler, initial response, and event stream union) plus request augmentation for simplex streaming operations, closing the gap versus C2J for kinesis SubscribeToShard and bedrock-runtime streaming operations. - Add EventStreamRenderer producing the handler and initial-response (with serde stubs) and the header-only event stream union, matching C2J which emits no .cpp for the union. - Augment RequestRenderer with HasEventStreamResponse/IsEventStreamRequest and the decoder/handler accessors, placing members to match C2J ordering. - Add event stream detection helpers to ShapeClassifier and event-stream serde stub helpers to SerdeStub. - Restore handler and union documentation to match C2J. - Deduplicate renderClassDocComment into MemberRenderer and emit the file copyright header once from CppWriterDelegator.
sbaluja
marked this pull request as ready for review
July 30, 2026 18:49
sbiscigl
reviewed
Jul 30, 2026
Collaborator
There was a problem hiding this comment.
in multiple places in the code we have classes that are more or less
publc class FileGenerator {
public void function() {
if(protocol.isJsonLike()) {
... do json thing
} else {
... do xml thing
}
}
}theres a couple of issues i see with that, logic for protocols is scattered between classes, and that xml is used at a fallback. protocol should be selected once in the generator then injected into generator classes, where they dont need to remember protocol specific logic. i.e.
public interface ProtocolSpecificCommands {
void WriteSerializerHeaders();
// whatever others functions
}
public class JsonCommands implements ProtocolSpecificCommands {
@override
void WriteSerializerHeaders() { .. do json stuff}
}
public class Generator {
private final ProtocolSpecificCommands commands;
public void run() {
commands.WriteSerializerHeaders(... pass in scope)
}
}
public class Plugin {
ProtocolSpecificCommands commands = new JsonCommands();
Generator generator = new Generator(commands)
}that way its easier to add more protocols, you dont need to add another branch statment, and you can handle the "no such protocol, throw exception" once instead of in multiple places.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Description of changes:
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.