Skip to content

Fix route regex pattern in route name generation #929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/orange-dogs-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"swagger-typescript-api": patch
---

Fix route regex pattern in route name generation.
2 changes: 1 addition & 1 deletion templates/base/route-name.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const methodAliases = {
};

const createCustomOperationId = (method, route, moduleName) => {
const hasPathInserts = /\{(\w){1,}\}/g.test(route);
const hasPathInserts = /\{(\w){1,}\}$/g.test(route);
const splittedRouteBySlash = _.compact(_.replace(route, /\{(\w){1,}\}/g, "").split("/"));
const routeParts = (splittedRouteBySlash.length > 1
? splittedRouteBySlash.splice(1)
Expand Down
68 changes: 34 additions & 34 deletions tests/__snapshots__/extended.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -59295,7 +59295,7 @@ export enum StepModeEnum {
Other = "other",
}

export type StopDetailData = Step[];
export type StopListData = Step[];

export interface Trip {
/**
Expand All @@ -59321,19 +59321,19 @@ export type TripListData = Trip[];
export namespace Trip {
/**
* @description list stops for a trip identified by {trip_id}
* @name StopDetail
* @name StopList
* @request GET:/trip/{trip_id}/stop
* @secure
*/
export namespace StopDetail {
export namespace StopList {
export type RequestParams = {
/** id of the trip */
tripId: string;
};
export type RequestQuery = {};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = StopDetailData;
export type ResponseBody = StopListData;
}

/**
Expand Down Expand Up @@ -59577,12 +59577,12 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
/**
* @description list stops for a trip identified by {trip_id}
*
* @name StopDetail
* @name StopList
* @request GET:/trip/{trip_id}/stop
* @secure
*/
stopDetail: (tripId: string, params: RequestParams = {}) =>
this.request<StopDetailData, any>({
stopList: (tripId: string, params: RequestParams = {}) =>
this.request<StopListData, any>({
path: \`/trip/\${tripId}/stop\`,
method: "GET",
secure: true,
Expand Down Expand Up @@ -69761,9 +69761,9 @@ export interface ListWebhooksResponse {
};
}

export type LogsDetailData = ListWebhookDeliveryLogsResponse;
export type LogsListData = ListWebhookDeliveryLogsResponse;

export interface LogsDetailParams {
export interface LogsListParams {
/**
* The number of records to return in each page.
* @example 30
Expand Down Expand Up @@ -70016,7 +70016,9 @@ export enum TransactionStatusEnum {

export type TransactionsDetailData = GetTransactionResponse;

export interface TransactionsDetailParams1 {
export type TransactionsListData = ListTransactionsResponse;

export interface TransactionsListParams {
/**
* The category identifier for which to filter transactions.
* Both parent and child categories can be filtered through
Expand Down Expand Up @@ -70060,18 +70062,11 @@ export interface TransactionsDetailParams1 {
* @example 30
*/
"page[size]"?: number;
/**
* The unique identifier for the account.
* @example "86150b64-feaa-4186-a7e4-e84eae764602"
*/
accountId: string;
/** Blablabla bla */
someEnumName?: SomeEnumName;
}

export type TransactionsDetailResult = ListTransactionsResponse;

export type TransactionsListData = ListTransactionsResponse;

export interface TransactionsListParams {
export interface TransactionsListParams2 {
/**
* The category identifier for which to filter transactions.
* Both parent and child categories can be filtered through
Expand Down Expand Up @@ -70115,10 +70110,15 @@ export interface TransactionsListParams {
* @example 30
*/
"page[size]"?: number;
/** Blablabla bla */
someEnumName?: SomeEnumName;
/**
* The unique identifier for the account.
* @example "86150b64-feaa-4186-a7e4-e84eae764602"
*/
accountId: string;
}

export type TransactionsListResult = ListTransactionsResponse;

/** Request to add or remove tags associated with a transaction. */
export interface UpdateTransactionTagsRequest {
/** The tags to add to or remove from the transaction. */
Expand Down Expand Up @@ -70385,12 +70385,12 @@ export namespace Accounts {
/**
* @description Retrieve a list of all transactions for a specific account. The returned list is [paginated](#pagination) and can be scrolled by following the \`next\` and \`prev\` links where present. To narrow the results to a specific date range pass one or both of \`filter[since]\` and \`filter[until]\` in the query string. These filter parameters **should not** be used for pagination. Results are ordered newest first to oldest last.
* @tags Transactions
* @name TransactionsDetail
* @name TransactionsList
* @summary List transactions by account
* @request GET:/accounts/{accountId}/transactions
* @secure
*/
export namespace TransactionsDetail {
export namespace TransactionsList {
export type RequestParams = {
/**
* The unique identifier for the account.
Expand Down Expand Up @@ -70445,7 +70445,7 @@ export namespace Accounts {
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = TransactionsDetailResult;
export type ResponseBody = TransactionsListResult;
}
}

Expand Down Expand Up @@ -70673,12 +70673,12 @@ export namespace Webhooks {
/**
* @description Retrieve a list of delivery logs for a webhook by providing its unique identifier. This is useful for analysis and debugging purposes. The returned list is [paginated](#pagination) and can be scrolled by following the \`next\` and \`prev\` links where present. Results are ordered newest first to oldest last. Logs may be automatically purged after a period of time.
* @tags Webhooks
* @name LogsDetail
* @name LogsList
* @summary List webhook logs
* @request GET:/webhooks/{webhookId}/logs
* @secure
*/
export namespace LogsDetail {
export namespace LogsList {
export type RequestParams = {
/**
* The unique identifier for the webhook.
Expand All @@ -70695,7 +70695,7 @@ export namespace Webhooks {
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = LogsDetailData;
export type ResponseBody = LogsListData;
}

/**
Expand Down Expand Up @@ -71067,13 +71067,13 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
* @description Retrieve a list of all transactions for a specific account. The returned list is [paginated](#pagination) and can be scrolled by following the \`next\` and \`prev\` links where present. To narrow the results to a specific date range pass one or both of \`filter[since]\` and \`filter[until]\` in the query string. These filter parameters **should not** be used for pagination. Results are ordered newest first to oldest last.
*
* @tags Transactions
* @name TransactionsDetail
* @name TransactionsList
* @summary List transactions by account
* @request GET:/accounts/{accountId}/transactions
* @secure
*/
transactionsDetail: ({ accountId, ...query }: TransactionsDetailParams1, params: RequestParams = {}) =>
this.request<TransactionsDetailResult, any>({
transactionsList: ({ accountId, ...query }: TransactionsListParams2, params: RequestParams = {}) =>
this.request<TransactionsListResult, any>({
path: \`/accounts/\${accountId}/transactions\`,
method: "GET",
query: query,
Expand Down Expand Up @@ -71240,13 +71240,13 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
* @description Retrieve a list of delivery logs for a webhook by providing its unique identifier. This is useful for analysis and debugging purposes. The returned list is [paginated](#pagination) and can be scrolled by following the \`next\` and \`prev\` links where present. Results are ordered newest first to oldest last. Logs may be automatically purged after a period of time.
*
* @tags Webhooks
* @name LogsDetail
* @name LogsList
* @summary List webhook logs
* @request GET:/webhooks/{webhookId}/logs
* @secure
*/
logsDetail: ({ webhookId, ...query }: LogsDetailParams, params: RequestParams = {}) =>
this.request<LogsDetailData, any>({
logsList: ({ webhookId, ...query }: LogsListParams, params: RequestParams = {}) =>
this.request<LogsListData, any>({
path: \`/webhooks/\${webhookId}/logs\`,
method: "GET",
query: query,
Expand Down
12 changes: 6 additions & 6 deletions tests/__snapshots__/simple.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36145,11 +36145,11 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
/**
* @description list stops for a trip identified by {trip_id}
*
* @name StopDetail
* @name StopList
* @request GET:/trip/{trip_id}/stop
* @secure
*/
stopDetail: (tripId: string, params: RequestParams = {}) =>
stopList: (tripId: string, params: RequestParams = {}) =>
this.request<Step[], any>({
path: \`/trip/\${tripId}/stop\`,
method: "GET",
Expand Down Expand Up @@ -44828,12 +44828,12 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
* @description Retrieve a list of all transactions for a specific account. The returned list is [paginated](#pagination) and can be scrolled by following the \`next\` and \`prev\` links where present. To narrow the results to a specific date range pass one or both of \`filter[since]\` and \`filter[until]\` in the query string. These filter parameters **should not** be used for pagination. Results are ordered newest first to oldest last.
*
* @tags Transactions
* @name TransactionsDetail
* @name TransactionsList
* @summary List transactions by account
* @request GET:/accounts/{accountId}/transactions
* @secure
*/
transactionsDetail: (
transactionsList: (
accountId: string,
query?: {
/**
Expand Down Expand Up @@ -45219,12 +45219,12 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
* @description Retrieve a list of delivery logs for a webhook by providing its unique identifier. This is useful for analysis and debugging purposes. The returned list is [paginated](#pagination) and can be scrolled by following the \`next\` and \`prev\` links where present. Results are ordered newest first to oldest last. Logs may be automatically purged after a period of time.
*
* @tags Webhooks
* @name LogsDetail
* @name LogsList
* @summary List webhook logs
* @request GET:/webhooks/{webhookId}/logs
* @secure
*/
logsDetail: (
logsList: (
webhookId: string,
query?: {
/**
Expand Down
Loading