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

Pascal case operation names #1827

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use smithy.test#httpRequestTests
use smithy.test#httpResponseTests
use aws.protocols#awsJson1_1
use aws.api#service
use smithy.framework#ValidationException

/// Confounds model generation machinery with lots of problematic names
@awsJson1_1
Expand Down Expand Up @@ -41,17 +42,20 @@ service Config {
}
])
operation ReservedWordsAsMembers {
input: ReservedWords
input: ReservedWords,
errors: [ValidationException],
}

// tests that module names are properly escaped
operation Match {
input: ReservedWords
errors: [ValidationException],
}

// Should generate a PascalCased `RpcEchoInput` struct.
operation RPCEcho {
input: ReservedWords
errors: [ValidationException],
}

structure ReservedWords {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,10 @@ open class SymbolVisitor(
TODO("Not yet implemented: https://github.com/awslabs/smithy-rs/issues/312")
}

override fun operationShape(shape: OperationShape): Symbol {
return symbolBuilder(
RustType.Opaque(
shape.contextName(serviceShape)
.replaceFirstChar { it.uppercase() },
),
)
override fun operationShape(shape: OperationShape) =
symbolBuilder(RustType.Opaque(shape.contextName(serviceShape).toPascalCase()))
.locatedIn(Operations)
.build()
}

override fun resourceShape(shape: ResourceShape?): Symbol {
TODO("Not yet implemented: resources are not supported")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ class HttpBindingGenerator(
/**
* Generate a unique name for the deserializer function for a given [operationShape] and HTTP binding.
*/
// Rename here technically not required, operations and members cannot be renamed.
private fun fnName(operationShape: OperationShape, binding: HttpBindingDescriptor) =
"${operationShape.id.getName(service).toSnakeCase()}_${binding.member.container.name.toSnakeCase()}_${binding.memberName.toSnakeCase()}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import kotlin.streams.toList
*/
object OperationNormalizer {
// Functions to construct synthetic shape IDs—Don't rely on these in external code.
// Rename safety: Operations cannot be renamed
// In order to ensure that the fully qualified smithy id of a synthetic shape can never conflict with an existing shape,
// the `synthetic` namespace is appended.
private fun OperationShape.syntheticInputId() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ServerOperationGenerator(
private val symbolProvider = codegenContext.symbolProvider
private val model = codegenContext.model

private val operationName = symbolProvider.toSymbol(operation).name.toPascalCase()
private val operationName = symbolProvider.toSymbol(operation).name
private val operationId = operation.id

/** Returns `std::convert::Infallible` if the model provides no errors. */
Expand Down