Skip to content

Commit 275001e

Browse files
Fix inline type naming: set current_schema_name in add_inline_schema
Inline schemas processed via add_inline_schema were not updating current_schema_name before calling analyze_schema_value. This caused all nested inline property types (enums, unions, objects) to inherit the stale current_schema_name from whatever named schema was last processed, resulting in incorrect type name prefixes (e.g., all inline types getting a "WorktreeResetInput" prefix regardless of their actual parent schema). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0f95063 commit 275001e

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/analysis.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,7 +2353,12 @@ impl SchemaAnalyzer {
23532353
}
23542354

23552355
// For non-primitive types, analyze the inline schema and add it to our collection
2356+
// Set current_schema_name so nested inline properties (enums, unions, objects)
2357+
// get named with the correct parent context instead of inheriting a stale name
2358+
let previous_schema_name = self.current_schema_name.take();
2359+
self.current_schema_name = Some(type_name.to_string());
23562360
let analyzed = self.analyze_schema_value(schema, type_name)?;
2361+
self.current_schema_name = previous_schema_name;
23572362

23582363
// Add to resolved cache so it can be generated
23592364
self.resolved_cache.insert(type_name.to_string(), analyzed);

src/snapshots/openapi_to_rust__test_helpers__mixed_inline_ref_oneof.snap

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ pub enum Response {
2525
#[serde(rename = "redirect")]
2626
Redirect(UrlBlock),
2727
}
28+
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
29+
pub enum UrlBlockType {
30+
#[default]
31+
#[serde(rename = "redirect")]
32+
Redirect,
33+
}
2834
#[derive(Debug, Clone, Deserialize, Serialize)]
2935
pub struct NamedError {
3036
pub code: String,
@@ -41,8 +47,8 @@ pub struct DataBlock {
4147
pub data: serde_json::Value,
4248
}
4349
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, Default)]
44-
pub enum ResponseType {
50+
pub enum DataBlockType {
4551
#[default]
46-
#[serde(rename = "redirect")]
47-
Redirect,
52+
#[serde(rename = "success")]
53+
Success,
4854
}

0 commit comments

Comments
 (0)