Skip to content

Comments

serde2: generate schemas#623

Merged
lucix-aws merged 1 commit intofeat-serde2from
feat-serde2-schema
Feb 11, 2026
Merged

serde2: generate schemas#623
lucix-aws merged 1 commit intofeat-serde2from
feat-serde2-schema

Conversation

@lucix-aws
Copy link
Contributor

@lucix-aws lucix-aws commented Jan 30, 2026

part of #458

Schemas are trimmed-down descriptions of shapes in the model. Schemas are used in the new (NYI) (de)serialization in place of model-ignorant/static generated code.

Right now generation of these is gated behind a new "useExperimentalSerde" setting so there are no downstream codegen changes (and that aside we're merging this to a feature branch).

The serde itself has already been largely bootstrapped, I yanked it out of this so we could review schemas on their own but FYI there might be random import changes / utility APIs seemingly there for no reason that I missed, they were likely added for serde.

Their may be slight API changes to schemas as part of serde but the general layout of schemas and traits, as well as all the codegen for them, should be 99% stable.

gist with generated example schema for sqs: https://gist.github.com/lucix-aws/2e85bd115e51aca977a2a79eb04ba428

preview of what generated serializers look like with schemas: https://gist.github.com/lucix-aws/2a17ad38f46f0b1f9b2f4c8252a89687

@lucix-aws lucix-aws requested review from a team as code owners January 30, 2026 20:43
@lucix-aws lucix-aws changed the base branch from main to feat-serde2 January 30, 2026 20:43
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* WARNING 1/29/26: AVOID any new usages of these.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i don't remember why i wrote this


// Other traits
GENERATORS.put(ContextParamTrait.ID, new SimpleTraitGenerator<>(SMITHY_TRAITS.struct("ContextParam")));
GENERATORS.put(AwsQueryErrorTrait.ID, new SimpleTraitGenerator<>(SMITHY_TRAITS.struct("AWSQueryError"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we

  1. do it like this
  2. put aws traits in their own module?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer only pass 1 string-func key value pair to the generator's constructor (unless some trait like error/status code must be bounded together), or maybe we can pass key value separately as list in order.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure i follow

Copy link
Contributor

@wty-Bryant wty-Bryant Feb 2, 2026

Choose a reason for hiding this comment

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

i mean now we have SimpleTraitGenerator(symbol, k1, v1) and SimpleTraitGenerator(symbol, k1, v1, k2, v2), which might be merged to a single constructor like SimpleTraitGenerator(symbol, List<k>, List<v>)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not really a fan of that personally, I think the ergonomics of k/v are way better. It matches how the constructors of Map.of are defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Java should really just have actual map literals but unfortunately it doesn't.

import software.amazon.smithy.model.shapes.ShapeType;

public class UnsupportedShapeException extends CodegenException {
public UnsupportedShapeException(ShapeType type) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

part of the serde that got left behind

m := &Schema{
id: ShapeID{Member: name},
typ: target.typ,
members: target.members,
Copy link
Contributor

@wty-Bryant wty-Bryant Feb 1, 2026

Choose a reason for hiding this comment

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

out of curious: is there a reason you not clone the members like you do for traits?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so for members, we don't want to be cloning them because that would mean every member shape clones all of its members down its shape tree recursively. the member lists don't get modified so it's also just not necessary.

for traits we have to clone them because we combine member and target traits here (we don't want to disturb the original target trait map)

@lucix-aws lucix-aws merged commit 1452f9a into feat-serde2 Feb 11, 2026
15 checks passed
@lucix-aws lucix-aws deleted the feat-serde2-schema branch February 11, 2026 19: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.

2 participants