Skip to content

Impossible to generate clients for non-aws services due to dependency on aws.api#Service trait #2522

Closed as not planned
@Petroniuss

Description

@Petroniuss

Describe the feature

Looks like the only way to generate go smithy clients is to build both projects source - codegen: Move protocol generators out of aws-sdk-go-v2 into smithy-go:

  • smithy-go
  • aws-sdk-go-v2

However, it's not possible to generate basic http clients without modifying source of aws-sdk-go-v2. The reason for that is that most GoIntegrations specific to AWS residing in aws-sdk-go-v2 do something similar to lines below:

 ServiceShape serviceShape = settings.getService(model);
 return serviceShape.expectTrait(ServiceTrait.class).getSdkId();

This causes the code generation to fail if the service isn't annotated with aws.api#Service.

Relevant parts of the stacktrace showing the problem:

software.amazon.smithy.model.node.ExpectationNotMetException: 
Expected shape example#ExampleClient to have a trait 
software.amazon.smithy.aws.traits.ServiceTrait...
...
at software.amazon.smithy.model.shapes.Shape.lambda$expectTrait$0(Shape.java:332)
   at java.base/java.util.Optional.orElseThrow(Optional.java:403)
   at software.amazon.smithy.model.shapes.Shape.expectTrait(Shape.java:332)
   at software.amazon.smithy.aws.go.codegen.AwsSdkServiceId.processServiceId(AwsSdkServiceId.java:33)
   at software.amazon.smithy.go.codegen.ServiceGenerator.generateMetadata(ServiceGenerator.java:109)
   at software.amazon.smithy.go.codegen.ServiceGenerator.generate(ServiceGenerator.java:96)

Use Case

Trying to generate go clients using smithy for non-aws services.

Proposed Solution

Would it be possible to first check if a service has the aws.api#Service trait and if it doesn't then skip applying the integration? This is how I've seen other aws smithy repos do it. Of course I'd prefer to just use smithy-go but this seems to be blocked/not prioritized.,

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS Go SDK V2 Module Versions Used

2024-02-28 release

Go version used

1.20

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions