Got a little nit in the type generation.
When I have a type in the OpenAPI schema that uses "const" like this:
"ConstModifier": {
"type": "object",
"properties": {
"someConstant": {
"type": "string",
"const": "TheOnlyValidValue"
},
},
}
I get the following rust code:
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ConstModifier {
#[serde(rename = "someConstant", skip_serializing_if = "Option::is_none")]
pub some_constant: Option<String>,
}
The good news is that this works, in that I can call my API this way, but I'd expect it to be more tightly constrained. Rust doesn't have literal values the way Python or TS does and I'm not sure how other Rust libraries handle this... I imagine the better thing would be to emit an enum with only one option, so I'd end up constructing it something like:
let myModifier = ConstModifier {
some_constant: Some(ConstModifierSomeConstantType::TheOnlyValidValue),
};
It certainly makes sense in our case (where the constant is a placeholder for expanding into an enum).
Got a little nit in the type generation.
When I have a type in the OpenAPI schema that uses
"const"like this:I get the following rust code:
The good news is that this works, in that I can call my API this way, but I'd expect it to be more tightly constrained. Rust doesn't have literal values the way Python or TS does and I'm not sure how other Rust libraries handle this... I imagine the better thing would be to emit an enum with only one option, so I'd end up constructing it something like:
It certainly makes sense in our case (where the constant is a placeholder for expanding into an enum).