How to define enum mapping in OpenAPI?

OpenAPI 3.1 OpenAPI 3.1 uses the latest JSON Schema, and the recommended way to annotate individual enum values in JSON Schema is to use oneOf+const instead of enum. This way you can specify both custom names (title) and descriptions for enum values. Severity: type: integer oneOf: – title: HIGH const: 2 description: An urgent problem … Read more

Can traits be used on enum types?

Can traits be used on enum types? Yes. In fact, you already have multiple traits defined for your enum; the traits Debug, Copy and Clone: #[derive(Debug, Copy, Clone)] pub enum SceneType The problem is that you aren’t attempting to implement Playable for your enum, you are trying to implement it for one of the enum’s … Read more

Can I extend an enum with additional values?

An enum can’t be directly extended, but you use the same composition trick one would use with structs (that is, with a struct, one would have a field storing an instance of the ‘parent’). enum Base { Alpha, Beta(usize), } enum Extended { Base(Base), Gamma } If you wish to handle each case individually, this … Read more

tech