Skip to content

Implement namespace support for generated Unison client code#12

Merged
f34nk merged 14 commits intomainfrom
refactor/namespace
Dec 16, 2025
Merged

Implement namespace support for generated Unison client code#12
f34nk merged 14 commits intomainfrom
refactor/namespace

Conversation

@f34nk
Copy link
Copy Markdown
Owner

@f34nk f34nk commented Dec 16, 2025

This PR does:

  • Add getClientNamespace() method to UnisonSettings that derives namespace from config (e.g., "aws.s3" -> "Aws.S3")
  • Add toNamespacedTypeName() and toNamespacedFunctionName() methods to UnisonSymbolProvider
  • Update all generators (RestXmlProtocolGenerator, EnumGenerator, StructureGenerator, UnionGenerator, PaginationGenerator) to use namespaced names
  • Fix record constructor calls to use base type names due to Unison namespace resolution quirks
  • Fix enum converter function naming for namespaced types (e.g., Aws.S3.requestPayerToText)

This can be verified by doing:

  • Run ./gradlew test to verify all tests pass
  • Generate S3 client with smithy build in examples/aws-demo
  • Verify generated code uses namespaced types like Aws.S3.Config, Aws.S3.createBucket
  • Load generated code in UCM to verify it compiles without namespace resolution errors

f34nk added 14 commits December 16, 2025 22:47
Update generate.py to derive namespace from service and output to generated/ directory.
Add additional Smithy AWS dependencies to aws-demo smithy-build.json.
Add method to convert dot-separated namespace config to PascalCase
Unison namespace prefix (e.g., aws.s3 -> Aws.S3).
Add toNamespacedTypeName() and toNamespacedFunctionName() methods
for generating fully qualified Unison names with namespace prefix.
Apply namespace prefix to Config, Credentials, error types, XML parsers,
operation stubs, and field extraction in generated client code.
Apply namespace prefix to operations, types, enum functions, XML parsers,
and error types in generated REST-XML protocol code.
Update stub implementation to use namespaced function names
for future REST-JSON protocol support.
Update stub implementation to use namespaced function names
for future AWS JSON 1.0/1.1 protocol support.
Apply namespace prefix to enum types and converter functions.
Types use Aws.S3.EnumName format, functions use Aws.S3.enumNameToText format.
Apply namespace prefix to structure types (including errors), union types,
and their field references. All complex types now use Aws.S3.TypeName format.
…helpers

Update ClientModuleWriter to pass clientNamespace when creating PaginationGenerator.
This ensures pagination helper functions use namespaced types like Aws.S3.Config
instead of unqualified Config references.
Update toLowerCamelCase to only convert the last component of namespaced names.
Aws.S3.RequestPayer now generates Aws.S3.requestPayerToText instead of
aws.S3.RequestPayerToText. Also pass clientNamespace to PaginationGenerator.
Fix Unison namespace resolution by using base type names for record
constructor calls instead of fully namespaced names. Unison resolves
constructors differently than type references in the same file context.
@f34nk f34nk merged commit 084e40e into main Dec 16, 2025
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.

1 participant