Skip to content
Merged
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
a5fbb3d
service init, code to separate client and service
Jun 24, 2025
74efe84
server can be ran
Jun 27, 2025
4ae4afb
Merge branch 'server-sdk-main' of https://github.com/smithy-lang/smit…
Jun 27, 2025
172cc97
application in build.gradle.kts
Jun 27, 2025
e9007b1
detele non-finished code
Jun 27, 2025
03c15d0
ktlintformat
Jun 27, 2025
7c6ca67
change style
Jun 30, 2025
3a9ec4d
ktlintformat
Jun 30, 2025
7fb8705
add abstraction for service
Jun 30, 2025
859c02b
minor fix
Jun 30, 2025
7d5b92e
minor fix
Jun 30, 2025
1455933
cbor serde
Jul 2, 2025
39e67b6
Merge branch 'server-sdk-main' of github.com:smithy-lang/smithy-kotli…
Jul 2, 2025
40d4af8
fix
Jul 2, 2025
3db1971
formatting
Jul 2, 2025
219c66f
comment
Jul 2, 2025
d0b7d11
fix
Jul 2, 2025
4de4c84
fix
Jul 2, 2025
f9fb095
generate routing based on smithy file
Jul 2, 2025
313b758
ktlint format
Jul 2, 2025
8870ca4
service framework abstraction
Jul 3, 2025
c108529
ktlint foramt
Jul 3, 2025
344512b
logging
Jul 3, 2025
304550a
ktlint format
Jul 3, 2025
bdb9101
add ContentTypeGuard
Jul 4, 2025
40f69b0
ktlint
Jul 4, 2025
23590fe
fix content type guard
Jul 7, 2025
3b750b2
pull from server-sdk-main
Jul 8, 2025
9b14ed7
ktlint
Jul 8, 2025
68b985e
move some parameters, e.g. engine, port, log level to be chosen in ru…
Jul 8, 2025
50fae66
ktlint
Jul 8, 2025
5e5fac9
fix
Jul 8, 2025
0fa77aa
error handler
Jul 8, 2025
25b033e
ktlint
Jul 8, 2025
7ec323f
fix logging
Jul 9, 2025
a8f7f2c
Merge branch 'service-sdk-routing' of github.com:smithy-lang/smithy-k…
Jul 9, 2025
7aafc7e
error handler message envelope
Jul 9, 2025
1a62c87
use error handler for content guard type
Jul 9, 2025
047f8a2
fix
Jul 9, 2025
8f97cc9
Merge branch 'service-sdk-routing' of github.com:smithy-lang/smithy-k…
Jul 9, 2025
b917b44
fix
Jul 9, 2025
dfa7673
ktlint
Jul 9, 2025
8d95731
Merge branch 'service-sdk-routing' of github.com:smithy-lang/smithy-k…
Jul 9, 2025
25b5f08
Merge branch 'server-sdk-main' of github.com:smithy-lang/smithy-kotli…
Jul 10, 2025
20018b5
ktlint
Jul 10, 2025
1effbfb
fix
Jul 10, 2025
493d888
fix and set up
Jul 10, 2025
51419e3
test set up
Jul 10, 2025
81ee058
authentication set up
Jul 10, 2025
e2b9dcb
fix
Jul 11, 2025
c774456
kitlint
Jul 11, 2025
c670441
error handler for auth
Jul 11, 2025
3e705f7
generate all the files
Jul 11, 2025
984fdec
cbor serializer fix
Jul 11, 2025
78e85df
remove manual input
Jul 11, 2025
c64a23d
fix
Jul 11, 2025
b8df0d3
abstraction of service framework and run type
Jul 14, 2025
7c24657
simplify the code
Jul 14, 2025
7d2dd2c
Merge branch 'service-sdk-error' of github.com:smithy-lang/smithy-kot…
Jul 14, 2025
9e7b8e2
Merge branch 'service-sdk-authentication' of github.com:smithy-lang/s…
Jul 14, 2025
e66343f
Merge branch 'server-sdk-main' of github.com:smithy-lang/smithy-kotli…
Jul 14, 2025
40e5f47
fix
Jul 14, 2025
08e85c8
merge
Jul 14, 2025
3493c66
test works
Jul 14, 2025
274c6b9
ktlint
Jul 14, 2025
512b84e
auth
Jul 14, 2025
337033a
fix
Jul 14, 2025
323df57
merge
Jul 14, 2025
dfc38b3
end to end test for post
Jul 15, 2025
0bc3711
fix testing
Jul 15, 2025
32ee46f
additional testing
Jul 15, 2025
6bfe679
fix
Jul 15, 2025
73feb6c
add test, accept content type and some improvement of the code
Jul 15, 2025
336c309
add closing test
Jul 15, 2025
82351b3
more tests
Jul 15, 2025
cd9f87e
add parameters
Jul 16, 2025
bad0985
add testing
Jul 16, 2025
5a103ec
fix engine factory
Jul 16, 2025
a98ca12
fix
Jul 16, 2025
6cac4e7
merge
Jul 16, 2025
a2abdaf
fix
Jul 16, 2025
bad5be5
fix
Jul 16, 2025
2a12023
add print for testing
Jul 16, 2025
95165df
fix
Jul 16, 2025
db2a8d3
fix
Jul 16, 2025
287b408
chore: v1.5-main merge (#1328)
ianbotsf Jul 17, 2025
0019542
chore: release 1.5.0
aws-sdk-kotlin-ci Jul 17, 2025
238b479
chore: bump snapshot version to 1.5.1-SNAPSHOT
aws-sdk-kotlin-ci Jul 17, 2025
93649e1
fix: correct the Brazil mapping for aws-crt-kotlin 0.10.* (#1334)
ianbotsf Jul 17, 2025
3dfc9b3
chore: release 1.5.1
aws-sdk-kotlin-ci Jul 17, 2025
b5d177c
chore: bump snapshot version to 1.5.2-SNAPSHOT
aws-sdk-kotlin-ci Jul 17, 2025
a5bc47b
fix circular dependency now all works
Jul 17, 2025
b1cb5ae
fix
Jul 17, 2025
9dfa590
remove println
Jul 17, 2025
c666db7
test
Jul 17, 2025
42f8ec7
test
Jul 17, 2025
95f77e1
test
Jul 17, 2025
26a4ef8
port listener
Jul 17, 2025
d1c5224
ktlint
Jul 17, 2025
faa549b
fix
Jul 17, 2025
a67198f
fix
Jul 18, 2025
b8fd8ed
fix
Jul 18, 2025
5e8fd00
fix naming
Jul 21, 2025
5a60b67
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into serv…
Jul 21, 2025
65f81f4
fix
Jul 21, 2025
499aa43
Merge branch 'server-sdk-main' into service-sdk-testing
luigi617 Jul 21, 2025
7193630
fix
Jul 21, 2025
1052703
Merge remote-tracking branch 'origin/service-sdk-testing' into servic…
Jul 21, 2025
c0cd07a
fix
Jul 22, 2025
f66a76e
fix
Jul 22, 2025
61ce2f8
fix
Jul 22, 2025
de04da0
fix
Jul 22, 2025
904c906
fix
Jul 22, 2025
4041dc6
fix
Jul 22, 2025
2613a29
fix
Jul 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ apiValidation {
"nullability-tests",
"paginator-tests",
"waiter-tests",
"service-codegen-tests",
"compile",
"slf4j-1x-consumer",
"slf4j-2x-consumer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class RpcV2Cbor : AwsHttpBindingProtocolGenerator() {
resolver.requestBindings(op)
}
val httpPayload = bindings.firstOrNull { it.location == HttpBinding.Location.PAYLOAD }

if (httpPayload != null) {
renderExplicitHttpPayloadSerializer(ctx, httpPayload, writer)
} else {
Expand All @@ -117,9 +118,15 @@ class RpcV2Cbor : AwsHttpBindingProtocolGenerator() {
// delegate to the generate operation body serializer function
val sdg = structuredDataSerializer(ctx)
val opBodySerializerFn = sdg.operationSerializer(ctx, op, documentMembers)
writer.write("builder.body = #T(context, input)", opBodySerializerFn)
if (ctx.settings.build.generateServiceProject) {
writer.write("response = #T(context, input)", opBodySerializerFn)
} else {
writer.write("builder.body = #T(context, input)", opBodySerializerFn)
}
}
if (!ctx.settings.build.generateServiceProject) {
renderContentTypeHeader(ctx, op, writer, resolver)
}
renderContentTypeHeader(ctx, op, writer, resolver)
}

/**
Expand Down
8 changes: 4 additions & 4 deletions codegen/smithy-kotlin-codegen-testutils/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ dependencies {

tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
freeCompilerArgs.add("-Xjdk-release=1.8")
jvmTarget.set(JvmTarget.JVM_17)
freeCompilerArgs.add("-Xjdk-release=17")
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}

// Reusable license copySpec
Expand Down
8 changes: 4 additions & 4 deletions codegen/smithy-kotlin-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ val generateSdkRuntimeVersion by tasks.registering {

tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
freeCompilerArgs.add("-Xjdk-release=1.8")
jvmTarget.set(JvmTarget.JVM_17)
freeCompilerArgs.add("-Xjdk-release=17")
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
dependsOn(generateSdkRuntimeVersion)
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}

// Reusable license copySpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private fun getDefaultRuntimeVersion(): String {
const val RUNTIME_GROUP: String = "aws.smithy.kotlin"
val RUNTIME_VERSION: String = System.getProperty("smithy.kotlin.codegen.clientRuntimeVersion", getDefaultRuntimeVersion())
val KOTLIN_COMPILER_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCompilerVersion", "2.2.0")
val KTOR_VERSION: String = System.getProperty("smithy.kotlin.codegen.ktorVersion", "3.1.3")
val KTOR_VERSION: String = System.getProperty("smithy.kotlin.codegen.ktorVersion", "3.2.2")
val SERIALIZATION_PLUGIN: String = System.getProperty("smithy.kotlin.codegen.SerializationPlugin", "2.0.20")
val KOTLINX_VERSION: String = System.getProperty("smithy.kotlin.codegen.ktorKotlinxVersion", "1.9.0")
val KTOR_LOGGING_BACKEND_VERSION: String = System.getProperty("smithy.kotlin.codegen.ktorLoggingBackendVersion", "1.4.14")
Expand Down Expand Up @@ -144,8 +144,11 @@ data class KotlinDependency(
// FIXME: version numbers should not be hardcoded, they should be setting dynamically based on the Gradle library versions
val KTOR_SERVER_CORE = KotlinDependency(GradleConfiguration.Implementation, "io.ktor.server", "io.ktor", "ktor-server-core", KTOR_VERSION)
val KTOR_SERVER_NETTY = KotlinDependency(GradleConfiguration.Implementation, "io.ktor.server.netty", "io.ktor", "ktor-server-netty", KTOR_VERSION)
val KTOR_SERVER_CIO = KotlinDependency(GradleConfiguration.Implementation, "io.ktor.server.cio", "io.ktor", "ktor-server-cio", KTOR_VERSION)
val KTOR_SERVER_JETTY_JAKARTA = KotlinDependency(GradleConfiguration.Implementation, "io.ktor.server.jetty.jakarta", "io.ktor", "ktor-server-jetty-jakarta", KTOR_VERSION)
val KTOR_SERVER_HTTP = KotlinDependency(GradleConfiguration.Implementation, "io.ktor.http", "io.ktor", "ktor-http-jvm", KTOR_VERSION)
val KTOR_SERVER_LOGGING = KotlinDependency(GradleConfiguration.Implementation, "io.ktor.server.plugins.calllogging", "io.ktor", "ktor-server-call-logging", KTOR_VERSION)
val KTOR_SERVER_BODY_LIMIT = KotlinDependency(GradleConfiguration.Implementation, "io.ktor.server.plugins", "io.ktor", "ktor-server-body-limit", KTOR_VERSION)
val KTOR_LOGGING_SLF4J = KotlinDependency(GradleConfiguration.Implementation, "org.slf4j", "ch.qos.logback", "logback-classic", KTOR_LOGGING_BACKEND_VERSION)
val KTOR_LOGGING_LOGBACK = KotlinDependency(GradleConfiguration.Implementation, "ch.qos.logback", "ch.qos.logback", "logback-classic", KTOR_LOGGING_BACKEND_VERSION)
val KTOR_SERVER_STATUS_PAGE = KotlinDependency(GradleConfiguration.Implementation, "io.ktor.server.plugins.statuspages", "io.ktor", "ktor-server-status-pages-jvm", KTOR_VERSION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,12 @@ object RuntimeTypes {
val embeddedServer = symbol("embeddedServer", "engine")
val EmbeddedServerType = symbol("EmbeddedServer", "engine")
val ApplicationEngineFactory = symbol("ApplicationEngineFactory", "engine")
val connector = symbol("connector", "engine")

val Application = symbol("Application", "application")
val ApplicationCallClass = symbol("ApplicationCall", "application")
val ApplicationStarting = symbol("ApplicationStarting", "application")
val ApplicationStarted = symbol("ApplicationStarted", "application")
val ApplicationStopping = symbol("ApplicationStopping", "application")
val ApplicationStopped = symbol("ApplicationStopped", "application")
val ApplicationCreateRouteScopedPlugin = symbol("createRouteScopedPlugin", "application")
Expand Down Expand Up @@ -536,11 +539,23 @@ object RuntimeTypes {

object KtorServerNetty : RuntimeTypePackage(KotlinDependency.KTOR_SERVER_NETTY) {
val Netty = symbol("Netty")
val Configuration = symbol("Configuration", "NettyApplicationEngine")
}

object KtorServerCio : RuntimeTypePackage(KotlinDependency.KTOR_SERVER_CIO) {
val CIO = symbol("CIO")
val Configuration = symbol("Configuration", "CIOApplicationEngine")
}

object KtorServerJettyJakarta : RuntimeTypePackage(KotlinDependency.KTOR_SERVER_JETTY_JAKARTA) {
val Jetty = symbol("Jetty")
val Configuration = symbol("Configuration", "JettyApplicationEngineBase")
}

object KtorServerHttp : RuntimeTypePackage(KotlinDependency.KTOR_SERVER_HTTP) {
val ContentType = symbol("ContentType")
val HttpStatusCode = symbol("HttpStatusCode")
val parseAndSortHeader = symbol("parseAndSortHeader")
val HttpHeaders = symbol("HttpHeaders")
val Cbor = symbol("Cbor", "ContentType.Application")
val Json = symbol("Json", "ContentType.Application")
Expand All @@ -550,6 +565,11 @@ object RuntimeTypes {
val CallLogging = symbol("CallLogging")
}

object KtorServerBodyLimit : RuntimeTypePackage(KotlinDependency.KTOR_SERVER_BODY_LIMIT) {
val RequestBodyLimit = symbol("RequestBodyLimit", "bodylimit")
val PayloadTooLargeException = symbol("PayloadTooLargeException")
}

object KtorLoggingSlf4j : RuntimeTypePackage(KotlinDependency.KTOR_LOGGING_SLF4J) {
val Level = symbol("Level", "event")
val LoggerFactory = symbol("LoggerFactory")
Expand Down Expand Up @@ -582,4 +602,8 @@ object RuntimeTypes {
object KotlinxJsonSerde : RuntimeTypePackage(KotlinDependency.KOTLINX_JSON_SERDE) {
val Json = symbol("Json")
}

object Duration {
val seconds = "kotlin.time.Duration.Companion.seconds".toSymbol()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,27 +182,47 @@ abstract class HttpBindingProtocolGenerator : ProtocolGenerator {
val serdeMeta = HttpSerdeMeta(op.isInputEventStream(ctx.model))

ctx.delegator.useSymbolWriter(serializerSymbol) { writer ->
writer
.addImport(operationSerializerSymbols)
.write("")
.openBlock("internal class #T: #T.#L<#T> {", serializerSymbol, RuntimeTypes.HttpClient.Operation.HttpSerializer, serdeMeta.variantName, serializationSymbol)
.call {
val modifier = if (serdeMeta.isStreaming) "suspend " else ""
writer.openBlock(
"override #Lfun serialize(context: #T, input: #T): #T {",
modifier,
RuntimeTypes.Core.ExecutionContext,
serializationSymbol,
RuntimeTypes.Http.Request.HttpRequestBuilder,
)
.write("val builder = #T()", RuntimeTypes.Http.Request.HttpRequestBuilder)
.call {
renderHttpSerialize(ctx, op, writer)
}
.write("return builder")
.closeBlock("}")
}
.closeBlock("}")
// FIXME: this works only for Cbor protocol now
if (ctx.settings.build.generateServiceProject) {
writer
.openBlock("internal class #T {", serializerSymbol)
.call {
writer.openBlock(
"public fun serialize(context: #T, input: #T): ByteArray {",
RuntimeTypes.Core.ExecutionContext,
serializationSymbol,
)
.write("var response: Any")
.call {
renderSerializeHttpBody(ctx, op, writer)
}
.write("return response")
.closeBlock("}")
}
.closeBlock("}")
} else {
writer
.addImport(operationSerializerSymbols)
.write("")
.openBlock("internal class #T: #T.#L<#T> {", serializerSymbol, RuntimeTypes.HttpClient.Operation.HttpSerializer, serdeMeta.variantName, serializationSymbol)
.call {
val modifier = if (serdeMeta.isStreaming) "suspend " else ""
writer.openBlock(
"override #Lfun serialize(context: #T, input: #T): #T {",
modifier,
RuntimeTypes.Core.ExecutionContext,
serializationSymbol,
RuntimeTypes.Http.Request.HttpRequestBuilder,
)
.write("val builder = #T()", RuntimeTypes.Http.Request.HttpRequestBuilder)
.call {
renderHttpSerialize(ctx, op, writer)
}
.write("return builder")
.closeBlock("}")
}
.closeBlock("}")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@ class CborSerializerGenerator(
}
val serializationShape = serializationTarget.get().let { ctx.model.expectShape(it) }
val serializationSymbol = ctx.symbolProvider.toSymbol(serializationShape)

return op.bodySerializer(ctx.settings) { writer ->
addNestedDocumentSerializers(ctx, op, writer)
writer.withBlock("private fun #L(context: #T, input: #T): #T {", "}", op.bodySerializerName(), RuntimeTypes.Core.ExecutionContext, serializationSymbol, RuntimeTypes.Http.HttpBody) {
call {
renderSerializeOperationBody(ctx, op, members, writer)
if (ctx.settings.build.generateServiceProject) {
return op.bodySerializer(ctx.settings) { writer ->
addNestedDocumentSerializers(ctx, op, writer)
writer.withBlock("private fun #L(context: #T, input: #T): ByteArray {", "}", op.bodySerializerName(), RuntimeTypes.Core.ExecutionContext, serializationSymbol) {
call {
renderSerializeOperationBody(ctx, op, members, writer)
}
}
}
} else {
return op.bodySerializer(ctx.settings) { writer ->
addNestedDocumentSerializers(ctx, op, writer)
writer.withBlock("private fun #L(context: #T, input: #T): #T {", "}", op.bodySerializerName(), RuntimeTypes.Core.ExecutionContext, serializationSymbol, RuntimeTypes.Http.HttpBody) {
call {
renderSerializeOperationBody(ctx, op, members, writer)
}
}
}
}
Expand All @@ -52,7 +62,11 @@ class CborSerializerGenerator(
val serializationshape = ctx.model.expectShape(serializationTarget.get())
writer.write("val serializer = #T()", RuntimeTypes.Serde.SerdeCbor.CborSerializer)
renderSerializerBody(ctx, serializationshape, documentMembers, writer)
writer.write("return serializer.toHttpBody()")
if (ctx.settings.build.generateServiceProject) {
writer.write("return serializer.toByteArray()")
} else {
writer.write("return serializer.toHttpBody()")
}
}

private fun renderSerializerBody(
Expand Down
Loading
Loading