Skip to content

Commit

Permalink
Fix capture group syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Victoria-Casasampere-BeeTheData committed Feb 6, 2025
1 parent ff8e3cd commit 51f6e61
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
String axumPath = op.path;
for (CodegenParameter param : op.pathParams) {
// Replace {baseName} with {paramName} for format string
String paramSearch = "{" + param.baseName + "}";
String paramReplace = ":" + param.paramName;

axumPath = axumPath.replace(paramSearch, paramReplace);
axumPath = axumPath.replace(param.baseName, param.paramName);
}
pathMethodOpMap
.computeIfAbsent(axumPath, (key) -> new ArrayList<>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
get(get_payment_methods::<I, A, E, C>),
)
.route(
"/v71/paymentMethods/:id",
"/v71/paymentMethods/{id}",
get(get_payment_method_by_id::<I, A, E, C>),
)
.route("/v71/payments", post(post_make_payment::<I, A, E, C>))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ where
.route("/complex-query-param",
get(complex_query_param_get::<I, A, E>)
)
.route("/enum_in_path/:path_param",
.route("/enum_in_path/{path_param}",
get(enum_in_path_path_param_get::<I, A, E>)
)
.route("/form-test",
Expand All @@ -56,7 +56,7 @@ where
.route("/multiget",
get(multiget_get::<I, A, E>)
)
.route("/multiple-path-params-with-very-long-path-to-test-formatting/:path_param_a/:path_param_b",
.route("/multiple-path-params-with-very-long-path-to-test-formatting/{path_param_a}/{path_param_b}",
get(multiple_path_params_with_very_long_path_to_test_formatting_path_param_a_path_param_b_get::<I, A, E>)
)
.route("/multiple_auth_scheme",
Expand All @@ -83,7 +83,7 @@ where
.route("/repos",
post(create_repo::<I, A, E>)
)
.route("/repos/:repo_id",
.route("/repos/{repo_id}",
get(get_repo_info::<I, A, E>).get(get_repo_info::<I, A, E>)
)
.route("/required_octet_stream",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where
put(test_body_with_query_params::<I, A, E, C>),
)
.route(
"/v2/fake/hyphenParam/:hyphen_param",
"/v2/fake/hyphenParam/{hyphen_param}",
get(hyphen_param::<I, A, E, C>),
)
.route(
Expand Down Expand Up @@ -88,33 +88,27 @@ where
post(add_pet::<I, A, E, C>).put(update_pet::<I, A, E, C>),
)
.route(
"/v2/pet/:pet_id",
"/v2/pet/findByStatus",
get(find_pets_by_status::<I, A, E, C>),
)
.route("/v2/pet/findByTags", get(find_pets_by_tags::<I, A, E, C>))
.route(
"/v2/pet/{pet_id}",
delete(delete_pet::<I, A, E, C>)
.get(get_pet_by_id::<I, A, E, C>)
.post(update_pet_with_form::<I, A, E, C>),
)
.route(
"/v2/pet/:pet_id/uploadImage",
"/v2/pet/{pet_id}/uploadImage",
post(upload_file::<I, A, E, C>),
)
.route(
"/v2/pet/findByStatus",
get(find_pets_by_status::<I, A, E, C>),
)
.route("/v2/pet/findByTags", get(find_pets_by_tags::<I, A, E, C>))
.route("/v2/store/inventory", get(get_inventory::<I, A, E, C>))
.route("/v2/store/order", post(place_order::<I, A, E, C>))
.route(
"/v2/store/order/:order_id",
"/v2/store/order/{order_id}",
delete(delete_order::<I, A, E, C>).get(get_order_by_id::<I, A, E, C>),
)
.route("/v2/user", post(create_user::<I, A, E>))
.route(
"/v2/user/:username",
delete(delete_user::<I, A, E>)
.get(get_user_by_name::<I, A, E>)
.put(update_user::<I, A, E>),
)
.route(
"/v2/user/createWithArray",
post(create_users_with_array_input::<I, A, E>),
Expand All @@ -125,6 +119,12 @@ where
)
.route("/v2/user/login", get(login_user::<I, A, E>))
.route("/v2/user/logout", get(logout_user::<I, A, E>))
.route(
"/v2/user/{username}",
delete(delete_user::<I, A, E>)
.get(get_user_by_name::<I, A, E>)
.put(update_user::<I, A, E>),
)
.with_state(api_impl)
}

Expand Down
28 changes: 14 additions & 14 deletions samples/server/petstore/rust-axum/output/petstore/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,27 @@ where
post(add_pet::<I, A, E, C>).put(update_pet::<I, A, E, C>),
)
.route(
"/v2/pet/:pet_id",
"/v2/pet/findByStatus",
get(find_pets_by_status::<I, A, E, C>),
)
.route("/v2/pet/findByTags", get(find_pets_by_tags::<I, A, E, C>))
.route(
"/v2/pet/{pet_id}",
delete(delete_pet::<I, A, E, C>)
.get(get_pet_by_id::<I, A, E, C>)
.post(update_pet_with_form::<I, A, E, C>),
)
.route(
"/v2/pet/:pet_id/uploadImage",
"/v2/pet/{pet_id}/uploadImage",
post(upload_file::<I, A, E, C>),
)
.route(
"/v2/pet/findByStatus",
get(find_pets_by_status::<I, A, E, C>),
)
.route("/v2/pet/findByTags", get(find_pets_by_tags::<I, A, E, C>))
.route("/v2/store/inventory", get(get_inventory::<I, A, E, C>))
.route("/v2/store/order", post(place_order::<I, A, E, C>))
.route(
"/v2/store/order/:order_id",
"/v2/store/order/{order_id}",
delete(delete_order::<I, A, E, C>).get(get_order_by_id::<I, A, E, C>),
)
.route("/v2/user", post(create_user::<I, A, E, C>))
.route(
"/v2/user/:username",
delete(delete_user::<I, A, E, C>)
.get(get_user_by_name::<I, A, E, C>)
.put(update_user::<I, A, E, C>),
)
.route(
"/v2/user/createWithArray",
post(create_users_with_array_input::<I, A, E, C>),
Expand All @@ -70,6 +64,12 @@ where
)
.route("/v2/user/login", get(login_user::<I, A, E, C>))
.route("/v2/user/logout", get(logout_user::<I, A, E, C>))
.route(
"/v2/user/{username}",
delete(delete_user::<I, A, E, C>)
.get(get_user_by_name::<I, A, E, C>)
.put(update_user::<I, A, E, C>),
)
.with_state(api_impl)
}

Expand Down

0 comments on commit 51f6e61

Please sign in to comment.