Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align need for orphaned shape generation better with Smithy code generation recommendations/idioms #627

Open
robin-aws opened this issue Oct 9, 2024 · 4 comments

Comments

@robin-aws
Copy link
Contributor

Splitting this off from #622, which is about testing for the current state better, whereas this issue is about improving the current state.

Local services need to generate code for shapes not in the service closure for at least two different reasons:

  1. The config shape for a local service isn't directly connected to the service, only through the @localService$config member.
  2. Interceptors like the DB ESDK need configuration structures to be generated for shapes that are completely disconnected from any service, mainly because the interceptor concept is not yet modeled in a local service.

smithy-dafny generally generates code for all shapes in a namespace to get around this, but this can be surprising and makes it harder to re-use logic from other smithy-<lang> code generators.

Being able to generate just types from shapes without a dummy service attached is a very common Smithy feature request, and a general feature may land in the future we can use here.

@texastony
Copy link
Contributor

Note: in the meantime, it would be really Groovy if Smithy Danfy's various code generators could consolidate on the same shape selection logic.

That is difficult, but would be Groovy.

@robin-aws
Copy link
Contributor Author

FYI the standard solution for orphaned shapes is to add dummy operations to bring them into the service closure. That's probably our best option until Smithy itself broadly supports a proper feature for adding shapes to the closure, or "types" code generation that isn't driven by the closure.

@texastony
Copy link
Contributor

That is not an acceptable solution,
in our use case,
at least on it's own.

Because that would add Dummy operations to our public interfaces.

That will not earn customer trust.

@texastony
Copy link
Contributor

We could have some silly trait that comes back and deletes the dummy operations...
But... I'd rather us refactor to have a static create service operation that takes the service config as an input.

If we had a trait/member on the local service trait,
or some other indication,
that the operation is used to create the local service,
along with additional traits for references/resources,
we could actually just model local service and resource creation.

Finally, if we refactor the models to ensure that all of a service's errors are listed on the service,
we have entirely removed the currently identified orphaned shapes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants