@tim-smart/openapi-gen 0.2.0 → 0.2.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/main.js +25 -23
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -29342,6 +29342,28 @@ var make65 = make64;
|
|
|
29342
29342
|
var withHandler2 = withHandler;
|
|
29343
29343
|
var run9 = run8;
|
|
29344
29344
|
|
|
29345
|
+
// src/Utils.ts
|
|
29346
|
+
var camelize = (self) => {
|
|
29347
|
+
let str = "";
|
|
29348
|
+
let hadSymbol = false;
|
|
29349
|
+
for (let i = 0; i < self.length; i++) {
|
|
29350
|
+
const charCode = self.charCodeAt(i);
|
|
29351
|
+
if (charCode >= 65 && charCode <= 90 || charCode >= 97 && charCode <= 122) {
|
|
29352
|
+
str += hadSymbol ? self[i].toUpperCase() : self[i];
|
|
29353
|
+
hadSymbol = false;
|
|
29354
|
+
} else if (charCode >= 48 && charCode <= 57) {
|
|
29355
|
+
if (str.length > 0) {
|
|
29356
|
+
str += self[i];
|
|
29357
|
+
hadSymbol = true;
|
|
29358
|
+
}
|
|
29359
|
+
} else if (str.length > 0) {
|
|
29360
|
+
hadSymbol = true;
|
|
29361
|
+
}
|
|
29362
|
+
}
|
|
29363
|
+
return str;
|
|
29364
|
+
};
|
|
29365
|
+
var identifier = (operationId) => capitalize(camelize(operationId));
|
|
29366
|
+
|
|
29345
29367
|
// src/JsonSchemaGen.ts
|
|
29346
29368
|
var make66 = gen2(function* () {
|
|
29347
29369
|
const store = /* @__PURE__ */ new Map();
|
|
@@ -29354,7 +29376,7 @@ var make66 = gen2(function* () {
|
|
|
29354
29376
|
return;
|
|
29355
29377
|
}
|
|
29356
29378
|
const path2 = schema.$ref.slice(2).split("/");
|
|
29357
|
-
const name2 = path2[path2.length - 1];
|
|
29379
|
+
const name2 = identifier(path2[path2.length - 1]);
|
|
29358
29380
|
if (store.has(name2)) {
|
|
29359
29381
|
return;
|
|
29360
29382
|
}
|
|
@@ -29390,7 +29412,7 @@ var make66 = gen2(function* () {
|
|
|
29390
29412
|
}
|
|
29391
29413
|
if ("$ref" in root2) {
|
|
29392
29414
|
addRefs(root2, false);
|
|
29393
|
-
return root2.$ref.split("/").pop();
|
|
29415
|
+
return identifier(root2.$ref.split("/").pop());
|
|
29394
29416
|
} else {
|
|
29395
29417
|
addRefs(root2);
|
|
29396
29418
|
store.set(name, root2);
|
|
@@ -29509,7 +29531,7 @@ var make66 = gen2(function* () {
|
|
|
29509
29531
|
if (!schema.$ref.startsWith("#")) {
|
|
29510
29532
|
return none2();
|
|
29511
29533
|
}
|
|
29512
|
-
const name = schema.$ref.split("/").pop();
|
|
29534
|
+
const name = identifier(schema.$ref.split("/").pop());
|
|
29513
29535
|
return some2(name);
|
|
29514
29536
|
} else if ("properties" in schema) {
|
|
29515
29537
|
return toSource(S, { type: "object", ...schema }, topLevel);
|
|
@@ -29715,7 +29737,6 @@ var _OpenApi = class _OpenApi extends Tag3("OpenApi")() {
|
|
|
29715
29737
|
};
|
|
29716
29738
|
_OpenApi.Live = effect(_OpenApi, make67);
|
|
29717
29739
|
var OpenApi = _OpenApi;
|
|
29718
|
-
var identifier = (operationId) => capitalize(camelize(operationId));
|
|
29719
29740
|
var processPath = (path2) => {
|
|
29720
29741
|
const ids3 = [];
|
|
29721
29742
|
path2 = path2.replace(/{([^}]+)}/g, (_, name) => {
|
|
@@ -29835,25 +29856,6 @@ var operationToImpl = (operation) => {
|
|
|
29835
29856
|
${pipeline.join(",\n ")}
|
|
29836
29857
|
)`;
|
|
29837
29858
|
};
|
|
29838
|
-
var camelize = (self) => {
|
|
29839
|
-
let str = "";
|
|
29840
|
-
let hadSymbol = false;
|
|
29841
|
-
for (let i = 0; i < self.length; i++) {
|
|
29842
|
-
const charCode = self.charCodeAt(i);
|
|
29843
|
-
if (charCode >= 65 && charCode <= 90 || charCode >= 97 && charCode <= 122) {
|
|
29844
|
-
str += hadSymbol ? self[i].toUpperCase() : self[i];
|
|
29845
|
-
hadSymbol = false;
|
|
29846
|
-
} else if (charCode >= 48 && charCode <= 57) {
|
|
29847
|
-
if (str.length > 0) {
|
|
29848
|
-
str += self[i];
|
|
29849
|
-
hadSymbol = true;
|
|
29850
|
-
}
|
|
29851
|
-
} else if (str.length > 0) {
|
|
29852
|
-
hadSymbol = true;
|
|
29853
|
-
}
|
|
29854
|
-
}
|
|
29855
|
-
return str;
|
|
29856
|
-
};
|
|
29857
29859
|
|
|
29858
29860
|
// src/main.ts
|
|
29859
29861
|
var spec = fileParse2("spec").pipe(
|