Open Baccata opened 9 months ago
Can you say more about the use case?
Sure : there is a use case in our organisation for automating the update of some smithy files depending on some information stored in a database somewhere.
The smithy files can also be manually edited to add some additional information, but also read by third parties that seek to manually implement the contracts represented by the smithy models when code-generators are unavailable.
In the particular case of structure shapes, a large amount of traits applied on the shape's members negatively impacts the readability of the smithy files, and the apply
keyword can be used to regain some readability of the overall data structure whilst keeping the semantics identical. However, the automated edition of the files (which leverages the SmithyIdlSerializer
construct) prevents the decision of which traits should be inlined with the members and which traits should be "externalised" using apply
.
Thanks for sharing the use case. One thing to keep in mind with trying to automate updates to existing models is that the IDL serializer loses things like comments and any existing formatting. If that’s acceptable, then we can look into extending the serializer to address your use case. Otherwise, when trying to modify models in place and not lose comments or existing formatting, smithy-syntax should be used.
Yup, we're aware of the loss of formatting and comments when using the serializer, that is absolutely acceptable.
The API of the serializer is very convenient, we like it very much. The lack of control over the placement of the traits is the only pain point we're experiencing around it.
When writing smithy specifications by hand, traits can be written by :
apply
keyword, potentially in another fileWhen rendering a smithy model via the
SmithyIdlSerializer
, it'd be nice to have an option to control whether the trait should be inlined with the shape, or rendered using anapply
statement, in which case it'd be nice to have control over the file in which the apply statement is rendered.