openapi-sync 2.0.2 → 2.1.1
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/db.json +1 -1
- package/dist/Openapi-sync/index.js +12 -4
- package/package.json +1 -1
- package/types.ts +2 -1
|
@@ -54,7 +54,9 @@ const OpenapiSync = (apiUrl, apiName, config, refetchInterval) => __awaiter(void
|
|
|
54
54
|
});
|
|
55
55
|
const folderPath = path_1.default.join((config === null || config === void 0 ? void 0 : config.folder) || "", apiName);
|
|
56
56
|
const spec = lintResults.bundle.parsed;
|
|
57
|
-
const serverUrl =
|
|
57
|
+
const serverUrl = typeof (config === null || config === void 0 ? void 0 : config.server) === "string"
|
|
58
|
+
? config === null || config === void 0 ? void 0 : config.server
|
|
59
|
+
: ((_b = (_a = spec === null || spec === void 0 ? void 0 : spec.servers) === null || _a === void 0 ? void 0 : _a[(config === null || config === void 0 ? void 0 : config.server) || 0]) === null || _b === void 0 ? void 0 : _b.url) || "";
|
|
58
60
|
const typePrefix = typeof ((_d = (_c = config === null || config === void 0 ? void 0 : config.types) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.prefix) === "string"
|
|
59
61
|
? config === null || config === void 0 ? void 0 : config.types.name.prefix
|
|
60
62
|
: "I";
|
|
@@ -446,7 +448,7 @@ const OpenapiSync = (apiUrl, apiName, config, refetchInterval) => __awaiter(void
|
|
|
446
448
|
const endpointSpec = spec.paths[endpointPath];
|
|
447
449
|
const endpointMethods = Object.keys(endpointSpec);
|
|
448
450
|
endpointMethods.forEach((_method) => {
|
|
449
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
451
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
450
452
|
const method = _method;
|
|
451
453
|
const endpoint = (0, helpers_1.getEndpointDetails)(endpointPath, method);
|
|
452
454
|
const endpointUrlTxt = (((_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.includeServer) ? serverUrl : "") +
|
|
@@ -670,7 +672,6 @@ ${(0, curl_generator_1.CurlGenerator)({
|
|
|
670
672
|
((_q = eSpec === null || eSpec === void 0 ? void 0 : eSpec.operationId) === null || _q === void 0 ? void 0 : _q.length) > 0
|
|
671
673
|
? eSpec.operationId
|
|
672
674
|
: `${endpoint.name}`;
|
|
673
|
-
console.log("endpoint.name", eSpec);
|
|
674
675
|
if ((_s = (_r = config === null || config === void 0 ? void 0 : config.endpoints) === null || _r === void 0 ? void 0 : _r.name) === null || _s === void 0 ? void 0 : _s.format) {
|
|
675
676
|
const formattedName = config === null || config === void 0 ? void 0 : config.endpoints.name.format({
|
|
676
677
|
method,
|
|
@@ -681,8 +682,15 @@ ${(0, curl_generator_1.CurlGenerator)({
|
|
|
681
682
|
if (formattedName)
|
|
682
683
|
name = formattedName;
|
|
683
684
|
}
|
|
685
|
+
const content = {
|
|
686
|
+
method: `"${method}"`,
|
|
687
|
+
operationId: `"${eSpec === null || eSpec === void 0 ? void 0 : eSpec.operationId}"`,
|
|
688
|
+
url: endpointUrl,
|
|
689
|
+
};
|
|
684
690
|
// Add the endpoint url
|
|
685
|
-
endpointsFileContent += `${doc}export const ${endpointPrefix}${name} = ${
|
|
691
|
+
endpointsFileContent += `${doc}export const ${endpointPrefix}${name} = ${((_u = (_t = config === null || config === void 0 ? void 0 : config.endpoints) === null || _t === void 0 ? void 0 : _t.value) === null || _u === void 0 ? void 0 : _u.type) === "object"
|
|
692
|
+
? (0, helpers_1.JSONStringify)(content)
|
|
693
|
+
: endpointUrl};
|
|
686
694
|
`;
|
|
687
695
|
});
|
|
688
696
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-sync",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "A developer-friendly tool designed to keep your API up-to-date by leveraging OpenAPI schemas. It automates the generation of endpoint URIs and type definitions, including shared types, directly from your OpenAPI specification.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/types.ts
CHANGED
|
@@ -67,7 +67,7 @@ export type IConfig = {
|
|
|
67
67
|
refetchInterval?: number;
|
|
68
68
|
folder?: string;
|
|
69
69
|
api: Record<string, string>;
|
|
70
|
-
server?: number;
|
|
70
|
+
server?: number | string;
|
|
71
71
|
types?: {
|
|
72
72
|
name?: {
|
|
73
73
|
prefix?: string;
|
|
@@ -90,6 +90,7 @@ export type IConfig = {
|
|
|
90
90
|
value?: {
|
|
91
91
|
replaceWords?: IConfigReplaceWord[];
|
|
92
92
|
includeServer?: boolean;
|
|
93
|
+
type?: "string" | "object";
|
|
93
94
|
};
|
|
94
95
|
name?: {
|
|
95
96
|
format?: (data: {
|