schemars/docs/examples/8-enum_repr.md
Graham Esau 61d64df57d v0.8.2
2021-03-27 00:04:07 +00:00

648 B

layout title parent nav_order summary
default Serialize Enum as Number (serde_repr) Examples 8 Generating a schema for with a C-like enum compatible with serde_repr.

Serialize Enum as Number (serde_repr Compatibility)

If you use the #[repr(...)] attribute on an enum to give it a C-like representation, then you may also want to use the serde_repr crate to serialize the enum values as numbers. In this case, you should use the corresponding JsonSchema_repr derive to ensure the schema for your type reflects how serde formats your type.

{% include example.md name="enum_repr" %}