Skip to content

Optimize encoding of Newtypes in Schema serialization #2584

Description

@xsistens

The following feature request is written from a rust perspective but might also be valid for other languages.

Currently the following struct in rust, which is being used as a newtype, is being exposed as an object instead of the simplified encoding of simply the wrapped typed.

#[derive(Shrinkwrap, Schema, Debug, Clone, Copy)]
pub struct LobbyId(pub Uuid);

When this struct is being used as input or output of agents it results in the following json:

...
"id": {
        "value": "dd00721b-3329-4621-a01d-c71f02cd78c6"
        }
...

Instead the following encoding which should have all information to read and write the newtype is easier to read and also provide as input:

...
"id": "dd00721b-3329-4621-a01d-c71f02cd78c6"
...

It would be nice to have an option, so that wrapper structs simply wrapping one value (or annotated with a derive macro) would be serialized as described above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions