@visulima/jsdoc-open-api 3.0.0-alpha.7 → 3.0.0-alpha.9

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.
Files changed (25) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cli/commander/index.cjs +1 -1
  3. package/dist/cli/commander/index.mjs +1 -1
  4. package/dist/cli/index.cjs +1 -1
  5. package/dist/cli/index.mjs +1 -1
  6. package/dist/index.cjs +5 -5
  7. package/dist/index.mjs +5 -5
  8. package/dist/packem_shared/{SwaggerCompilerPlugin-BHbHAPK-.cjs → SwaggerCompilerPlugin-BkYJzU4f.cjs} +7 -7
  9. package/dist/packem_shared/{SwaggerCompilerPlugin-BEbFO9Dt.mjs → SwaggerCompilerPlugin-DZ7tIJ8x.mjs} +7 -7
  10. package/dist/packem_shared/{generateCommand-B1t3VSDX.mjs → generateCommand-DRMkfIle.mjs} +1 -1
  11. package/dist/packem_shared/{generateCommand-Cu0UQUh8.cjs → generateCommand-MwnCNgEE.cjs} +8 -11
  12. package/dist/packem_shared/{generateCommand-CmyavGTZ.cjs → generateCommand-RY4QFtm7.cjs} +1 -1
  13. package/dist/packem_shared/{generateCommand-CZEFuXr9.mjs → generateCommand-a9_RAbug.mjs} +8 -11
  14. package/dist/packem_shared/{jsDocumentCommentsToOpenApi-C8kxIQH2.cjs → jsDocumentCommentsToOpenApi-C7yMeXJ5.cjs} +9 -6
  15. package/dist/packem_shared/{jsDocumentCommentsToOpenApi-eOlxMuMO.mjs → jsDocumentCommentsToOpenApi-DtrIZ2lK.mjs} +9 -6
  16. package/dist/packem_shared/{parseFile-Bxis7tbW.mjs → parseFile-BE-sKiRK.mjs} +1 -1
  17. package/dist/packem_shared/{parseFile-BJwu_na4.cjs → parseFile-Dk7Bw7lt.cjs} +1 -1
  18. package/dist/packem_shared/{swaggerJsDocumentCommentsToOpenApi-Cb5s1J29.mjs → swaggerJsDocumentCommentsToOpenApi-B7g9rVr5.mjs} +13 -12
  19. package/dist/packem_shared/{swaggerJsDocumentCommentsToOpenApi-JFymRz50.cjs → swaggerJsDocumentCommentsToOpenApi-BuB7eE94.cjs} +13 -12
  20. package/dist/packem_shared/{yamlLoc-Cmx4vbRt.mjs → yamlLoc-C7iHWvdq.mjs} +4 -2
  21. package/dist/packem_shared/{yamlLoc-BLoIYoXs.cjs → yamlLoc-CEvBiR4K.cjs} +4 -2
  22. package/dist/swagger-jsdoc/utils.d.cts +3 -2
  23. package/dist/swagger-jsdoc/utils.d.mts +3 -2
  24. package/dist/swagger-jsdoc/utils.d.ts +3 -2
  25. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,3 +1,35 @@
