fix(router): Make v2 endpoints follow standard naming conventions (#8630)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Anurag Thakur
2025-07-21 19:33:25 +05:30
committed by GitHub
parent 2bac3e0a65
commit db14764671
24 changed files with 128 additions and 56 deletions

View File

@ -20,7 +20,7 @@
}
],
"paths": {
"/v2/organization": {
"/v2/organizations": {
"post": {
"tags": [
"Organization"
@ -67,7 +67,7 @@
]
}
},
"/v2/organization/{id}": {
"/v2/organizations/{id}": {
"get": {
"tags": [
"Organization"
@ -164,7 +164,7 @@
]
}
},
"/v2/organization/{id}/merchant-accounts": {
"/v2/organizations/{id}/merchant-accounts": {
"get": {
"tags": [
"Organization"
@ -1220,7 +1220,7 @@
]
}
},
"/v2/routing-algorithm": {
"/v2/routing-algorithms": {
"post": {
"tags": [
"Routing"
@ -1275,7 +1275,7 @@
]
}
},
"/v2/routing-algorithm/{id}": {
"/v2/routing-algorithms/{id}": {
"get": {
"tags": [
"Routing"
@ -2850,7 +2850,7 @@
]
}
},
"/v2/payment-method-session": {
"/v2/payment-method-sessions": {
"post": {
"tags": [
"Payment Method Session"
@ -2897,7 +2897,7 @@
]
}
},
"/v2/payment-method-session/{id}": {
"/v2/payment-method-sessions/{id}": {
"get": {
"tags": [
"Payment Method Session"
@ -2994,7 +2994,7 @@
]
}
},
"/v2/payment-method-session/{id}/list-payment-methods": {
"/v2/payment-method-sessions/{id}/list-payment-methods": {
"get": {
"tags": [
"Payment Method Session"
@ -3035,7 +3035,7 @@
]
}
},
"/v2/payment-method-session/{id}/update-saved-payment-method": {
"/v2/payment-method-sessions/{id}/update-saved-payment-method": {
"put": {
"tags": [
"Payment Method Session"
@ -3098,7 +3098,7 @@
]
}
},
"/v2/payment-method-session/{id}/confirm": {
"/v2/payment-method-sessions/{id}/confirm": {
"post": {
"tags": [
"Payment Method Session"
@ -3241,7 +3241,7 @@
]
}
},
"/v2/refunds/{id}/update_metadata": {
"/v2/refunds/{id}/update-metadata": {
"put": {
"tags": [
"Refunds"
@ -3377,7 +3377,7 @@
]
}
},
"/v2/process_tracker/revenue_recovery_workflow/{revenue_recovery_id}": {
"/v2/process-trackers/revenue-recovery-workflow/{revenue_recovery_id}": {
"get": {
"tags": [
"Revenue Recovery"

View File

@ -1,3 +1,3 @@
---
openapi: post /v2/organization
openapi: post /v2/organizations
---

View File

@ -1,3 +1,3 @@
---
openapi: get /v2/organization/{id}/merchant-accounts
openapi: get /v2/organizations/{id}/merchant-accounts
---

View File

@ -1,3 +1,3 @@
---
openapi: get /v2/organization/{id}
openapi: get /v2/organizations/{id}
---

View File

@ -1,3 +1,3 @@
---
openapi: put /v2/organization/{id}
openapi: put /v2/organizations/{id}
---

View File

@ -1,3 +1,3 @@
---
openapi: post /v2/payment-method-session/{id}/confirm
openapi: post /v2/payment-method-sessions/{id}/confirm
---

View File

@ -1,3 +1,3 @@
---
openapi: post /v2/payment-method-session
openapi: post /v2/payment-method-sessions
---

View File

@ -1,3 +1,3 @@
---
openapi: delete /v2/payment-method-session/{id}
openapi: delete /v2/payment-method-sessions/{id}
---

View File

@ -1,3 +1,3 @@
---
openapi: get /v2/payment-method-session/{id}/list-payment-methods
openapi: get /v2/payment-method-sessions/{id}/list-payment-methods
---

View File

@ -1,3 +1,3 @@
---
openapi: get /v2/payment-method-session/{id}
openapi: get /v2/payment-method-sessions/{id}
---

View File

@ -1,3 +1,3 @@
---
openapi: put /v2/payment-method-session/{id}/update-saved-payment-method
openapi: put /v2/payment-method-sessions/{id}/update-saved-payment-method
---

View File

@ -1,3 +1,3 @@
---
openapi: get /v2/process_tracker/revenue_recovery_workflow/{revenue_recovery_id}
openapi: get /v2/process-trackers/revenue-recovery-workflow/{revenue_recovery_id}
---

View File

@ -1,3 +1,3 @@
---
openapi: post /v2/routing-algorithm
openapi: post /v2/routing-algorithms
---

View File

@ -1,3 +1,3 @@
---
openapi: get /v2/routing-algorithm/{id}
openapi: get /v2/routing-algorithms/{id}
---

View File

@ -85,7 +85,7 @@ impl ConnectorIntegration<ExternalVaultCreateFlow, VaultRequestData, VaultRespon
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
"{}/v2/payment-methods-session",
"{}/v2/payment-method-sessions",
self.base_url(connectors)
))
}

View File

@ -77,7 +77,7 @@ pub async fn organization_update() {}
/// Create a new organization
#[utoipa::path(
post,
path = "/v2/organization",
path = "/v2/organizations",
request_body(
content = OrganizationCreateRequest,
examples(
@ -104,7 +104,7 @@ pub async fn organization_create() {}
/// Retrieve an existing organization
#[utoipa::path(
get,
path = "/v2/organization/{id}",
path = "/v2/organizations/{id}",
params (("id" = String, Path, description = "The unique identifier for the Organization")),
responses(
(status = 200, description = "Organization Created", body =OrganizationResponse),
@ -122,7 +122,7 @@ pub async fn organization_retrieve() {}
/// Create a new organization for .
#[utoipa::path(
put,
path = "/v2/organization/{id}",
path = "/v2/organizations/{id}",
request_body(
content = OrganizationUpdateRequest,
examples(
@ -150,7 +150,7 @@ pub async fn organization_update() {}
/// List merchant accounts for an Organization
#[utoipa::path(
get,
path = "/v2/organization/{id}/merchant-accounts",
path = "/v2/organizations/{id}/merchant-accounts",
params (("id" = String, Path, description = "The unique identifier for the Organization")),
responses(
(status = 200, description = "Merchant Account list retrieved successfully", body = Vec<MerchantAccountResponse>),

View File

@ -353,7 +353,7 @@ pub async fn list_customer_payment_method_api() {}
#[cfg(feature = "v2")]
#[utoipa::path(
post,
path = "/v2/payment-method-session",
path = "/v2/payment-method-sessions",
request_body(
content = PaymentMethodSessionRequest,
examples (( "Create a payment method session with customer_id" = (
@ -378,7 +378,7 @@ pub fn payment_method_session_create() {}
#[cfg(feature = "v2")]
#[utoipa::path(
get,
path = "/v2/payment-method-session/{id}",
path = "/v2/payment-method-sessions/{id}",
params (
("id" = String, Path, description = "The unique identifier for the Payment Method Session"),
),
@ -399,7 +399,7 @@ pub fn payment_method_session_retrieve() {}
#[cfg(feature = "v2")]
#[utoipa::path(
get,
path = "/v2/payment-method-session/{id}/list-payment-methods",
path = "/v2/payment-method-sessions/{id}/list-payment-methods",
params (
("id" = String, Path, description = "The unique identifier for the Payment Method Session"),
),
@ -419,7 +419,7 @@ pub fn payment_method_session_list_payment_methods() {}
#[cfg(feature = "v2")]
#[utoipa::path(
put,
path = "/v2/payment-method-session/{id}/update-saved-payment-method",
path = "/v2/payment-method-sessions/{id}/update-saved-payment-method",
params (
("id" = String, Path, description = "The unique identifier for the Payment Method Session"),
),
@ -453,7 +453,7 @@ pub fn payment_method_session_update_saved_payment_method() {}
#[cfg(feature = "v2")]
#[utoipa::path(
delete,
path = "/v2/payment-method-session/{id}",
path = "/v2/payment-method-sessions/{id}",
params (
("id" = String, Path, description = "The unique identifier for the Payment Method Session"),
),
@ -520,7 +520,7 @@ pub async fn tokenize_card_using_pm_api() {}
/// **Confirms a payment method session object with the payment method data**
#[utoipa::path(
post,
path = "/v2/payment-method-session/{id}/confirm",
path = "/v2/payment-method-sessions/{id}/confirm",
params (("id" = String, Path, description = "The unique identifier for the Payment Method Session"),
(
"X-Profile-Id" = String, Header,

View File

@ -221,7 +221,7 @@ pub async fn refunds_create() {}
/// Updates the properties of a Refund object. This API can be used to attach a reason for the refund or metadata fields
#[utoipa::path(
put,
path = "/v2/refunds/{id}/update_metadata",
path = "/v2/refunds/{id}/update-metadata",
params(
("id" = String, Path, description = "The identifier for refund")
),

View File

@ -4,7 +4,7 @@
/// Retrieve the Revenue Recovery Payment Info
#[utoipa::path(
get,
path = "/v2/process_tracker/revenue_recovery_workflow/{revenue_recovery_id}",
path = "/v2/process-trackers/revenue-recovery-workflow/{revenue_recovery_id}",
params(
("recovery_recovery_id" = String, Path, description = "The payment intent id"),
),

View File

@ -26,7 +26,7 @@ pub async fn routing_create_config() {}
/// Create a routing algorithm
#[utoipa::path(
post,
path = "/v2/routing-algorithm",
path = "/v2/routing-algorithms",
request_body = RoutingConfigRequest,
responses(
(status = 200, description = "Routing Algorithm created", body = RoutingDictionaryRecord),
@ -92,7 +92,7 @@ pub async fn routing_retrieve_config() {}
/// Retrieve a routing algorithm with its algorithm id
#[utoipa::path(
get,
path = "/v2/routing-algorithm/{id}",
path = "/v2/routing-algorithms/{id}",
params(
("id" = String, Path, description = "The unique identifier for a routing algorithm"),
),

View File

@ -210,7 +210,10 @@ pub fn mk_app(
#[cfg(feature = "v2")]
{
server_app = server_app.service(routes::ProcessTracker::server(state.clone()));
server_app = server_app
.service(routes::UserDeprecated::server(state.clone()))
.service(routes::ProcessTrackerDeprecated::server(state.clone()))
.service(routes::ProcessTracker::server(state.clone()));
}
}

View File

@ -91,8 +91,9 @@ pub use self::app::{
ApiKeys, AppState, ApplePayCertificatesMigration, Authentication, Cache, Cards, Chat, Configs,
ConnectorOnboarding, Customers, Disputes, EphemeralKey, FeatureMatrix, Files, Forex, Gsm,
Health, Hypersense, Mandates, MerchantAccount, MerchantConnectorAccount, PaymentLink,
PaymentMethods, Payments, Poll, ProcessTracker, Profile, ProfileAcquirer, ProfileNew, Refunds,
Relay, RelayWebhooks, SessionState, ThreeDsDecisionRule, User, Webhooks,
PaymentMethods, Payments, Poll, ProcessTracker, ProcessTrackerDeprecated, Profile,
ProfileAcquirer, ProfileNew, Refunds, Relay, RelayWebhooks, SessionState, ThreeDsDecisionRule,
User, UserDeprecated, Webhooks,
};
#[cfg(feature = "olap")]
pub use self::app::{Blocklist, Organization, Routing, Verify, WebhookEvents};

View File

@ -657,10 +657,15 @@ impl Payments {
web::resource("/confirm-intent")
.route(web::post().to(payments::payment_confirm_intent)),
)
// TODO: Deprecated. Remove this in favour of /list-attempts
.service(
web::resource("/list_attempts")
.route(web::get().to(payments::list_payment_attempts)),
)
.service(
web::resource("/list-attempts")
.route(web::get().to(payments::list_payment_attempts)),
)
.service(
web::resource("/proxy-confirm-intent")
.route(web::post().to(payments::proxy_confirm_intent)),
@ -882,7 +887,7 @@ pub struct Routing;
#[cfg(all(feature = "olap", feature = "v2"))]
impl Routing {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/routing-algorithm")
web::scope("/v2/routing-algorithms")
.app_data(web::Data::new(state.clone()))
.service(
web::resource("").route(web::post().to(|state, req, payload| {
@ -1255,7 +1260,7 @@ impl Refunds {
.route(web::post().to(refunds::refunds_retrieve_with_gateway_creds)),
)
.service(
web::resource("/{id}/update_metadata")
web::resource("/{id}/update-metadata")
.route(web::put().to(refunds::refunds_metadata_update)),
);
}
@ -1425,7 +1430,7 @@ pub struct PaymentMethodSession;
#[cfg(all(feature = "v2", feature = "oltp"))]
impl PaymentMethodSession {
pub fn server(state: AppState) -> Scope {
let mut route = web::scope("/v2/payment-methods-session").app_data(web::Data::new(state));
let mut route = web::scope("/v2/payment-method-sessions").app_data(web::Data::new(state));
route = route.service(
web::resource("")
.route(web::post().to(payment_methods::payment_methods_session_create)),
@ -1558,7 +1563,7 @@ impl Organization {
#[cfg(all(feature = "v2", feature = "olap"))]
impl Organization {
pub fn server(state: AppState) -> Scope {
web::scope("/v2/organization")
web::scope("/v2/organizations")
.app_data(web::Data::new(state))
.service(web::resource("").route(web::post().to(admin::organization_create)))
.service(
@ -2282,15 +2287,61 @@ impl Verify {
}
}
pub struct UserDeprecated;
#[cfg(all(feature = "olap", feature = "v2"))]
impl UserDeprecated {
pub fn server(state: AppState) -> Scope {
// TODO: Deprecated. Remove this in favour of /v2/users
let mut route = web::scope("/v2/user").app_data(web::Data::new(state));
route = route.service(
web::resource("/create_merchant")
.route(web::post().to(user::user_merchant_account_create)),
);
route = route.service(
web::scope("/list")
.service(
web::resource("/merchant")
.route(web::get().to(user::list_merchants_for_user_in_org)),
)
.service(
web::resource("/profile")
.route(web::get().to(user::list_profiles_for_user_in_org_and_merchant)),
),
);
route = route.service(
web::scope("/switch")
.service(
web::resource("/merchant")
.route(web::post().to(user::switch_merchant_for_user_in_org)),
)
.service(
web::resource("/profile")
.route(web::post().to(user::switch_profile_for_user_in_org_and_merchant)),
),
);
route = route.service(
web::resource("/data")
.route(web::get().to(user::get_multiple_dashboard_metadata))
.route(web::post().to(user::set_dashboard_metadata)),
);
route
}
}
pub struct User;
#[cfg(all(feature = "olap", feature = "v2"))]
impl User {
pub fn server(state: AppState) -> Scope {
let mut route = web::scope("/v2/user").app_data(web::Data::new(state));
let mut route = web::scope("/v2/users").app_data(web::Data::new(state));
route = route.service(
web::resource("/create_merchant")
web::resource("/create-merchant")
.route(web::post().to(user::user_merchant_account_create)),
);
route = route.service(
@ -2696,6 +2747,23 @@ impl FeatureMatrix {
}
}
#[cfg(feature = "olap")]
pub struct ProcessTrackerDeprecated;
#[cfg(all(feature = "olap", feature = "v2"))]
impl ProcessTrackerDeprecated {
pub fn server(state: AppState) -> Scope {
use super::process_tracker::revenue_recovery;
// TODO: Deprecated. Remove this in favour of /v2/process-trackers
web::scope("/v2/process_tracker/revenue_recovery_workflow")
.app_data(web::Data::new(state.clone()))
.service(
web::resource("/{revenue_recovery_id}")
.route(web::get().to(revenue_recovery::revenue_recovery_pt_retrieve_api)),
)
}
}
#[cfg(feature = "olap")]
pub struct ProcessTracker;
@ -2703,7 +2771,7 @@ pub struct ProcessTracker;
impl ProcessTracker {
pub fn server(state: AppState) -> Scope {
use super::process_tracker::revenue_recovery;
web::scope("/v2/process_tracker/revenue_recovery_workflow")
web::scope("/v2/process-trackers/revenue-recovery-workflow")
.app_data(web::Data::new(state.clone()))
.service(
web::resource("/{revenue_recovery_id}")

View File

@ -45,7 +45,7 @@ Cypress.Commands.add(
// Define the necessary variables and constants
const api_key = globalState.get("adminApiKey");
const base_url = globalState.get("baseUrl");
const url = `${base_url}/v2/organization`;
const url = `${base_url}/v2/organizations`;
// Update request body
organizationCreateBody.organization_name += " " + nanoid();
@ -84,7 +84,7 @@ Cypress.Commands.add("organizationRetrieveCall", (globalState) => {
const api_key = globalState.get("adminApiKey");
const base_url = globalState.get("baseUrl");
const organization_id = globalState.get("organizationId");
const url = `${base_url}/v2/organization/${organization_id}`;
const url = `${base_url}/v2/organizations/${organization_id}`;
cy.request({
method: "GET",
@ -125,7 +125,7 @@ Cypress.Commands.add(
const api_key = globalState.get("adminApiKey");
const base_url = globalState.get("baseUrl");
const organization_id = globalState.get("organizationId");
const url = `${base_url}/v2/organization/${organization_id}`;
const url = `${base_url}/v2/organizations/${organization_id}`;
// Update request body
organizationUpdateBody.organization_name += " " + nanoid();
@ -805,7 +805,7 @@ Cypress.Commands.add(
const api_key = globalState.get("userInfoToken");
const base_url = globalState.get("baseUrl");
const profile_id = globalState.get("profileId");
const url = `${base_url}/v2/routing-algorithm`;
const url = `${base_url}/v2/routing-algorithms`;
// Update request body
routingSetupBody.algorithm.data = payload.data;
@ -961,7 +961,7 @@ Cypress.Commands.add("routingRetrieveCall", (globalState) => {
const base_url = globalState.get("baseUrl");
const profile_id = globalState.get("profileId");
const routing_algorithm_id = globalState.get("routingAlgorithmId");
const url = `${base_url}/v2/routing-algorithm/${routing_algorithm_id}`;
const url = `${base_url}/v2/routing-algorithms/${routing_algorithm_id}`;
cy.request({
method: "GET",
@ -1170,7 +1170,7 @@ Cypress.Commands.add("merchantAccountsListCall", (globalState) => {
const key_id_type = "publishable_key";
const key_id = validateEnv(base_url, key_id_type);
const organization_id = globalState.get("organizationId");
const url = `${base_url}/v2/organization/${organization_id}/merchant-accounts`;
const url = `${base_url}/v2/organizations/${organization_id}/merchant-accounts`;
cy.request({
method: "GET",