@dotflash/openapi-semantic-generator 0.1.2 → 0.1.3

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.
@@ -37,7 +37,9 @@ async function extractMetadata(specPath) {
37
37
  if (typedDetails.requestBody) {
38
38
  }
39
39
  operations.push({
40
- operationId: typedDetails.operationId || `${method}_${path4.replace(/\//g, "_")}`,
40
+ operationId: toCamelCase(
41
+ typedDetails.operationId || `${method}_${path4.replace(/\//g, "_")}`
42
+ ),
41
43
  summary: typedDetails.summary,
42
44
  description: typedDetails.description,
43
45
  httpMethod: method.toUpperCase(),
@@ -65,6 +67,9 @@ async function extractMetadata(specPath) {
65
67
  }))
66
68
  };
67
69
  }
70
+ function toCamelCase(str) {
71
+ return str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
72
+ }
68
73
  function cleanDescription(desc) {
69
74
  if (!desc) return "";
70
75
  return desc.split("\n").filter((line) => {
@@ -99,9 +104,10 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
99
104
  let matchedApi = apis[0];
100
105
  if (op.tags && op.tags.length > 0) {
101
106
  const primaryTag = op.tags[0].toLowerCase();
107
+ const normalizedTag = primaryTag.replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
102
108
  const found = apis.find((api) => {
103
109
  const fileName = api.className.toLowerCase();
104
- return fileName.includes(primaryTag);
110
+ return fileName.includes(normalizedTag) || fileName.includes(primaryTag.replace(/\s+/g, ""));
105
111
  });
106
112
  if (found) {
107
113
  matchedApi = found;
package/dist/cli.cjs CHANGED
@@ -75,7 +75,9 @@ async function extractMetadata(specPath) {
75
75
  if (typedDetails.requestBody) {
76
76
  }
77
77
  operations.push({
78
- operationId: typedDetails.operationId || `${method}_${path5.replace(/\//g, "_")}`,
78
+ operationId: toCamelCase(
79
+ typedDetails.operationId || `${method}_${path5.replace(/\//g, "_")}`
80
+ ),
79
81
  summary: typedDetails.summary,
80
82
  description: typedDetails.description,
81
83
  httpMethod: method.toUpperCase(),
@@ -103,6 +105,9 @@ async function extractMetadata(specPath) {
103
105
  }))
104
106
  };
105
107
  }
108
+ function toCamelCase(str) {
109
+ return str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
110
+ }
106
111
  function cleanDescription(desc) {
107
112
  if (!desc) return "";
108
113
  return desc.split("\n").filter((line) => {
@@ -137,9 +142,10 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
137
142
  let matchedApi = apis[0];
138
143
  if (op.tags && op.tags.length > 0) {
139
144
  const primaryTag = op.tags[0].toLowerCase();
145
+ const normalizedTag = primaryTag.replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
140
146
  const found = apis.find((api) => {
141
147
  const fileName = api.className.toLowerCase();
142
- return fileName.includes(primaryTag);
148
+ return fileName.includes(normalizedTag) || fileName.includes(primaryTag.replace(/\s+/g, ""));
143
149
  });
144
150
  if (found) {
145
151
  matchedApi = found;
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  generateDocs
4
- } from "./chunk-PLFFT6WD.js";
4
+ } from "./chunk-QEPXZXK5.js";
5
5
 
6
6
  // src/cli.ts
7
7
  import { Command } from "commander";
package/dist/index.cjs CHANGED
@@ -84,7 +84,9 @@ async function extractMetadata(specPath) {
84
84
  if (typedDetails.requestBody) {
85
85
  }
86
86
  operations.push({
87
- operationId: typedDetails.operationId || `${method}_${path4.replace(/\//g, "_")}`,
87
+ operationId: toCamelCase(
88
+ typedDetails.operationId || `${method}_${path4.replace(/\//g, "_")}`
89
+ ),
88
90
  summary: typedDetails.summary,
89
91
  description: typedDetails.description,
90
92
  httpMethod: method.toUpperCase(),
@@ -112,6 +114,9 @@ async function extractMetadata(specPath) {
112
114
  }))
113
115
  };
114
116
  }
117
+ function toCamelCase(str) {
118
+ return str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "");
119
+ }
115
120
  function cleanDescription(desc) {
116
121
  if (!desc) return "";
117
122
  return desc.split("\n").filter((line) => {
@@ -146,9 +151,10 @@ async function scanGeneratedFiles(outputDir, metadata, options = {}) {
146
151
  let matchedApi = apis[0];
147
152
  if (op.tags && op.tags.length > 0) {
148
153
  const primaryTag = op.tags[0].toLowerCase();
154
+ const normalizedTag = primaryTag.replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
149
155
  const found = apis.find((api) => {
150
156
  const fileName = api.className.toLowerCase();
151
- return fileName.includes(primaryTag);
157
+ return fileName.includes(normalizedTag) || fileName.includes(primaryTag.replace(/\s+/g, ""));
152
158
  });
153
159
  if (found) {
154
160
  matchedApi = found;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  generateDocs,
4
4
  renderDocs,
5
5
  scanGeneratedFiles
6
- } from "./chunk-PLFFT6WD.js";
6
+ } from "./chunk-QEPXZXK5.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.2",
3
+ "version": "0.1.3",
4
4
  "description": "Semantic mapping automation tool for LLM agents and OpenAPI generated code",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",