Skip to content

Commit

Permalink
Use replaceAll instead of replace when generating operationid. (langc…
Browse files Browse the repository at this point in the history
…hain-ai#3267)

* Use replaceAll instead of replace when generating operationid.

Fixes langchain-ai#3266.

* Format code.
  • Loading branch information
Manouchehri authored Nov 14, 2023
1 parent f73fb6e commit 3983e5c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions langchain/src/util/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,15 @@ export class OpenAPISpec {
) {
let { operationId } = operation;
if (operationId === undefined) {
const updatedPath = path.replace(/[^a-zA-Z0-9]/, "_");
const updatedPath = path.replaceAll(/[^a-zA-Z0-9]/, "_");
operationId = `${
updatedPath.startsWith("/") ? updatedPath.slice(1) : updatedPath
}_${method}`;
}
return operationId.replace("-", "_").replace(".", "_").replace("/", "_");
return operationId
.replaceAll("-", "_")
.replaceAll(".", "_")
.replaceAll("/", "_");
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit 3983e5c

Please sign in to comment.