From 5cf336b0b47d29b99e8cbe0b6fa3f7b77ca543fc Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Wed, 13 Aug 2025 17:21:16 +0200 Subject: [PATCH 1/8] Fixes for atomic deployment --- src/rust/client_gen.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rust/client_gen.rs b/src/rust/client_gen.rs index 236468f..3fd5a82 100644 --- a/src/rust/client_gen.rs +++ b/src/rust/client_gen.rs @@ -17,7 +17,7 @@ use crate::rust::lib_gen::{Module, ModuleDef, ModuleName}; use crate::rust::model_gen::RefCache; use crate::rust::printer::*; use crate::rust::types::{ - ref_or_box_schema_type, ref_or_schema_type, DataType, ModelType, RustPrinter, RustResult, + ref_or_box_schema_type, ref_or_schema_type, DataType, IntFormat, ModelType, RustPrinter, RustResult }; use crate::{Error, Result}; use convert_case::{Case, Casing}; @@ -748,6 +748,7 @@ fn render_path_param(method: &Method, name: &str) -> RustResult { DataType::String => Ok(unit() + ¶m.name), DataType::Uuid => Ok(unit() + "&" + ¶m.name + ".to_string()"), DataType::Model(_) => Ok(unit() + "&" + ¶m.name + ".to_string()"), + DataType::Int(IntFormat::U64) => Ok(unit() + "&" + ¶m.name + ".to_string()"), _ => Err(Error::unexpected(format!( "Unexpected param type {name}: {:?}", param.tpe From e92907d869150dcb2d60dd4449cea17c19a1b3f7 Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Wed, 13 Aug 2025 17:24:36 +0200 Subject: [PATCH 2/8] fmt --- src/rust/client_gen.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rust/client_gen.rs b/src/rust/client_gen.rs index 3fd5a82..4d9bc27 100644 --- a/src/rust/client_gen.rs +++ b/src/rust/client_gen.rs @@ -17,7 +17,8 @@ use crate::rust::lib_gen::{Module, ModuleDef, ModuleName}; use crate::rust::model_gen::RefCache; use crate::rust::printer::*; use crate::rust::types::{ - ref_or_box_schema_type, ref_or_schema_type, DataType, IntFormat, ModelType, RustPrinter, RustResult + ref_or_box_schema_type, ref_or_schema_type, DataType, IntFormat, ModelType, RustPrinter, + RustResult, }; use crate::{Error, Result}; use convert_case::{Case, Casing}; From 531984a6779c2d7ce42726639a4526fe77cc4b7c Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Wed, 13 Aug 2025 19:07:41 +0200 Subject: [PATCH 3/8] remove blanked impl for multipart --- src/rust/model_gen.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/rust/model_gen.rs b/src/rust/model_gen.rs index 05f65cc..8b05a87 100644 --- a/src/rust/model_gen.rs +++ b/src/rust/model_gen.rs @@ -342,20 +342,7 @@ pub fn multipart_field_module() -> Result { + line("fn to_multipart_field(&self) -> String;") + line("fn mime_type(&self) -> &'static str;"), ) - + line(unit() + "}") - + NewLine - + line(unit() + "impl MultipartField for T {") - + indented( - unit() - + line("fn to_multipart_field(&self) -> String {") - + indented(line("self.to_string()")) - + line("}") - + NewLine - + line(unit() + "fn mime_type(&self) -> &'static str {") - + indented(line(r#""text/plain; charset=utf-8""#)) - + line(unit() + "}"), - ) - + line("}"); + + line(unit() + "}"); Ok(Module { def: ModuleDef { From 225e41632ca743843d371534f82b9a87ba32a5dd Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Wed, 13 Aug 2025 19:22:32 +0200 Subject: [PATCH 4/8] update --- src/rust/client_gen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rust/client_gen.rs b/src/rust/client_gen.rs index 4d9bc27..141d047 100644 --- a/src/rust/client_gen.rs +++ b/src/rust/client_gen.rs @@ -749,7 +749,7 @@ fn render_path_param(method: &Method, name: &str) -> RustResult { DataType::String => Ok(unit() + ¶m.name), DataType::Uuid => Ok(unit() + "&" + ¶m.name + ".to_string()"), DataType::Model(_) => Ok(unit() + "&" + ¶m.name + ".to_string()"), - DataType::Int(IntFormat::U64) => Ok(unit() + "&" + ¶m.name + ".to_string()"), + DataType::Int(_) => Ok(unit() + "&" + ¶m.name + ".to_string()"), _ => Err(Error::unexpected(format!( "Unexpected param type {name}: {:?}", param.tpe From e6d55a72cb59bf0fba05fb98a6af2deae655a228 Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Thu, 14 Aug 2025 12:58:05 +0200 Subject: [PATCH 5/8] fix --- src/printer.rs | 14 -------------- src/rust/client_gen.rs | 3 +-- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/printer.rs b/src/printer.rs index 043eabc..311a826 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -75,12 +75,6 @@ impl Printer for String { } } -pub struct UnitPrinter; - -impl Printer for UnitPrinter { - fn print(&self, _ctx: &mut Context) {} -} - pub struct IndentPrinter; impl Printer for IndentPrinter { @@ -136,14 +130,6 @@ impl TreePrinter { } } -pub struct TreePrinterPrinter(TreePrinter); - -impl Printer for TreePrinterPrinter { - fn print(&self, ctx: &mut Context) { - self.0.print(ctx) - } -} - impl Add> for TreePrinter where TreePrinter: Add>, diff --git a/src/rust/client_gen.rs b/src/rust/client_gen.rs index 141d047..e4b039c 100644 --- a/src/rust/client_gen.rs +++ b/src/rust/client_gen.rs @@ -17,8 +17,7 @@ use crate::rust::lib_gen::{Module, ModuleDef, ModuleName}; use crate::rust::model_gen::RefCache; use crate::rust::printer::*; use crate::rust::types::{ - ref_or_box_schema_type, ref_or_schema_type, DataType, IntFormat, ModelType, RustPrinter, - RustResult, + ref_or_box_schema_type, ref_or_schema_type, DataType, ModelType, RustPrinter, RustResult, }; use crate::{Error, Result}; use convert_case::{Case, Casing}; From 64018ca64c798839b6018c6bf4923c0277301826 Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Tue, 26 Aug 2025 21:31:29 +0200 Subject: [PATCH 6/8] support generating nocontent --- src/rust/client_gen.rs | 14 +++++++++----- src/rust/types.rs | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/rust/client_gen.rs b/src/rust/client_gen.rs index e4b039c..bb9baa6 100644 --- a/src/rust/client_gen.rs +++ b/src/rust/client_gen.rs @@ -493,11 +493,10 @@ fn response_type(response: &ReferenceOr, ref_cache: &mut RefCache) -> "Reference in response top level: {reference}" ))), ReferenceOr::Item(resp) => { - if resp.content.len() != 1 { - Err(Error::unimplemented( - "Response content with not exactly 1 option.", - )) - } else { + if resp.content.len() == 0 { + // No content case + Ok(DataType::Unit) + } else if resp.content.len() == 1 { let (content_type, media_type) = resp.content.first().unwrap(); if content_type.starts_with("application/json") { @@ -520,6 +519,10 @@ fn response_type(response: &ReferenceOr, ref_cache: &mut RefCache) -> "Response content type: {content_type}" ))) } + } else { + Err(Error::unimplemented( + "Response content with not exactly 1 option.", + )) } } } @@ -883,6 +886,7 @@ fn status_match(range_results: bool, code: &StatusCode) -> RustPrinter { fn response_body_parsing(data_type: &DataType) -> RustPrinter { match data_type { DataType::Binary => unit() + "response.bytes().await?", + DataType::Unit => unit() + "()", _ => unit() + "response.json::<" + data_type.render_declaration(false) + ">().await?", } } diff --git a/src/rust/types.rs b/src/rust/types.rs index d0d0c8a..53a506f 100644 --- a/src/rust/types.rs +++ b/src/rust/types.rs @@ -74,6 +74,7 @@ pub enum DataType { MapOf(Box), Json, Yaml, + Unit, } pub fn escape_keywords(name: &str) -> String { @@ -95,6 +96,7 @@ impl DataType { } match self { + DataType::Unit => unit() + "()", DataType::String => { if top_param { unit() + "&str" From 8532419c4e0498149a6422a7c1aa1af5c636319c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Istv=C3=A1n=20B=C3=ADr=C3=B3?= Date: Fri, 28 Nov 2025 13:12:32 +0100 Subject: [PATCH 7/8] add derive Clone for Error --- src/rust/error_gen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rust/error_gen.rs b/src/rust/error_gen.rs index 54fde76..0394fce 100644 --- a/src/rust/error_gen.rs +++ b/src/rust/error_gen.rs @@ -19,7 +19,7 @@ pub fn error_gen() -> Module { let code = indoc! { r#" use bytes::Bytes; - #[derive(Debug, thiserror::Error)] + #[derive(Debug, Clone, thiserror::Error)] pub enum Error { #[error("{0}")] Item(T), From 0ef70eadc1fc99e009d8cb1ab1e612da5748ffa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Istv=C3=A1n=20B=C3=ADr=C3=B3?= Date: Fri, 28 Nov 2025 13:18:55 +0100 Subject: [PATCH 8/8] Revert "add derive Clone for Error" This reverts commit 8532419c4e0498149a6422a7c1aa1af5c636319c. --- src/rust/error_gen.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rust/error_gen.rs b/src/rust/error_gen.rs index 0394fce..54fde76 100644 --- a/src/rust/error_gen.rs +++ b/src/rust/error_gen.rs @@ -19,7 +19,7 @@ pub fn error_gen() -> Module { let code = indoc! { r#" use bytes::Bytes; - #[derive(Debug, Clone, thiserror::Error)] + #[derive(Debug, thiserror::Error)] pub enum Error { #[error("{0}")] Item(T),