Skip to content

Commit b0bd03b

Browse files
committed
Support char
1 parent 5267d6e commit b0bd03b

4 files changed

Lines changed: 73 additions & 3 deletions

File tree

examples/axum-example/openapi.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,11 @@
22082208
"Config": {
22092209
"type": "object",
22102210
"properties": {
2211+
"delimiter": {
2212+
"type": "string",
2213+
"format": "char",
2214+
"nullable": true
2215+
},
22112216
"discountRate": {
22122217
"type": "number",
22132218
"format": "decimal",
@@ -2233,6 +2238,10 @@
22332238
"type": "integer",
22342239
"format": "uint8"
22352240
},
2241+
"separator": {
2242+
"type": "string",
2243+
"format": "char"
2244+
},
22362245
"taxRate": {
22372246
"type": "number",
22382247
"format": "decimal"
@@ -2244,7 +2253,8 @@
22442253
"maxPrice",
22452254
"maxItems",
22462255
"retryCount",
2247-
"priority"
2256+
"priority",
2257+
"separator"
22482258
]
22492259
},
22502260
"ConfigSchema": {
@@ -3591,6 +3601,11 @@
35913601
"UpdateConfigRequest": {
35923602
"type": "object",
35933603
"properties": {
3604+
"delimiter": {
3605+
"type": "string",
3606+
"format": "char",
3607+
"nullable": true
3608+
},
35943609
"discountRate": {
35953610
"type": "number",
35963611
"format": "decimal",
@@ -3621,6 +3636,11 @@
36213636
"format": "uint8",
36223637
"nullable": true
36233638
},
3639+
"separator": {
3640+
"type": "string",
3641+
"format": "char",
3642+
"nullable": true
3643+
},
36243644
"taxRate": {
36253645
"type": "number",
36263646
"format": "decimal",

examples/axum-example/src/routes/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub struct Config {
1313
pub max_items: usize,
1414
pub retry_count: u8,
1515
pub priority: i32,
16+
pub separator: char,
17+
pub delimiter: Option<char>,
1618
}
1719

1820
#[derive(Deserialize, Schema)]
@@ -25,6 +27,8 @@ pub struct UpdateConfigRequest {
2527
pub max_items: Option<usize>,
2628
pub retry_count: Option<u8>,
2729
pub priority: Option<i32>,
30+
pub separator: Option<char>,
31+
pub delimiter: Option<char>,
2832
}
2933

3034
/// Get current config
@@ -38,6 +42,8 @@ pub async fn get_config() -> Json<Config> {
3842
max_items: 100,
3943
retry_count: 3,
4044
priority: 0,
45+
separator: ',',
46+
delimiter: Some('|'),
4147
})
4248
}
4349

@@ -56,6 +62,8 @@ pub async fn update_config(Json(req): Json<UpdateConfigRequest>) -> Json<Config>
5662
max_items: 100,
5763
retry_count: 3,
5864
priority: 0,
65+
separator: ',',
66+
delimiter: Some('|'),
5967
};
6068

6169
Json(Config {
@@ -66,5 +74,7 @@ pub async fn update_config(Json(req): Json<UpdateConfigRequest>) -> Json<Config>
6674
max_items: req.max_items.unwrap_or(current.max_items),
6775
retry_count: req.retry_count.unwrap_or(current.retry_count),
6876
priority: req.priority.unwrap_or(current.priority),
77+
separator: req.separator.unwrap_or(current.separator),
78+
delimiter: req.delimiter.or(current.delimiter),
6979
})
7080
}

examples/axum-example/tests/snapshots/integration_test__openapi.snap

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,11 @@ expression: "std::fs::read_to_string(\"openapi.json\").unwrap()"
22122212
"Config": {
22132213
"type": "object",
22142214
"properties": {
2215+
"delimiter": {
2216+
"type": "string",
2217+
"format": "char",
2218+
"nullable": true
2219+
},
22152220
"discountRate": {
22162221
"type": "number",
22172222
"format": "decimal",
@@ -2237,6 +2242,10 @@ expression: "std::fs::read_to_string(\"openapi.json\").unwrap()"
22372242
"type": "integer",
22382243
"format": "uint8"
22392244
},
2245+
"separator": {
2246+
"type": "string",
2247+
"format": "char"
2248+
},
22402249
"taxRate": {
22412250
"type": "number",
22422251
"format": "decimal"
@@ -2248,7 +2257,8 @@ expression: "std::fs::read_to_string(\"openapi.json\").unwrap()"
22482257
"maxPrice",
22492258
"maxItems",
22502259
"retryCount",
2251-
"priority"
2260+
"priority",
2261+
"separator"
22522262
]
22532263
},
22542264
"ConfigSchema": {
@@ -3595,6 +3605,11 @@ expression: "std::fs::read_to_string(\"openapi.json\").unwrap()"
35953605
"UpdateConfigRequest": {
35963606
"type": "object",
35973607
"properties": {
3608+
"delimiter": {
3609+
"type": "string",
3610+
"format": "char",
3611+
"nullable": true
3612+
},
35983613
"discountRate": {
35993614
"type": "number",
36003615
"format": "decimal",
@@ -3625,6 +3640,11 @@ expression: "std::fs::read_to_string(\"openapi.json\").unwrap()"
36253640
"format": "uint8",
36263641
"nullable": true
36273642
},
3643+
"separator": {
3644+
"type": "string",
3645+
"format": "char",
3646+
"nullable": true
3647+
},
36283648
"taxRate": {
36293649
"type": "number",
36303650
"format": "decimal",

openapi.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,11 @@
22082208
"Config": {
22092209
"type": "object",
22102210
"properties": {
2211+
"delimiter": {
2212+
"type": "string",
2213+
"format": "char",
2214+
"nullable": true
2215+
},
22112216
"discountRate": {
22122217
"type": "number",
22132218
"format": "decimal",
@@ -2233,6 +2238,10 @@
22332238
"type": "integer",
22342239
"format": "uint8"
22352240
},
2241+
"separator": {
2242+
"type": "string",
2243+
"format": "char"
2244+
},
22362245
"taxRate": {
22372246
"type": "number",
22382247
"format": "decimal"
@@ -2244,7 +2253,8 @@
22442253
"maxPrice",
22452254
"maxItems",
22462255
"retryCount",
2247-
"priority"
2256+
"priority",
2257+
"separator"
22482258
]
22492259
},
22502260
"ConfigSchema": {
@@ -3591,6 +3601,11 @@
35913601
"UpdateConfigRequest": {
35923602
"type": "object",
35933603
"properties": {
3604+
"delimiter": {
3605+
"type": "string",
3606+
"format": "char",
3607+
"nullable": true
3608+
},
35943609
"discountRate": {
35953610
"type": "number",
35963611
"format": "decimal",
@@ -3621,6 +3636,11 @@
36213636
"format": "uint8",
36223637
"nullable": true
36233638
},
3639+
"separator": {
3640+
"type": "string",
3641+
"format": "char",
3642+
"nullable": true
3643+
},
36243644
"taxRate": {
36253645
"type": "number",
36263646
"format": "decimal",

0 commit comments

Comments
 (0)