@dotflash/openapi-semantic-generator 0.1.3 → 0.1.4

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.
@@ -68,7 +68,8 @@ async function extractMetadata(specPath) {
68
68
  };
69
69
  }
70
70
  function toCamelCase(str) {
71
- return str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
71
+ const camel = str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
72
+ return camel.charAt(0).toLowerCase() + camel.slice(1);
72
73
  }
73
74
  function cleanDescription(desc) {
74
75
  if (!desc) return "";
@@ -89,10 +90,13 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
89
90
  if (!await fs2.pathExists(fullDir)) continue;
90
91
  const files = await fs2.readdir(fullDir);
91
92
  for (const file of files) {
92
- if ((file.endsWith("Api.ts") || file.endsWith("api.ts")) && !file.endsWith(".test.ts")) {
93
+ const lowerFile = file.toLowerCase();
94
+ const isCodeFile = file.endsWith(".ts") || file.endsWith(".js");
95
+ const isTestFile = lowerFile.endsWith(".test.ts") || lowerFile.endsWith(".spec.ts");
96
+ const isIndexFile = lowerFile === "index.ts" || lowerFile === "index.js";
97
+ if (isCodeFile && !isTestFile && !isIndexFile) {
93
98
  apis.push({
94
- className: file.replace(".ts", ""),
95
- // Simplified
99
+ className: file.replace(/\.[jt]s$/, ""),
96
100
  sourceFile: path.join(dirName, file)
97
101
  });
98
102
  }
@@ -101,6 +105,11 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
101
105
  if (metadata.operations) {
102
106
  for (const op of metadata.operations) {
103
107
  if (apis.length === 0) continue;
108
+ if (apis.length === 1) {
109
+ op.className = apis[0].className;
110
+ op.sourceFile = apis[0].sourceFile;
111
+ continue;
112
+ }
104
113
  let matchedApi = apis[0];
105
114
  if (op.tags && op.tags.length > 0) {
106
115
  const primaryTag = op.tags[0].toLowerCase();
package/dist/cli.cjs CHANGED
@@ -106,7 +106,8 @@ async function extractMetadata(specPath) {
106
106
  };
107
107
  }
108
108
  function toCamelCase(str) {
109
- return str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
109
+ const camel = str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
110
+ return camel.charAt(0).toLowerCase() + camel.slice(1);
110
111
  }
111
112
  function cleanDescription(desc) {
112
113
  if (!desc) return "";
@@ -127,10 +128,13 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
127
128
  if (!await import_fs_extra2.default.pathExists(fullDir)) continue;
128
129
  const files = await import_fs_extra2.default.readdir(fullDir);
129
130
  for (const file of files) {
130
- if ((file.endsWith("Api.ts") || file.endsWith("api.ts")) && !file.endsWith(".test.ts")) {
131
+ const lowerFile = file.toLowerCase();
132
+ const isCodeFile = file.endsWith(".ts") || file.endsWith(".js");
133
+ const isTestFile = lowerFile.endsWith(".test.ts") || lowerFile.endsWith(".spec.ts");
134
+ const isIndexFile = lowerFile === "index.ts" || lowerFile === "index.js";
135
+ if (isCodeFile && !isTestFile && !isIndexFile) {
131
136
  apis.push({
132
- className: file.replace(".ts", ""),
133
- // Simplified
137
+ className: file.replace(/\.[jt]s$/, ""),
134
138
  sourceFile: import_path.default.join(dirName, file)
135
139
  });
136
140
  }
@@ -139,6 +143,11 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
139
143
  if (metadata.operations) {
140
144
  for (const op of metadata.operations) {
141
145
  if (apis.length === 0) continue;
146
+ if (apis.length === 1) {
147
+ op.className = apis[0].className;
148
+ op.sourceFile = apis[0].sourceFile;
149
+ continue;
150
+ }
142
151
  let matchedApi = apis[0];
143
152
  if (op.tags && op.tags.length > 0) {
144
153
  const primaryTag = op.tags[0].toLowerCase();
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  generateDocs
4
- } from "./chunk-QEPXZXK5.js";
4
+ } from "./chunk-4WJ3XNRD.js";
5
5
 
6
6
  // src/cli.ts
7
7
  import { Command } from "commander";
package/dist/index.cjs CHANGED
@@ -115,7 +115,8 @@ async function extractMetadata(specPath) {
115
115
  };
116
116
  }
117
117
  function toCamelCase(str) {
118
- return str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
118
+ const camel = str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
119
+ return camel.charAt(0).toLowerCase() + camel.slice(1);
119
120
  }
120
121
  function cleanDescription(desc) {
121
122
  if (!desc) return "";
@@ -136,10 +137,13 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
136
137
  if (!await import_fs_extra2.default.pathExists(fullDir)) continue;
137
138
  const files = await import_fs_extra2.default.readdir(fullDir);
138
139
  for (const file of files) {
139
- if ((file.endsWith("Api.ts") || file.endsWith("api.ts")) && !file.endsWith(".test.ts")) {
140
+ const lowerFile = file.toLowerCase();
141
+ const isCodeFile = file.endsWith(".ts") || file.endsWith(".js");
142
+ const isTestFile = lowerFile.endsWith(".test.ts") || lowerFile.endsWith(".spec.ts");
143
+ const isIndexFile = lowerFile === "index.ts" || lowerFile === "index.js";
144
+ if (isCodeFile && !isTestFile && !isIndexFile) {
140
145
  apis.push({
141
- className: file.replace(".ts", ""),
142
- // Simplified
146
+ className: file.replace(/\.[jt]s$/, ""),
143
147
  sourceFile: import_path.default.join(dirName, file)
144
148
  });
145
149
  }
@@ -148,6 +152,11 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
148
152
  if (metadata.operations) {
149
153
  for (const op of metadata.operations) {
150
154
  if (apis.length === 0) continue;
155
+ if (apis.length === 1) {
156
+ op.className = apis[0].className;
157
+ op.sourceFile = apis[0].sourceFile;
158
+ continue;
159
+ }
151
160
  let matchedApi = apis[0];
152
161
  if (op.tags && op.tags.length > 0) {
153
162
  const primaryTag = op.tags[0].toLowerCase();
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  generateDocs,
4
4
  renderDocs,
5
5
  scanGeneratedFiles
6
- } from "./chunk-QEPXZXK5.js";
6
+ } from "./chunk-4WJ3XNRD.js";
7
7
  export {
8
8
  extractMetadata,
9
9
  generateDocs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotflash/openapi-semantic-generator",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Semantic mapping automation tool for LLM agents and OpenAPI generated code",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",