Bug Report Checklist
Description
The rust-axum generator renders integer enums with string-based #[serde(rename = "0")] attributes instead of integer representations. This causes deserialization to fail when clients send spec-correct integer values (e.g., lib_type: 1 instead of "1").
OpenAPI declaration
LibType:
type: integer
description: TSS library/protocol type
enum: [0, 1, 2]
x-enum-varnames: [GG20, DKLS, KeyImport]
Expected generated code
An enum that serializes/deserializes as integers, e.g. using serde_repr:
#[repr(i32)]
#[derive(serde_repr::Serialize_repr, serde_repr::Deserialize_repr)]
pub enum LibType {
GG20 = 0,
DKLS = 1,
KeyImport = 2,
}
Actual generated code
#[derive(serde::Serialize, serde::Deserialize)]
pub enum LibType {
#[serde(rename = "0")]
GG20,
#[serde(rename = "1")]
DKLS,
#[serde(rename = "2")]
KeyImport,
}
LibType::DKLS serializes as "1" (JSON string) instead of 1 (JSON number). Deserializing {"lib_type": 1} fails with a type mismatch error.
Generation details
- Generator:
rust-axum
- Version: 7.20.0 (also reproducible on 7.21.0)
- Command:
npx @openapitools/openapi-generator-cli generate -i spec.yaml -g rust-axum -o output/
Workaround
Post-generation script that regex-replaces the generated enum blocks with serde_repr-based versions. Fragile but functional.
Bug Report Checklist
Description
The
rust-axumgenerator renders integer enums with string-based#[serde(rename = "0")]attributes instead of integer representations. This causes deserialization to fail when clients send spec-correct integer values (e.g.,lib_type: 1instead of"1").OpenAPI declaration
Expected generated code
An enum that serializes/deserializes as integers, e.g. using
serde_repr:Actual generated code
LibType::DKLSserializes as"1"(JSON string) instead of1(JSON number). Deserializing{"lib_type": 1}fails with a type mismatch error.Generation details
rust-axumnpx @openapitools/openapi-generator-cli generate -i spec.yaml -g rust-axum -o output/Workaround
Post-generation script that regex-replaces the generated enum blocks with
serde_repr-based versions. Fragile but functional.