Version or commit
0.6.0
Affected area
Generated models
Minimal OpenAPI fragment
{
"openapi": "3.1.0",
"info": { "title": "repro", "version": "1.0.0" },
"paths": {
"/profile": {
"get": {
"operationId": "getProfile",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"languages": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string",
"enum": ["EN", "ES"]
}
},
{ "type": "null" }
]
}
}
}
}
}
}
}
}
}
}
}
Configuration and command
[generator]
spec_path = "repro.json"
output_dir = "src/generated"
module_name = "api"
[features]
enable_async_client = true
`openapi-to-rust generate`
Actual behavior
In types.rs, languages are String types:
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetProfileResponse {
#[serde(skip_serializing_if = "Option::is_none")]
pub languages: Option<Vec<String>>,
}
Expected behavior
languages are enum type:
#[derive(...)]
pub enum Whatever {
#[serde(rename = "EN")] En,
#[serde(rename = "ES")] Es,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GetProfileResponse {
#[serde(skip_serializing_if = "Option::is_none")]
pub languages: Option<Vec<Whatever>>,
}
Environment
cargo install --locked
Checks
Version or commit
0.6.0
Affected area
Generated models
Minimal OpenAPI fragment
Configuration and command
Actual behavior
In
types.rs, languages areStringtypes:Expected behavior
languages are enum type:
Environment
cargo install --locked
Checks