Skip to content

Commit 7072009

Browse files
[Rust-Axum] Support quotes in string literals (#20176)
* Allow quotes in string literals * Update samples
1 parent 19e2141 commit 7072009

File tree

3 files changed

+6
-6
lines changed
  • modules/openapi-generator/src/main/java/org/openapitools/codegen/languages
  • samples/server/petstore/rust-axum/output

3 files changed

+6
-6
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ public String toDefaultValue(final Schema p) {
809809
}
810810
} else if (ModelUtils.isStringSchema(p)) {
811811
if (p.getDefault() != null) {
812-
defaultValue = "\"" + p.getDefault() + "\".to_string()";
812+
defaultValue = "r#\"" + p.getDefault() + "\"#.to_string()";
813813
}
814814
}
815815

samples/server/petstore/rust-axum/output/openapi-v3/src/models.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ impl NullableTest {
18271827
NullableTest {
18281828
nullable,
18291829
nullable_with_null_default: None,
1830-
nullable_with_present_default: Some(Nullable::Present("default".to_string())),
1830+
nullable_with_present_default: Some(Nullable::Present(r#"default"#.to_string())),
18311831
nullable_with_no_default: None,
18321832
nullable_array: None,
18331833
min_item_test: None,

samples/server/petstore/rust-axum/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl Animal {
309309
pub fn new(class_name: String) -> Animal {
310310
Animal {
311311
class_name,
312-
color: Some("red".to_string()),
312+
color: Some(r#"red"#.to_string()),
313313
}
314314
}
315315
}
@@ -1460,7 +1460,7 @@ impl Cat {
14601460
pub fn new(class_name: String) -> Cat {
14611461
Cat {
14621462
class_name,
1463-
color: Some("red".to_string()),
1463+
color: Some(r#"red"#.to_string()),
14641464
declawed: None,
14651465
}
14661466
}
@@ -2041,7 +2041,7 @@ impl Dog {
20412041
pub fn new(class_name: String) -> Dog {
20422042
Dog {
20432043
class_name,
2044-
color: Some("red".to_string()),
2044+
color: Some(r#"red"#.to_string()),
20452045
breed: None,
20462046
}
20472047
}
@@ -5858,7 +5858,7 @@ impl TestEnumParametersRequest {
58585858
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
58595859
pub fn new() -> TestEnumParametersRequest {
58605860
TestEnumParametersRequest {
5861-
enum_form_string: Some("-efg".to_string()),
5861+
enum_form_string: Some(r#"-efg"#.to_string()),
58625862
}
58635863
}
58645864
}

0 commit comments

Comments
 (0)