Closed cbzehner closed 3 weeks ago
Related to #275 I assume. Would love to know how to fix this but have no idea where to start. Any ideas?
Seems like this struct in particular is quite difficult according to #72 - however it looks like the it's being properly generated now as an enum. Unfortunately, tag is still being incorrectly generated as "nodetype" instead of "node_type" which the spec states. Is this an issue with OpenAPI's generator? I was browsing over there and came accross this PR https://github.com/OpenAPITools/openapi-generator/pull/16205 but unfortunately am not too familiar with the generator to understand if this is truly related or not.
Edit: Nevermind it looks related to this issue: https://github.com/OpenAPITools/openapi-generator/issues/14745 which apparently fixes this - but the issue still persists. Do we need to regenerate the rust client code or something here?
This problem is fixed with the latest openapi-generator.
As example generated with latest version:
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct UiNodeTextAttributes {
/// A unique identifier
#[serde(rename = "id")]
pub id: String,
/// NodeType represents this node's types. It is a mirror of `node.type` and is primarily used to allow compatibility with OpenAPI 3.0. In this struct it technically always is \"text\".
#[serde(rename = "node_type")]
pub node_type: String,
#[serde(rename = "text")]
pub text: Box<crate::models::UiText>,
}
impl UiNodeTextAttributes {
pub fn new(id: String, node_type: String, text: crate::models::UiText) -> UiNodeTextAttributes {
UiNodeTextAttributes {
id,
node_type,
text: Box::new(text),
}
}
}
The problem is that we cannot switch to the openapi-generator provided templates, because this issue is still open: https://github.com/OpenAPITools/openapi-generator/issues/13257
This should be resolved with the new versions of the SDK!
Preflight checklist
Describe the bug
When generating the Rust SDK, the value nodeType serializes to
nodetype
(incorrect) rather thannode_type
(correct).This leads to the following error when attempting to use the SDK to deserialize UINodes into Rust structs:
reqwest::Error { kind: Decode, source: Error("missing field
nodetype", line: 1, column: 585) }
Changing this line locally to use the correct casing fixes the issue
This affects at least SDK versions corresponding to 0.11 & 0.13 - I haven't checked back further than that.
Reproducing the bug
Create a new rust project with
cargo new --bin test-node-type-issue
ory-kratos-client
,serde
&serde_json
as dependenciesmain.rs
filecargo test
to run the test and reproduce the issueRelevant log output
No response
Relevant configuration
No response
Version
v0.11.1 & v0.13
On which operating system are you observing this issue?
macOS
In which environment are you deploying?
Binary
Additional Context
No response