openapi-sync 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,6 +97,21 @@ const OpenapiSync = (apiUrl, apiName, refetchInterval) => __awaiter(void 0, void
97
97
  }
98
98
  return typeCnt;
99
99
  };
100
+ const treatEndpointUrl = (endpointUrl) => {
101
+ var _a, _b;
102
+ if (((_b = (_a = config === null || config === void 0 ? void 0 : config.endpoints) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.replaceWords) &&
103
+ Array.isArray(config.endpoints.value.replaceWords)) {
104
+ let newEndpointUrl = endpointUrl;
105
+ config.endpoints.value.replaceWords.forEach((replaceWord, indx) => {
106
+ const regexp = new RegExp(replaceWord.replace, "g");
107
+ newEndpointUrl = newEndpointUrl.replace(regexp, replaceWord.with || "");
108
+ });
109
+ return newEndpointUrl;
110
+ }
111
+ else {
112
+ return endpointUrl;
113
+ }
114
+ };
100
115
  Object.keys(spec.paths || {}).forEach((endpointPath) => {
101
116
  const endpointSpec = spec.paths[endpointPath];
102
117
  const endpointMethods = Object.keys(endpointSpec);
@@ -118,6 +133,8 @@ const OpenapiSync = (apiUrl, apiName, refetchInterval) => __awaiter(void 0, void
118
133
  const params = endpoint.variables.map((v) => `${v}:string`).join(",");
119
134
  endpointUrl = `(${params})=> \`${endpointUrlTxt}\``;
120
135
  }
136
+ //treat endpoint url
137
+ endpointUrl = treatEndpointUrl(endpointUrl);
121
138
  // Add the endpoint url
122
139
  endpointsFileContent += `export const ${endpoint.name} = ${endpointUrl};
123
140
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-sync",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "sync openapi variables",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",