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

fix: Add service client version to user-agent #851

Merged
merged 4 commits into from
Nov 6, 2024
Merged

Conversation

jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Nov 5, 2024

Description of changes

  • Remove all resources from service clients
  • Render a static version property into each service client
  • Correct data fields on smithy-swift related SwiftDependencies and DRY them up with a helper function

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

dependenciesByTarget.forEach { writeTargetDependency(writer, it) }
}
writer.openBlock("resources: [", "]") {
writer.write(".process(\"Resources\")")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the resources declaration from the service client, since it doesn't have resources anymore.

val SMITHY_XML = smithySwiftDependency("SmithyXML")
val SMITHY_JSON = smithySwiftDependency("SmithyJSON")
val SMITHY_FORM_URL = smithySwiftDependency("SmithyFormURL")
val SMITHY_WAITERS_API = smithySwiftDependency("SmithyWaitersAPI")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the smithy-swift libraries have been DRYed up with the helper method below.

@@ -30,6 +30,7 @@ open class HttpProtocolServiceClient(
ClientRuntimeTypes.Core.Client,
) {
writer.write("public static let clientName = \$S", serviceSymbol.name)
writer.write("public static let version = \$S", ctx.settings.moduleVersion)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the static property on service client that contains the version.

val TestInitializer = runtimeSymbol("TestInitializer")
val TestBaseError = runtimeSymbol("TestBaseError")
val TestInitializer = runtimeSymbol("TestInitializer", SwiftDeclaration.ENUM)
val TestBaseError = runtimeSymbol("TestBaseError", SwiftDeclaration.STRUCT)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added type info to these symbols.

@@ -17,9 +18,15 @@ class PackageManifestGeneratorTests {
private val testContext = setupTests("simple-service-with-operation-and-dependency.smithy", "smithy.example#Example")

@Test
fun `it renders package manifest file with macOS and iOS platforms block`() {
fun `it starts with a swift-tools-version statement`() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this test because a Swift package manifest is invalid without it.

@jbelkins jbelkins marked this pull request as ready for review November 5, 2024 23:13
@jbelkins jbelkins merged commit 211bf19 into main Nov 6, 2024
31 checks passed
@jbelkins jbelkins deleted the jbe/ua_version branch November 6, 2024 20:37
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

Successfully merging this pull request may close these issues.

3 participants