openapi-sync 1.0.12 → 1.0.14
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.
- package/README.md +2 -2
- package/bin/cli.js +1 -1
- package/dist/Openapi-sync/index.js +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/cli.js
CHANGED
|
@@ -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
|
`;
|