Skip to content

Commit a264582

Browse files
committed
Refine integer parameter inference logic
Removes 'id' and related patterns from integer parameter detection in infer_path_param_schema, treating them as string by default. Updates tests to reflect this change, ensuring 'id', 'user_id', 'userId', and 'postId' are now tested as string parameters.
1 parent a4b1a7b commit a264582

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

crates/rustapi-core/src/app.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,10 +1176,8 @@ fn infer_path_param_schema(name: &str) -> rustapi_openapi::SchemaRef {
11761176
}
11771177

11781178
// Integer patterns
1179-
let is_integer = lower == "id"
1180-
|| lower.ends_with("_id")
1181-
|| (lower.ends_with("id") && lower.len() > 2) // e.g., "userId", but not "uuid"
1182-
|| lower == "page"
1179+
// Integer patterns
1180+
let is_integer = lower == "page"
11831181
|| lower == "limit"
11841182
|| lower == "offset"
11851183
|| lower == "count"
@@ -1276,10 +1274,6 @@ mod tests {
12761274

12771275
// Test common integer patterns
12781276
let int_params = [
1279-
"id",
1280-
"user_id",
1281-
"userId",
1282-
"postId",
12831277
"page",
12841278
"limit",
12851279
"offset",
@@ -1342,7 +1336,9 @@ mod tests {
13421336
use super::infer_path_param_schema;
13431337

13441338
// Test string (default) patterns
1345-
let string_params = ["name", "slug", "code", "token", "username"];
1339+
let string_params = [
1340+
"name", "slug", "code", "token", "username", "id", "user_id", "userId", "postId",
1341+
];
13461342

13471343
for name in string_params {
13481344
let schema = infer_path_param_schema(name);

0 commit comments

Comments
 (0)