Ask
Add a CBOR codec to smithy-python, mirroring the existing JSON codec (JSONCodec in smithy-json) and wire-compatible with smithy-java's Rpcv2CborCodec. The JSON half already exists in both languages; this is the missing CBOR half on the Python side, so shapes generated from one Smithy model can be serde'd in both Java and Python and stay wire-compatible.
Use case: one Smithy model, codegen'd into Java and Python (SageMaker endpoint invocation)
SageMaker endpoint invocation crosses a language boundary: the model server is Python, and the clients calling it are Java and Python. The goal is to model the request/response shapes once in Smithy, codegen typed classes into both languages, and serde them with matching codecs — CBOR on the wire (compact, binary, schema-driven), JSON when readability matters. The requirement is wire compatibility: bytes written by the Java codec have to deserialize with the Python codec, and vice versa.
A generated shape round-trips through CBOR or JSON by swapping the codec — serde is schema-driven, nothing hand-written:
import software.amazon.smithy.java.cbor.Rpcv2CborCodec;
import software.amazon.smithy.java.json.JsonCodec;
import software.amazon.smithy.java.core.serde.Codec;
import java.nio.ByteBuffer;
// `request` is a code-generated smithy-java shape (a SerializableShape).
// --- CBOR (RPC v2 CBOR) ---
Codec cbor = Rpcv2CborCodec.builder().build();
ByteBuffer encoded = cbor.serialize(request);
MyShape decoded = cbor.deserializeShape(encoded, MyShape.builder());
// --- JSON (same shapes, same API) ---
Codec json = JsonCodec.builder().build();
ByteBuffer encodedJson = json.serialize(request);
MyShape decodedJson = json.deserializeShape(encodedJson, MyShape.builder());
Python today (smithy-python): JSON only
JSONCodec implements the format-agnostic Codec protocol from smithy_core.codecs:
from smithy_json import JSONCodec
codec = JSONCodec()
encoded: bytes = codec.serialize(request) # `request` is a code-generated shape
decoded = codec.deserialize(encoded, MyShape)
Python already has the generic Codec protocol (smithy-core) and concrete JSON (smithy-json) and XML (smithy-xml) codecs — but no CBOR codec (no smithy-cbor package).
Ask
Add a CBOR codec to smithy-python, mirroring the existing JSON codec (
JSONCodecinsmithy-json) and wire-compatible with smithy-java'sRpcv2CborCodec. The JSON half already exists in both languages; this is the missing CBOR half on the Python side, so shapes generated from one Smithy model can be serde'd in both Java and Python and stay wire-compatible.Use case: one Smithy model, codegen'd into Java and Python (SageMaker endpoint invocation)
SageMaker endpoint invocation crosses a language boundary: the model server is Python, and the clients calling it are Java and Python. The goal is to model the request/response shapes once in Smithy, codegen typed classes into both languages, and serde them with matching codecs — CBOR on the wire (compact, binary, schema-driven), JSON when readability matters. The requirement is wire compatibility: bytes written by the Java codec have to deserialize with the Python codec, and vice versa.
Java today: smithy-java
A generated shape round-trips through CBOR or JSON by swapping the codec — serde is schema-driven, nothing hand-written:
Python today (smithy-python): JSON only
JSONCodecimplements the format-agnosticCodecprotocol fromsmithy_core.codecs:Python already has the generic
Codecprotocol (smithy-core) and concrete JSON (smithy-json) and XML (smithy-xml) codecs — but no CBOR codec (nosmithy-cborpackage).