1
+ ## @visulima/jsdoc-open-api [3.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/jsdoc-open-api@3.0.0-alpha.8...@visulima/jsdoc-open-api@3.0.0-alpha.9) (2026-04-21)
2
+
3
+ ### Miscellaneous Chores
4
+
5
+ * update the jsr.json ([864ab7e](https://github.com/visulima/visulima/commit/864ab7e71c4b5ae82f64792d1ae8debfea2c539b))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.10
11
+
12
+ ## @visulima/jsdoc-open-api [3.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/jsdoc-open-api@3.0.0-alpha.7...@visulima/jsdoc-open-api@3.0.0-alpha.8) (2026-04-21)
13
+
14
+ ### Bug Fixes
15
+
16
+ * **api:** resolve eslint and type-safety issues across api packages ([3601491](https://github.com/visulima/visulima/commit/3601491261de56b5cfad87c97daafd458e4ee3b6))
17
+ * **jsdoc-open-api:** drop redundant String() conversion in init-command ([1b2384e](https://github.com/visulima/visulima/commit/1b2384e917687beaf464e18e24595c7d4214c94e))
18
+ * **jsdoc-open-api:** relax type overrides for parser code, preserve JSON roundtrip for undefined stripping ([be896e2](https://github.com/visulima/visulima/commit/be896e2e724396bcb74fbbd3161d29213a9984d6))
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * bump engines.node to ^22.14.0 || >=24.10.0 ([c3d0931](https://github.com/visulima/visulima/commit/c3d0931d1504e4f21ebf50ea680cfa7ce4ba15ce))
23
+ * fixed jsr.json ([5d85e51](https://github.com/visulima/visulima/commit/5d85e5179de38e284ec433b14d77c71a1619c8d6))
24
+ * **jsdoc-open-api:** apply formatter updates ([57231bd](https://github.com/visulima/visulima/commit/57231bd235fa16768802306aa6e906a4558c579c))
25
+ * **jsdoc-open-api:** apply pending lint and source updates ([0669fd3](https://github.com/visulima/visulima/commit/0669fd3d46ad0787ef6709cc8cad67b7ff7495f7))
26
+ * **jsdoc-open-api:** enforce curly braces and apply lint fixes ([606641f](https://github.com/visulima/visulima/commit/606641f7a29eaa5707ae27c57ed02a91adf950b5))
27
+
28
+
29
+ ### Dependencies
30
+
31
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.9
32
+
1
33
  ## @visulima/jsdoc-open-api [3.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/jsdoc-open-api@3.0.0-alpha.6...@visulima/jsdoc-open-api@3.0.0-alpha.7) (2026-04-08)
2
34
 
3
35
  ### Miscellaneous Chores
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const generateCommand = require('../../packem_shared/generateCommand-CmyavGTZ.cjs');
5
+ const generateCommand = require('../../packem_shared/generateCommand-RY4QFtm7.cjs');
6
6
  const initCommand = require('../../packem_shared/initCommand-D3yVEMwO.cjs');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { default as generateCommand } from '../../packem_shared/generateCommand-B1t3VSDX.mjs';
1
+ export { default as generateCommand } from '../../packem_shared/generateCommand-DRMkfIle.mjs';
2
2
  export { default as initCommand } from '../../packem_shared/initCommand-B6Z9EXHP.mjs';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const generateCommand = require('../packem_shared/generateCommand-Cu0UQUh8.cjs');
5
+ const generateCommand = require('../packem_shared/generateCommand-MwnCNgEE.cjs');
6
6
  const initCommand = require('../packem_shared/initCommand-Ch-72dKZ.cjs');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { default as generateCommand } from '../packem_shared/generateCommand-CZEFuXr9.mjs';
1
+ export { default as generateCommand } from '../packem_shared/generateCommand-a9_RAbug.mjs';
2
2
  export { default as initCommand } from '../packem_shared/initCommand-zE4VRDGW.mjs';
package/dist/index.cjs CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const jsDocumentCommentsToOpenApi = require('./packem_shared/jsDocumentCommentsToOpenApi-C8kxIQH2.cjs');
6
- const parseFile = require('./packem_shared/parseFile-BJwu_na4.cjs');
5
+ const jsDocumentCommentsToOpenApi = require('./packem_shared/jsDocumentCommentsToOpenApi-C7yMeXJ5.cjs');
6
+ const parseFile = require('./packem_shared/parseFile-Dk7Bw7lt.cjs');
7
7
  const SpecBuilder = require('./packem_shared/SpecBuilder-CCESkmm5.cjs');
8
- const swaggerJsDocumentCommentsToOpenApi = require('./packem_shared/swaggerJsDocumentCommentsToOpenApi-JFymRz50.cjs');
9
- const yamlLoc = require('./packem_shared/yamlLoc-BLoIYoXs.cjs');
10
- const SwaggerCompilerPlugin = require('./packem_shared/SwaggerCompilerPlugin-BHbHAPK-.cjs');
8
+ const swaggerJsDocumentCommentsToOpenApi = require('./packem_shared/swaggerJsDocumentCommentsToOpenApi-BuB7eE94.cjs');
9
+ const yamlLoc = require('./packem_shared/yamlLoc-CEvBiR4K.cjs');
10
+ const SwaggerCompilerPlugin = require('./packem_shared/SwaggerCompilerPlugin-BkYJzU4f.cjs');
11
11
 
12
12
 
13
13
 
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- export { default as jsDocumentCommentsToOpenApi } from './packem_shared/jsDocumentCommentsToOpenApi-eOlxMuMO.mjs';
2
- export { default as parseFile } from './packem_shared/parseFile-Bxis7tbW.mjs';
1
+ export { default as jsDocumentCommentsToOpenApi } from './packem_shared/jsDocumentCommentsToOpenApi-DtrIZ2lK.mjs';
2
+ export { default as parseFile } from './packem_shared/parseFile-BE-sKiRK.mjs';
3
3
  export { default as SpecBuilder } from './packem_shared/SpecBuilder-B7YiF7zR.mjs';
4
- export { default as swaggerJsDocumentCommentsToOpenApi } from './packem_shared/swaggerJsDocumentCommentsToOpenApi-Cb5s1J29.mjs';
5
- export { default as yamlLoc } from './packem_shared/yamlLoc-Cmx4vbRt.mjs';
6
- export { default as SwaggerCompilerPlugin } from './packem_shared/SwaggerCompilerPlugin-BEbFO9Dt.mjs';
4
+ export { default as swaggerJsDocumentCommentsToOpenApi } from './packem_shared/swaggerJsDocumentCommentsToOpenApi-B7g9rVr5.mjs';
5
+ export { default as yamlLoc } from './packem_shared/yamlLoc-C7iHWvdq.mjs';
6
+ export { default as SwaggerCompilerPlugin } from './packem_shared/SwaggerCompilerPlugin-DZ7tIJ8x.mjs';
@@ -5,10 +5,10 @@ const path = require('node:path');
5
5
  const node_process = require('node:process');
6
6
  const fs = require('@visulima/fs');
7
7
  const validate = require('./validate-FKieC3ln.cjs');
8
- const jsDocumentCommentsToOpenApi = require('./jsDocumentCommentsToOpenApi-C8kxIQH2.cjs');
9
- const parseFile = require('./parseFile-BJwu_na4.cjs');
8
+ const jsDocumentCommentsToOpenApi = require('./jsDocumentCommentsToOpenApi-C7yMeXJ5.cjs');
9
+ const parseFile = require('./parseFile-Dk7Bw7lt.cjs');
10
10
  const SpecBuilder = require('./SpecBuilder-CCESkmm5.cjs');
11
- const swaggerJsDocumentCommentsToOpenApi = require('./swaggerJsDocumentCommentsToOpenApi-JFymRz50.cjs');
11
+ const swaggerJsDocumentCommentsToOpenApi = require('./swaggerJsDocumentCommentsToOpenApi-BuB7eE94.cjs');
12
12
 
13
13
  const errorHandler = (error) => {
14
14
  if (error) {
@@ -34,7 +34,7 @@ class SwaggerCompilerPlugin {
34
34
  compiler.hooks.make.tapAsync("SwaggerCompilerPlugin", async (_, callback) => {
35
35
  console.log("Build paused, switching to swagger build");
36
36
  const spec = new SpecBuilder(this.swaggerDefinition);
37
- for await (const dir of this.sources) {
37
+ for (const dir of this.sources) {
38
38
  const files = await fs.collect(dir, {
39
39
  extensions: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".yaml", ".yml"],
40
40
  includeDirs: false,
@@ -62,9 +62,9 @@ class SwaggerCompilerPlugin {
62
62
  try {
63
63
  if (this.verbose) {
64
64
  console.log("Validating swagger spec");
65
- console.log(JSON.stringify(spec, null, 2));
65
+ console.log(JSON.stringify(spec, void 0, 2));
66
66
  }
67
- await validate.validate(JSON.parse(JSON.stringify(spec)));
67
+ await validate.validate(structuredClone(spec));
68
68
  } catch (error) {
69
69
  console.error(error.toJSON());
70
70
  node_process.exit(1);
@@ -74,7 +74,7 @@ class SwaggerCompilerPlugin {
74
74
  if (error) {
75
75
  errorHandler(error);
76
76
  }
77
- node_fs.writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);
77
+ node_fs.writeFile(assetsPath, JSON.stringify(spec, void 0, 2), errorHandler);
78
78
  });
79
79
  if (this.verbose) {
80
80
  console.log(`Written swagger spec to "${this.assetsPath}" file`);
@@ -3,10 +3,10 @@ import { dirname } from 'node:path';
3
3
  import { exit } from 'node:process';
4
4
  import { collect } from '@visulima/fs';
5
5
  import { v as validate, D as DEFAULT_EXCLUDE } from './validate-DZHaKH07.mjs';
6
- import commentsToOpenApi from './jsDocumentCommentsToOpenApi-eOlxMuMO.mjs';
7
- import parseFile from './parseFile-Bxis7tbW.mjs';
6
+ import commentsToOpenApi from './jsDocumentCommentsToOpenApi-DtrIZ2lK.mjs';
7
+ import parseFile from './parseFile-BE-sKiRK.mjs';
8
8
  import SpecBuilder from './SpecBuilder-B7YiF7zR.mjs';
9
- import commentsToOpenApi$1 from './swaggerJsDocumentCommentsToOpenApi-Cb5s1J29.mjs';
9
+ import commentsToOpenApi$1 from './swaggerJsDocumentCommentsToOpenApi-B7g9rVr5.mjs';
10
10
 
11
11
  const errorHandler = (error) => {
12
12
  if (error) {
@@ -32,7 +32,7 @@ class SwaggerCompilerPlugin {
32
32
  compiler.hooks.make.tapAsync("SwaggerCompilerPlugin", async (_, callback) => {
33
33
  console.log("Build paused, switching to swagger build");
34
34
  const spec = new SpecBuilder(this.swaggerDefinition);
35
- for await (const dir of this.sources) {
35
+ for (const dir of this.sources) {
36
36
  const files = await collect(dir, {
37
37
  extensions: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".yaml", ".yml"],
38
38
  includeDirs: false,
@@ -60,9 +60,9 @@ class SwaggerCompilerPlugin {
60
60
  try {
61
61
  if (this.verbose) {
62
62
  console.log("Validating swagger spec");
63
- console.log(JSON.stringify(spec, null, 2));
63
+ console.log(JSON.stringify(spec, void 0, 2));
64
64
  }
65
- await validate(JSON.parse(JSON.stringify(spec)));
65
+ await validate(structuredClone(spec));
66
66
  } catch (error) {
67
67
  console.error(error.toJSON());
68
68
  exit(1);
@@ -72,7 +72,7 @@ class SwaggerCompilerPlugin {
72
72
  if (error) {
73
73
  errorHandler(error);
74
74
  }
75
- writeFile(assetsPath, JSON.stringify(spec, null, 2), errorHandler);
75
+ writeFile(assetsPath, JSON.stringify(spec, void 0, 2), errorHandler);
76
76
  });
77
77
  if (this.verbose) {
78
78
  console.log(`Written swagger spec to "${this.assetsPath}" file`);
@@ -1,5 +1,5 @@
1
1
  import { exit } from 'node:process';
2
- import generateCommand$1 from './generateCommand-CZEFuXr9.mjs';
2
+ import generateCommand$1 from './generateCommand-a9_RAbug.mjs';
3
3
 
4
4
  const generateCommand = (program, commandName = "generate", configName = ".openapirc.js") => {
5
5
  program.command(commandName).description("Generates OpenAPI (Swagger) documentation from JSDoc's").usage("[options] <path ...>").argument("[path ...]", "Paths to files or directories to parse").option("-c, --config [.openapirc.js]", "@visulima/jsdoc-open-api config file path.").option("-o, --output [swaggerSpec.json]", "Output swagger specification.").option("-v, --verbose", "Verbose output.").option("-d, --very-verbose", "Very verbose output.").action(async (paths, options) => {
@@ -6,16 +6,13 @@ const node_url = require('node:url');
6
6
  const fs = require('@visulima/fs');
7
7
  const cliProgress = require('cli-progress');
8
8
  const validate = require('./validate-FKieC3ln.cjs');
9
- const jsDocumentCommentsToOpenApi = require('./jsDocumentCommentsToOpenApi-C8kxIQH2.cjs');
10
- const parseFile = require('./parseFile-BJwu_na4.cjs');
9
+ const jsDocumentCommentsToOpenApi = require('./jsDocumentCommentsToOpenApi-C7yMeXJ5.cjs');
10
+ const parseFile = require('./parseFile-Dk7Bw7lt.cjs');
11
11
  const SpecBuilder = require('./SpecBuilder-CCESkmm5.cjs');
12
- const swaggerJsDocumentCommentsToOpenApi = require('./swaggerJsDocumentCommentsToOpenApi-JFymRz50.cjs');
12
+ const swaggerJsDocumentCommentsToOpenApi = require('./swaggerJsDocumentCommentsToOpenApi-BuB7eE94.cjs');
13
13
 
14
14
  const generateCommand = async (configName, paths, options) => {
15
- let openapiConfig = {
16
- exclude: [],
17
- swaggerDefinition: {}
18
- };
15
+ let openapiConfig;
19
16
  try {
20
17
  let config = await import(node_url.pathToFileURL(path.normalize(options.config ?? configName)).href);
21
18
  if (config?.default) {
@@ -36,7 +33,7 @@ const generateCommand = async (configName, paths, options) => {
36
33
  );
37
34
  const spec = new SpecBuilder(openapiConfig.swaggerDefinition);
38
35
  const skip = /* @__PURE__ */ new Set([...validate.DEFAULT_EXCLUDE, ...openapiConfig.exclude]);
39
- for await (const dir of paths) {
36
+ for (const dir of paths) {
40
37
  (await promises.lstat(dir)).isDirectory();
41
38
  const realDirectory = await promises.realpath(dir);
42
39
  const files = await fs.collect(realDirectory, {
@@ -68,16 +65,16 @@ Found ${String(files.length)} files in ${realDirectory}`);
68
65
  console.log("Validating swagger spec");
69
66
  }
70
67
  if (options.veryVerbose) {
71
- console.log(JSON.stringify(spec, null, 2));
68
+ console.log(JSON.stringify(spec, void 0, 2));
72
69
  }
73
- await validate.validate(JSON.parse(JSON.stringify(spec)));
70
+ await validate.validate(structuredClone(spec));
74
71
  const output = options.output ?? "swagger.json";
75
72
  multibar.stop();
76
73
  if (options.verbose) {
77
74
  console.log(`Written swagger spec to "${output}" file`);
78
75
  }
79
76
  await promises.mkdir(path.dirname(output), { recursive: true });
80
- await promises.writeFile(output, JSON.stringify(spec, null, 2));
77
+ await promises.writeFile(output, JSON.stringify(spec, void 0, 2));
81
78
  console.log(`
82
79
  Swagger specification is ready, check the "${output}" file.`);
83
80
  };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const node_process = require('node:process');
4
- const generateCommand$1 = require('./generateCommand-Cu0UQUh8.cjs');
4
+ const generateCommand$1 = require('./generateCommand-MwnCNgEE.cjs');
5
5
 
6
6
  const generateCommand = (program, commandName = "generate", configName = ".openapirc.js") => {
7
7
  program.command(commandName).description("Generates OpenAPI (Swagger) documentation from JSDoc's").usage("[options] <path ...>").argument("[path ...]", "Paths to files or directories to parse").option("-c, --config [.openapirc.js]", "@visulima/jsdoc-open-api config file path.").option("-o, --output [swaggerSpec.json]", "Output swagger specification.").option("-v, --verbose", "Verbose output.").option("-d, --very-verbose", "Very verbose output.").action(async (paths, options) => {
@@ -4,16 +4,13 @@ import { pathToFileURL } from 'node:url';
4
4
  import { collect } from '@visulima/fs';
5
5
  import { MultiBar, Presets } from 'cli-progress';
6
6
  import { v as validate, D as DEFAULT_EXCLUDE } from './validate-DZHaKH07.mjs';
7
- import commentsToOpenApi from './jsDocumentCommentsToOpenApi-eOlxMuMO.mjs';
8
- import parseFile from './parseFile-Bxis7tbW.mjs';
7
+ import commentsToOpenApi from './jsDocumentCommentsToOpenApi-DtrIZ2lK.mjs';
8
+ import parseFile from './parseFile-BE-sKiRK.mjs';
9
9
  import SpecBuilder from './SpecBuilder-B7YiF7zR.mjs';
10
- import commentsToOpenApi$1 from './swaggerJsDocumentCommentsToOpenApi-Cb5s1J29.mjs';
10
+ import commentsToOpenApi$1 from './swaggerJsDocumentCommentsToOpenApi-B7g9rVr5.mjs';
11
11
 
12
12
  const generateCommand = async (configName, paths, options) => {
13
- let openapiConfig = {
14
- exclude: [],
15
- swaggerDefinition: {}
16
- };
13
+ let openapiConfig;
17
14
  try {
18
15
  let config = await import(pathToFileURL(normalize(options.config ?? configName)).href);
19
16
  if (config?.default) {
@@ -34,7 +31,7 @@ const generateCommand = async (configName, paths, options) => {
34
31
  );
35
32
  const spec = new SpecBuilder(openapiConfig.swaggerDefinition);
36
33
  const skip = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE, ...openapiConfig.exclude]);
37
- for await (const dir of paths) {
34
+ for (const dir of paths) {
38
35
  (await lstat(dir)).isDirectory();
39
36
  const realDirectory = await realpath(dir);
40
37
  const files = await collect(realDirectory, {
@@ -66,16 +63,16 @@ Found ${String(files.length)} files in ${realDirectory}`);
66
63
  console.log("Validating swagger spec");
67
64
  }
68
65
  if (options.veryVerbose) {
69
- console.log(JSON.stringify(spec, null, 2));
66
+ console.log(JSON.stringify(spec, void 0, 2));
70
67
  }
71
- await validate(JSON.parse(JSON.stringify(spec)));
68
+ await validate(structuredClone(spec));
72
69
  const output = options.output ?? "swagger.json";
73
70
  multibar.stop();
74
71
  if (options.verbose) {
75
72
  console.log(`Written swagger spec to "${output}" file`);
76
73
  }
77
74
  await mkdir(dirname(output), { recursive: true });
78
- await writeFile(output, JSON.stringify(spec, null, 2));
75
+ await writeFile(output, JSON.stringify(spec, void 0, 2));
79
76
  console.log(`
80
77
  Swagger specification is ready, check the "${output}" file.`);
81
78
  };
@@ -8,6 +8,10 @@ const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e
8
8
 
9
9
  const mergeWith__default = /*#__PURE__*/_interopDefaultCompat(mergeWith);
10
10
 
11
+ const ARRAY_SUFFIX_REGEX = /\[\]$/;
12
+ const DESCRIPTION_DASH_REGEX = /^- /u;
13
+ const PARAM_SUFFIX_REGEX = /Param$/u;
14
+ const OPEN_API_REGEX = /^(GET|PUT|POST|DELETE|OPTIONS|HEAD|PATCH|TRACE) \/.*$/;
11
15
  const fixSecurityObject = (thing) => {
12
16
  if (thing.security) {
13
17
  thing.security = Object.keys(thing.security).map((s) => {
@@ -32,7 +36,7 @@ const formatMap = {
32
36
  const parseDescription = (tag) => {
33
37
  const rawType = tag.type;
34
38
  const isArray = rawType.endsWith("[]");
35
- const parsedType = rawType.replace(/\[]$/, "");
39
+ const parsedType = rawType.replace(ARRAY_SUFFIX_REGEX, "");
36
40
  const isPrimitive = primitiveTypes.has(parsedType);
37
41
  const isFormat = Object.keys(formatMap).includes(parsedType);
38
42
  let defaultValue;
@@ -79,7 +83,7 @@ const parseDescription = (tag) => {
79
83
  if (parsedType === "") {
80
84
  schema = void 0;
81
85
  }
82
- let description = tag.description.trim().replace(/^- /u, "");
86
+ let description = tag.description.trim().replace(DESCRIPTION_DASH_REGEX, "");
83
87
  if (description === "") {
84
88
  description = void 0;
85
89
  }
@@ -91,7 +95,7 @@ const parseDescription = (tag) => {
91
95
  schema
92
96
  };
93
97
  };
94
- const tagsToObjects = (tags, verbose) => tags.map((tag) => {
98
+ const tagsToObjects = (tags, _verbose) => tags.map((tag) => {
95
99
  const parsedResponse = parseDescription(tag);
96
100
  let nameAndDescription = "";
97
101
  if (parsedResponse.name) {
@@ -158,7 +162,7 @@ const tagsToObjects = (tags, verbose) => tags.map((tag) => {
158
162
  parameters: [
159
163
  {
160
164
  description: parsedResponse.description,
161
- in: tag.tag.replace(/Param$/u, ""),
165
+ in: tag.tag.replace(PARAM_SUFFIX_REGEX, ""),
162
166
  name: parsedResponse.name,
163
167
  required: parsedResponse.required,
164
168
  schema: parsedResponse.schema
@@ -309,9 +313,8 @@ const tagsToObjects = (tags, verbose) => tags.map((tag) => {
309
313
  }
310
314
  });
311
315
  const commentsToOpenApi = (fileContents, verbose) => {
312
- const openAPIRegex = /^(GET|PUT|POST|DELETE|OPTIONS|HEAD|PATCH|TRACE) \/.*$/;
313
316
  const jsDocumentComments = commentParser.parse(fileContents, { spacing: "preserve" });
314
- return jsDocumentComments.filter((comment) => openAPIRegex.test(comment.description.trim())).map((comment) => {
317
+ return jsDocumentComments.filter((comment) => OPEN_API_REGEX.test(comment.description.trim())).map((comment) => {
315
318
  const loc = comment.tags.length + 1;
316
319
  const result = mergeWith__default({}, ...tagsToObjects(comment.tags), customizer.customizer);
317
320
  fixSecurityObject(result);
@@ -2,6 +2,10 @@ import { parse } from 'comment-parser';
2
2
  import mergeWith from 'lodash.mergewith';
3
3
  import { c as customizer } from './customizer-CoMXMU7a.mjs';
4
4
 
5
+ const ARRAY_SUFFIX_REGEX = /\[\]$/;
6
+ const DESCRIPTION_DASH_REGEX = /^- /u;
7
+ const PARAM_SUFFIX_REGEX = /Param$/u;
8
+ const OPEN_API_REGEX = /^(GET|PUT|POST|DELETE|OPTIONS|HEAD|PATCH|TRACE) \/.*$/;
5
9
  const fixSecurityObject = (thing) => {
6
10
  if (thing.security) {
7
11
  thing.security = Object.keys(thing.security).map((s) => {
@@ -26,7 +30,7 @@ const formatMap = {
26
30
  const parseDescription = (tag) => {
27
31
  const rawType = tag.type;
28
32
  const isArray = rawType.endsWith("[]");
29
- const parsedType = rawType.replace(/\[]$/, "");
33
+ const parsedType = rawType.replace(ARRAY_SUFFIX_REGEX, "");
30
34
  const isPrimitive = primitiveTypes.has(parsedType);
31
35
  const isFormat = Object.keys(formatMap).includes(parsedType);
32
36
  let defaultValue;
@@ -73,7 +77,7 @@ const parseDescription = (tag) => {
73
77
  if (parsedType === "") {
74
78
  schema = void 0;
75
79
  }
76
- let description = tag.description.trim().replace(/^- /u, "");
80
+ let description = tag.description.trim().replace(DESCRIPTION_DASH_REGEX, "");
77
81
  if (description === "") {
78
82
  description = void 0;
79
83
  }
@@ -85,7 +89,7 @@ const parseDescription = (tag) => {
85
89
  schema
86
90
  };
87
91
  };
88
- const tagsToObjects = (tags, verbose) => tags.map((tag) => {
92
+ const tagsToObjects = (tags, _verbose) => tags.map((tag) => {
89
93
  const parsedResponse = parseDescription(tag);
90
94
  let nameAndDescription = "";
91
95
  if (parsedResponse.name) {
@@ -152,7 +156,7 @@ const tagsToObjects = (tags, verbose) => tags.map((tag) => {
152
156
  parameters: [
153
157
  {
154
158
  description: parsedResponse.description,
155
- in: tag.tag.replace(/Param$/u, ""),
159
+ in: tag.tag.replace(PARAM_SUFFIX_REGEX, ""),
156
160
  name: parsedResponse.name,
157
161
  required: parsedResponse.required,
158
162
  schema: parsedResponse.schema
@@ -303,9 +307,8 @@ const tagsToObjects = (tags, verbose) => tags.map((tag) => {
303
307
  }
304
308
  });
305
309
  const commentsToOpenApi = (fileContents, verbose) => {
306
- const openAPIRegex = /^(GET|PUT|POST|DELETE|OPTIONS|HEAD|PATCH|TRACE) \/.*$/;
307
310
  const jsDocumentComments = parse(fileContents, { spacing: "preserve" });
308
- return jsDocumentComments.filter((comment) => openAPIRegex.test(comment.description.trim())).map((comment) => {
311
+ return jsDocumentComments.filter((comment) => OPEN_API_REGEX.test(comment.description.trim())).map((comment) => {
309
312
  const loc = comment.tags.length + 1;
310
313
  const result = mergeWith({}, ...tagsToObjects(comment.tags), customizer);
311
314
  fixSecurityObject(result);
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import yaml from 'yaml';
4
- import yamlLoc from './yamlLoc-Cmx4vbRt.mjs';
4
+ import yamlLoc from './yamlLoc-C7iHWvdq.mjs';
5
5
 
6
6
  const ALLOWED_KEYS = /* @__PURE__ */ new Set(["components", "externalDocs", "info", "openapi", "paths", "security", "servers", "tags"]);
7
7
  class ParseError extends Error {
@@ -3,7 +3,7 @@
3
3
  const node_fs = require('node:fs');
4
4
  const path = require('node:path');
5
5
  const yaml = require('yaml');
6
- const yamlLoc = require('./yamlLoc-BLoIYoXs.cjs');
6
+ const yamlLoc = require('./yamlLoc-CEvBiR4K.cjs');
7
7
 
8
8
  const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
9
9
 
@@ -3,7 +3,12 @@ import mergeWith from 'lodash.mergewith';
3
3
  import yaml from 'yaml';
4
4
  import { c as customizer } from './customizer-CoMXMU7a.mjs';
5
5
 
6
- const mergeDeep = (first, second) => mergeWith({}, first, second, (a, b) => b === null ? a : void 0);
6
+ const mergeDeep = (first, second) => mergeWith({}, first, second, (a, b) => {
7
+ if (b === null) {
8
+ return a;
9
+ }
10
+ return void 0;
11
+ });
7
12
  const hasEmptyProperty = (object) => Object.keys(object).map((key) => object[key]).every((keyObject) => typeof keyObject === "object" && Object.keys(keyObject).every((key) => !(key in keyObject)));
8
13
  const isTagPresentInTags = (tag, tags) => tags.some((targetTag) => tag.name === targetTag.name);
9
14
  const getSwaggerVersionFromSpec = (tag) => {
@@ -71,28 +76,24 @@ const specificationTemplate = {
71
76
  v4: ["components", "channels"]
72
77
  };
73
78
  const tagsToObjects = (specs, verbose) => specs.map((spec) => {
74
- const hasContent = spec.description !== "" || spec.name !== void 0 && (spec.name.startsWith("/") || spec.name.endsWith(":"));
79
+ const hasContent = spec.description !== "" || spec.name.startsWith("/") || spec.name.endsWith(":");
75
80
  if ((spec.tag === "openapi" || spec.tag === "swagger" || spec.tag === "asyncapi") && hasContent) {
76
81
  let yamlContent = spec.description;
77
- if (spec.name !== void 0 && (spec.name.startsWith("/") || spec.name.endsWith(":"))) {
82
+ if (spec.name.startsWith("/") || spec.name.endsWith(":")) {
78
83
  yamlContent = yamlContent.trim() === "" ? spec.name : `${spec.name}
79
84
  ${yamlContent}`;
80
85
  }
81
86
  const parsed = yaml.parseDocument(yamlContent);
82
87
  if (parsed.errors.length > 0) {
83
- parsed.errors.map((error) => {
84
- const newError = error;
85
- newError.annotation = yamlContent;
86
- return newError;
88
+ parsed.errors.forEach((error) => {
89
+ error.annotation = yamlContent;
87
90
  });
88
91
  let errorString = "Error parsing YAML in @openapi spec:";
89
- errorString += verbose ? parsed.errors.map(
90
- (error) => `${error.toString()}
92
+ errorString += verbose ? parsed.errors.map((error) => `${error.toString()}
91
93
  Imbedded within:
92
94
  \`\`\`
93
95
  ${error.annotation?.replaceAll("\n", "\n ")}
94
- \`\`\``
95
- ).join("\n") : parsed.errors.map((error) => error.toString()).join("\n");
96
+ \`\`\``).join("\n") : parsed.errors.map((error) => error.toString()).join("\n");
96
97
  throw new Error(errorString);
97
98
  }
98
99
  const parsedDocument = parsed.toJSON();
@@ -100,7 +101,7 @@ Imbedded within:
100
101
  tags: []
101
102
  };
102
103
  specificationTemplate[getSwaggerVersionFromSpec(spec)].forEach((property) => {
103
- specification[property] = specification[property] || {};
104
+ specification[property] = specification[property] ?? {};
104
105
  });
105
106
  Object.keys(parsedDocument).forEach((property) => {
106
107
  organizeSwaggerObject(specification, parsedDocument, property);
@@ -10,7 +10,12 @@ const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e
10
10
  const mergeWith__default = /*#__PURE__*/_interopDefaultCompat(mergeWith);
11
11
  const yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
12
12
 
13
- const mergeDeep = (first, second) => mergeWith__default({}, first, second, (a, b) => b === null ? a : void 0);
13
+ const mergeDeep = (first, second) => mergeWith__default({}, first, second, (a, b) => {
14
+ if (b === null) {
15
+ return a;
16
+ }
17
+ return void 0;
18
+ });
14
19
  const hasEmptyProperty = (object) => Object.keys(object).map((key) => object[key]).every((keyObject) => typeof keyObject === "object" && Object.keys(keyObject).every((key) => !(key in keyObject)));
15
20
  const isTagPresentInTags = (tag, tags) => tags.some((targetTag) => tag.name === targetTag.name);
16
21
  const getSwaggerVersionFromSpec = (tag) => {
@@ -78,28 +83,24 @@ const specificationTemplate = {
78
83
  v4: ["components", "channels"]
79
84
  };
80
85
  const tagsToObjects = (specs, verbose) => specs.map((spec) => {
81
- const hasContent = spec.description !== "" || spec.name !== void 0 && (spec.name.startsWith("/") || spec.name.endsWith(":"));
86
+ const hasContent = spec.description !== "" || spec.name.startsWith("/") || spec.name.endsWith(":");
82
87
  if ((spec.tag === "openapi" || spec.tag === "swagger" || spec.tag === "asyncapi") && hasContent) {
83
88
  let yamlContent = spec.description;
84
- if (spec.name !== void 0 && (spec.name.startsWith("/") || spec.name.endsWith(":"))) {
89
+ if (spec.name.startsWith("/") || spec.name.endsWith(":")) {
85
90
  yamlContent = yamlContent.trim() === "" ? spec.name : `${spec.name}
86
91
  ${yamlContent}`;
87
92
  }
88
93
  const parsed = yaml__default.parseDocument(yamlContent);
89
94
  if (parsed.errors.length > 0) {
90
- parsed.errors.map((error) => {
91
- const newError = error;
92
- newError.annotation = yamlContent;
93
- return newError;
95
+ parsed.errors.forEach((error) => {
96
+ error.annotation = yamlContent;
94
97
  });
95
98
  let errorString = "Error parsing YAML in @openapi spec:";
96
- errorString += verbose ? parsed.errors.map(
97
- (error) => `${error.toString()}
99
+ errorString += verbose ? parsed.errors.map((error) => `${error.toString()}
98
100
  Imbedded within:
99
101
  \`\`\`
100
102
  ${error.annotation?.replaceAll("\n", "\n ")}
101
- \`\`\``
102
- ).join("\n") : parsed.errors.map((error) => error.toString()).join("\n");
103
+ \`\`\``).join("\n") : parsed.errors.map((error) => error.toString()).join("\n");
103
104
  throw new Error(errorString);
104
105
  }
105
106
  const parsedDocument = parsed.toJSON();
@@ -107,7 +108,7 @@ Imbedded within:
107
108
  tags: []
108
109
  };
109
110
  specificationTemplate[getSwaggerVersionFromSpec(spec)].forEach((property) => {
110
- specification[property] = specification[property] || {};
111
+ specification[property] = specification[property] ?? {};
111
112
  });
112
113
  Object.keys(parsedDocument).forEach((property) => {
113
114
  organizeSwaggerObject(specification, parsedDocument, property);
@@ -1,7 +1,9 @@
1
+ const LINE_SPLIT_REGEX = /\r\n|\r|\n/u;
2
+ const COMMENT_OR_EMPTY_REGEX = /^\s*(#\s*(?:\S.*)?)?$/u;
1
3
  const yamlLoc = (string) => {
2
- const split = string.split(/\r\n|\r|\n/u);
4
+ const split = string.split(LINE_SPLIT_REGEX);
3
5
  const filtered = split.filter((line) => {
4
- if (/^\s*(#\s*(?:\S.*)?)?$/u.test(line)) {
6
+ if (COMMENT_OR_EMPTY_REGEX.test(line)) {
5
7
  return false;
6
8
  }
7
9
  return line.trim().length > 0;
@@ -1,9 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const LINE_SPLIT_REGEX = /\r\n|\r|\n/u;
4
+ const COMMENT_OR_EMPTY_REGEX = /^\s*(#\s*(?:\S.*)?)?$/u;
3
5
  const yamlLoc = (string) => {
4
- const split = string.split(/\r\n|\r|\n/u);
6
+ const split = string.split(LINE_SPLIT_REGEX);
5
7
  const filtered = split.filter((line) => {
6
- if (/^\s*(#\s*(?:\S.*)?)?$/u.test(line)) {
8
+ if (COMMENT_OR_EMPTY_REGEX.test(line)) {
7
9
  return false;
8
10
  }
9
11
  return line.trim().length > 0;
@@ -3,16 +3,17 @@ import type { Spec } from "comment-parser";
3
3
  * A recursive deep-merge that ignores null values when merging.
4
4
  * This returns the merged object and does not mutate.
5
5
  * @param first the first object to get merged
6
- * @param {object} second the second object to get merged
6
+ * @param second the second object to get merged
7
7
  */
8
8
  export declare const mergeDeep: (first?: object, second?: object) => object;
9
9
  /**
10
- * Checks if there is any properties of the input object which are an empty object
10
+ * Checks if there is any properties of the input object which are an empty object.
11
11
  * @param object the object to check
12
12
  * @returns boolean
13
13
  */
14
14
  export declare const hasEmptyProperty: (object: Record<string, any>) => boolean;
15
15
  /**
16
+ * Checks whether the given tag is present in tags.
16
17
  * @param tag
17
18
  * @param tags
18
19
  * @returns boolean
@@ -3,16 +3,17 @@ import type { Spec } from "comment-parser";
3
3
  * A recursive deep-merge that ignores null values when merging.
4
4
  * This returns the merged object and does not mutate.
5
5
  * @param first the first object to get merged
6
- * @param {object} second the second object to get merged
6
+ * @param second the second object to get merged
7
7
  */
8
8
  export declare const mergeDeep: (first?: object, second?: object) => object;
9
9
  /**
10
- * Checks if there is any properties of the input object which are an empty object
10
+ * Checks if there is any properties of the input object which are an empty object.
11
11
  * @param object the object to check
12
12
  * @returns boolean
13
13
  */
14
14
  export declare const hasEmptyProperty: (object: Record<string, any>) => boolean;
15
15
  /**
16
+ * Checks whether the given tag is present in tags.
16
17
  * @param tag
17
18
  * @param tags
18
19
  * @returns boolean
@@ -3,16 +3,17 @@ import type { Spec } from "comment-parser";
3
3
  * A recursive deep-merge that ignores null values when merging.
4
4
  * This returns the merged object and does not mutate.
5
5
  * @param first the first object to get merged
6
- * @param {object} second the second object to get merged
6
+ * @param second the second object to get merged
7
7
  */
8
8
  export declare const mergeDeep: (first?: object, second?: object) => object;
9
9
  /**
10
- * Checks if there is any properties of the input object which are an empty object
10
+ * Checks if there is any properties of the input object which are an empty object.
11
11
  * @param object the object to check
12
12
  * @returns boolean
13
13
  */
14
14
  export declare const hasEmptyProperty: (object: Record<string, any>) => boolean;
15
15
  /**
16
+ * Checks whether the given tag is present in tags.
16
17
  * @param tag
17
18
  * @param tags
18
19
  * @returns boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/jsdoc-open-api",
3
- "version": "3.0.0-alpha.7",
3
+ "version": "3.0.0-alpha.9",
4
4
  "description": "Generates swagger doc based on JSDoc.",
5
5
  "keywords": [
6
6
  "visulima",
@@ -101,7 +101,7 @@
101
101
  ],
102
102
  "dependencies": {
103
103
  "@apidevtools/swagger-parser": "^12.1.0",
104
- "@visulima/fs": "5.0.0-alpha.7",
104
+ "@visulima/fs": "5.0.0-alpha.10",
105
105
  "comment-parser": "1.4.6",
106
106
  "lodash.mergewith": "^4.6.2",
107
107
  "yaml": "2.8.3"
@@ -109,10 +109,10 @@
109
109
  "optionalDependencies": {
110
110
  "cli-progress": "^3.12.0",
111
111
  "commander": "^14.0.3",
112
- "webpack": "^5.106.0"
112
+ "webpack": "^5.106.2"
113
113
  },
114
114
  "engines": {
115
- "node": ">=22.13 <=25.x"
115
+ "node": "^22.14.0 || >=24.10.0"
116
116
  },
117
117
  "os": [
118
118
  "darwin",