@visulima/jsdoc-open-api 3.0.0-alpha.8 → 3.0.0

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 (113) hide show
  1. package/CHANGELOG.md +440 -0
  2. package/LICENSE.md +34 -0
  3. package/README.md +44 -33
  4. package/bin/index.js +12 -9
  5. package/dist/cli/commander/index.d.ts +1000 -2
  6. package/dist/cli/commander/index.js +1 -0
  7. package/dist/cli/index.d.ts +9 -2
  8. package/dist/cli/index.js +1 -0
  9. package/dist/index.d.ts +266 -7
  10. package/dist/index.js +1 -0
  11. package/dist/packem_shared/DEFAULT_OPTIONS-C7o6qjwP.js +1 -0
  12. package/dist/packem_shared/SpecBuilder-Vbq42UbW.js +1 -0
  13. package/dist/packem_shared/SwaggerCompilerPlugin-PUOALp2i.js +1 -0
  14. package/dist/packem_shared/constants-CdEv9ZcD.js +1 -0
  15. package/dist/packem_shared/customizer-BXFVpImq.js +1 -0
  16. package/dist/packem_shared/generateCommand-C_XPsbS6.js +5 -0
  17. package/dist/packem_shared/generateCommand-ClL9Mnc3.js +1 -0
  18. package/dist/packem_shared/initCommand-Ca1hGdYS.js +35 -0
  19. package/dist/packem_shared/initCommand-TixxsVQU.js +1 -0
  20. package/dist/packem_shared/jsDocumentCommentsToOpenApi-TjPhUj5G.js +1 -0
  21. package/dist/packem_shared/loadDefinition-7r9qpfuE.js +1 -0
  22. package/dist/packem_shared/parseFile-RDlR4tEF.js +1 -0
  23. package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-Bm9R1BnW.js +10 -0
  24. package/dist/packem_shared/validate-9Rwe2A3r.js +1 -0
  25. package/dist/packem_shared/yamlLoc-DPq-xUM4.js +1 -0
  26. package/package.json +23 -43
  27. package/dist/cli/command/generate-command.d.cts +0 -7
  28. package/dist/cli/command/generate-command.d.mts +0 -7
  29. package/dist/cli/command/generate-command.d.ts +0 -7
  30. package/dist/cli/command/init-command.d.cts +0 -2
  31. package/dist/cli/command/init-command.d.mts +0 -2
  32. package/dist/cli/command/init-command.d.ts +0 -2
  33. package/dist/cli/commander/command/generate-command.d.cts +0 -3
  34. package/dist/cli/commander/command/generate-command.d.mts +0 -3
  35. package/dist/cli/commander/command/generate-command.d.ts +0 -3
  36. package/dist/cli/commander/command/init-command.d.cts +0 -3
  37. package/dist/cli/commander/command/init-command.d.mts +0 -3
  38. package/dist/cli/commander/command/init-command.d.ts +0 -3
  39. package/dist/cli/commander/index.cjs +0 -11
  40. package/dist/cli/commander/index.d.cts +0 -2
  41. package/dist/cli/commander/index.d.mts +0 -2
  42. package/dist/cli/commander/index.mjs +0 -2
  43. package/dist/cli/index.cjs +0 -11
  44. package/dist/cli/index.d.cts +0 -2
  45. package/dist/cli/index.d.mts +0 -2
  46. package/dist/cli/index.mjs +0 -2
  47. package/dist/constants.d.cts +0 -1
  48. package/dist/constants.d.mts +0 -1
  49. package/dist/constants.d.ts +0 -1
  50. package/dist/exported.d.cts +0 -198
  51. package/dist/exported.d.mts +0 -198
  52. package/dist/exported.d.ts +0 -198
  53. package/dist/index.cjs +0 -19
  54. package/dist/index.d.cts +0 -7
  55. package/dist/index.d.mts +0 -7
  56. package/dist/index.mjs +0 -6
  57. package/dist/jsdoc/comments-to-open-api.d.cts +0 -6
  58. package/dist/jsdoc/comments-to-open-api.d.mts +0 -6
  59. package/dist/jsdoc/comments-to-open-api.d.ts +0 -6
  60. package/dist/packem_shared/SpecBuilder-B7YiF7zR.mjs +0 -61
  61. package/dist/packem_shared/SpecBuilder-CCESkmm5.cjs +0 -63
  62. package/dist/packem_shared/SwaggerCompilerPlugin-BkYJzU4f.cjs +0 -88
  63. package/dist/packem_shared/SwaggerCompilerPlugin-DZ7tIJ8x.mjs +0 -86
  64. package/dist/packem_shared/customizer-CoMXMU7a.mjs +0 -8
  65. package/dist/packem_shared/customizer-DDFwFqJl.cjs +0 -10
  66. package/dist/packem_shared/generateCommand-DRMkfIle.mjs +0 -15
  67. package/dist/packem_shared/generateCommand-MwnCNgEE.cjs +0 -82
  68. package/dist/packem_shared/generateCommand-RY4QFtm7.cjs +0 -17
  69. package/dist/packem_shared/generateCommand-a9_RAbug.mjs +0 -80
  70. package/dist/packem_shared/initCommand-B6Z9EXHP.mjs +0 -15
  71. package/dist/packem_shared/initCommand-Ch-72dKZ.cjs +0 -65
  72. package/dist/packem_shared/initCommand-D3yVEMwO.cjs +0 -17
  73. package/dist/packem_shared/initCommand-zE4VRDGW.mjs +0 -63
  74. package/dist/packem_shared/jsDocumentCommentsToOpenApi-C7yMeXJ5.cjs +0 -337
  75. package/dist/packem_shared/jsDocumentCommentsToOpenApi-DtrIZ2lK.mjs +0 -331
  76. package/dist/packem_shared/parseFile-BE-sKiRK.mjs +0 -35
  77. package/dist/packem_shared/parseFile-Dk7Bw7lt.cjs +0 -42
  78. package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-B7g9rVr5.mjs +0 -131
  79. package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-BuB7eE94.cjs +0 -138
  80. package/dist/packem_shared/validate-DZHaKH07.mjs +0 -30
  81. package/dist/packem_shared/validate-FKieC3ln.cjs +0 -37
  82. package/dist/packem_shared/yamlLoc-C7iHWvdq.mjs +0 -14
  83. package/dist/packem_shared/yamlLoc-CEvBiR4K.cjs +0 -16
  84. package/dist/parse-file.d.cts +0 -9
  85. package/dist/parse-file.d.mts +0 -9
  86. package/dist/parse-file.d.ts +0 -9
  87. package/dist/spec-builder.d.cts +0 -14
  88. package/dist/spec-builder.d.mts +0 -14
  89. package/dist/spec-builder.d.ts +0 -14
  90. package/dist/swagger-jsdoc/comments-to-open-api.d.cts +0 -6
  91. package/dist/swagger-jsdoc/comments-to-open-api.d.mts +0 -6
  92. package/dist/swagger-jsdoc/comments-to-open-api.d.ts +0 -6
  93. package/dist/swagger-jsdoc/organize-swagger-object.d.cts +0 -7
  94. package/dist/swagger-jsdoc/organize-swagger-object.d.mts +0 -7
  95. package/dist/swagger-jsdoc/organize-swagger-object.d.ts +0 -7
  96. package/dist/swagger-jsdoc/utils.d.cts +0 -22
  97. package/dist/swagger-jsdoc/utils.d.mts +0 -22
  98. package/dist/swagger-jsdoc/utils.d.ts +0 -22
  99. package/dist/util/customizer.d.cts +0 -2
  100. package/dist/util/customizer.d.mts +0 -2
  101. package/dist/util/customizer.d.ts +0 -2
  102. package/dist/util/object-merge.d.cts +0 -2
  103. package/dist/util/object-merge.d.mts +0 -2
  104. package/dist/util/object-merge.d.ts +0 -2
  105. package/dist/util/yaml-loc.d.cts +0 -2
  106. package/dist/util/yaml-loc.d.mts +0 -2
  107. package/dist/util/yaml-loc.d.ts +0 -2
  108. package/dist/validate.d.cts +0 -2
  109. package/dist/validate.d.mts +0 -2
  110. package/dist/validate.d.ts +0 -2
  111. package/dist/webpack/swagger-compiler-plugin.d.cts +0 -15
  112. package/dist/webpack/swagger-compiler-plugin.d.mts +0 -15
  113. package/dist/webpack/swagger-compiler-plugin.d.ts +0 -15
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- const node_fs = require('node:fs');
4
- const path = require('node:path');
5
- const yaml = require('yaml');
6
- const yamlLoc = require('./yamlLoc-CEvBiR4K.cjs');
7
-
8
- const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
9
-
10
- const path__default = /*#__PURE__*/_interopDefaultCompat(path);
11
- const yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
12
-
13
- const ALLOWED_KEYS = /* @__PURE__ */ new Set(["components", "externalDocs", "info", "openapi", "paths", "security", "servers", "tags"]);
14
- class ParseError extends Error {
15
- filePath;
16
- }
17
- const parseFile = (file, commentsToOpenApi, verbose) => {
18
- const fileContent = node_fs.readFileSync(file, { encoding: "utf8" });
19
- const extension = path__default.extname(file);
20
- if (extension === ".yaml" || extension === ".yml") {
21
- const spec = yaml__default.parse(fileContent);
22
- const invalidKeys = Object.keys(spec).filter((key) => !ALLOWED_KEYS.has(key));
23
- if (invalidKeys.length > 0) {
24
- const error = new ParseError(`Unexpected keys: ${invalidKeys.join(", ")}`);
25
- error.filePath = file;
26
- throw error;
27
- }
28
- if (Object.keys(spec).some((key) => ALLOWED_KEYS.has(key))) {
29
- const loc = yamlLoc(fileContent);
30
- return [{ loc, spec }];
31
- }
32
- return [];
33
- }
34
- try {
35
- return commentsToOpenApi(fileContent, verbose);
36
- } catch (error) {
37
- error.filePath = file;
38
- throw error;
39
- }
40
- };
41
-
42
- module.exports = parseFile;
@@ -1,131 +0,0 @@
1
- import { parse } from 'comment-parser';
2
- import mergeWith from 'lodash.mergewith';
3
- import yaml from 'yaml';
4
- import { c as customizer } from './customizer-CoMXMU7a.mjs';
5
-
6
- const mergeDeep = (first, second) => mergeWith({}, first, second, (a, b) => {
7
- if (b === null) {
8
- return a;
9
- }
10
- return void 0;
11
- });
12
- const hasEmptyProperty = (object) => Object.keys(object).map((key) => object[key]).every((keyObject) => typeof keyObject === "object" && Object.keys(keyObject).every((key) => !(key in keyObject)));
13
- const isTagPresentInTags = (tag, tags) => tags.some((targetTag) => tag.name === targetTag.name);
14
- const getSwaggerVersionFromSpec = (tag) => {
15
- switch (tag.tag) {
16
- case "asyncapi": {
17
- return "v4";
18
- }
19
- case "openapi": {
20
- return "v3";
21
- }
22
- case "swagger": {
23
- return "v2";
24
- }
25
- default: {
26
- return "v2";
27
- }
28
- }
29
- };
30
-
31
- const organizeSwaggerObject = (swaggerObject, annotation, property) => {
32
- if (property === "x-webhooks") {
33
- swaggerObject[property] = annotation[property];
34
- }
35
- if (property.startsWith("x-")) {
36
- return;
37
- }
38
- const commonProperties = [
39
- "components",
40
- "consumes",
41
- "produces",
42
- "paths",
43
- "schemas",
44
- "securityDefinitions",
45
- "responses",
46
- "parameters",
47
- "definitions",
48
- "channels"
49
- ];
50
- if (commonProperties.includes(property)) {
51
- Object.keys(annotation[property]).forEach((definition) => {
52
- swaggerObject[property][definition] = mergeDeep(swaggerObject[property][definition], annotation[property][definition]);
53
- });
54
- } else if (property === "tags") {
55
- const { tags } = annotation;
56
- if (Array.isArray(tags)) {
57
- tags.forEach((tag) => {
58
- if (!isTagPresentInTags(tag, swaggerObject.tags)) {
59
- swaggerObject.tags.push(tag);
60
- }
61
- });
62
- } else if (!isTagPresentInTags(tags, swaggerObject.tags)) {
63
- swaggerObject.tags.push(tags);
64
- }
65
- } else if (property === "security") {
66
- const { security } = annotation;
67
- swaggerObject.security = security;
68
- } else if (property.startsWith("/")) {
69
- swaggerObject.paths[property] = mergeDeep(swaggerObject.paths[property], annotation[property]);
70
- }
71
- };
72
-
73
- const specificationTemplate = {
74
- v2: ["paths", "definitions", "responses", "parameters", "securityDefinitions"],
75
- v3: ["paths", "definitions", "responses", "parameters", "securityDefinitions", "components"],
76
- v4: ["components", "channels"]
77
- };
78
- const tagsToObjects = (specs, verbose) => specs.map((spec) => {
79
- const hasContent = spec.description !== "" || spec.name.startsWith("/") || spec.name.endsWith(":");
80
- if ((spec.tag === "openapi" || spec.tag === "swagger" || spec.tag === "asyncapi") && hasContent) {
81
- let yamlContent = spec.description;
82
- if (spec.name.startsWith("/") || spec.name.endsWith(":")) {
83
- yamlContent = yamlContent.trim() === "" ? spec.name : `${spec.name}
84
- ${yamlContent}`;
85
- }
86
- const parsed = yaml.parseDocument(yamlContent);
87
- if (parsed.errors.length > 0) {
88
- parsed.errors.forEach((error) => {
89
- error.annotation = yamlContent;
90
- });
91
- let errorString = "Error parsing YAML in @openapi spec:";
92
- errorString += verbose ? parsed.errors.map((error) => `${error.toString()}
93
- Imbedded within:
94
- \`\`\`
95
- ${error.annotation?.replaceAll("\n", "\n ")}
96
- \`\`\``).join("\n") : parsed.errors.map((error) => error.toString()).join("\n");
97
- throw new Error(errorString);
98
- }
99
- const parsedDocument = parsed.toJSON();
100
- const specification = {
101
- tags: []
102
- };
103
- specificationTemplate[getSwaggerVersionFromSpec(spec)].forEach((property) => {
104
- specification[property] = specification[property] ?? {};
105
- });
106
- Object.keys(parsedDocument).forEach((property) => {
107
- organizeSwaggerObject(specification, parsedDocument, property);
108
- });
109
- return specification;
110
- }
111
- return {};
112
- });
113
- const commentsToOpenApi = (fileContents, verbose) => {
114
- const jsDocumentComments = parse(fileContents, { spacing: "preserve" });
115
- return jsDocumentComments.map((comment) => {
116
- const loc = comment.tags.length + 1;
117
- const result = mergeWith({}, ...tagsToObjects(comment.tags, verbose), customizer);
118
- ["definitions", "responses", "parameters", "securityDefinitions", "components", "tags"].forEach((property) => {
119
- if (result[property] !== void 0 && hasEmptyProperty(result[property])) {
120
- delete result[property];
121
- }
122
- });
123
- const spec = JSON.parse(JSON.stringify(result));
124
- return {
125
- loc,
126
- spec
127
- };
128
- });
129
- };
130
-
131
- export { commentsToOpenApi as default };
@@ -1,138 +0,0 @@
1
- 'use strict';
2
-
3
- const commentParser = require('comment-parser');
4
- const mergeWith = require('lodash.mergewith');
5
- const yaml = require('yaml');
6
- const customizer = require('./customizer-DDFwFqJl.cjs');
7
-
8
- const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
9
-
10
- const mergeWith__default = /*#__PURE__*/_interopDefaultCompat(mergeWith);
11
- const yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
12
-
13
- const mergeDeep = (first, second) => mergeWith__default({}, first, second, (a, b) => {
14
- if (b === null) {
15
- return a;
16
- }
17
- return void 0;
18
- });
19
- const hasEmptyProperty = (object) => Object.keys(object).map((key) => object[key]).every((keyObject) => typeof keyObject === "object" && Object.keys(keyObject).every((key) => !(key in keyObject)));
20
- const isTagPresentInTags = (tag, tags) => tags.some((targetTag) => tag.name === targetTag.name);
21
- const getSwaggerVersionFromSpec = (tag) => {
22
- switch (tag.tag) {
23
- case "asyncapi": {
24
- return "v4";
25
- }
26
- case "openapi": {
27
- return "v3";
28
- }
29
- case "swagger": {
30
- return "v2";
31
- }
32
- default: {
33
- return "v2";
34
- }
35
- }
36
- };
37
-
38
- const organizeSwaggerObject = (swaggerObject, annotation, property) => {
39
- if (property === "x-webhooks") {
40
- swaggerObject[property] = annotation[property];
41
- }
42
- if (property.startsWith("x-")) {
43
- return;
44
- }
45
- const commonProperties = [
46
- "components",
47
- "consumes",
48
- "produces",
49
- "paths",
50
- "schemas",
51
- "securityDefinitions",
52
- "responses",
53
- "parameters",
54
- "definitions",
55
- "channels"
56
- ];
57
- if (commonProperties.includes(property)) {
58
- Object.keys(annotation[property]).forEach((definition) => {
59
- swaggerObject[property][definition] = mergeDeep(swaggerObject[property][definition], annotation[property][definition]);
60
- });
61
- } else if (property === "tags") {
62
- const { tags } = annotation;
63
- if (Array.isArray(tags)) {
64
- tags.forEach((tag) => {
65
- if (!isTagPresentInTags(tag, swaggerObject.tags)) {
66
- swaggerObject.tags.push(tag);
67
- }
68
- });
69
- } else if (!isTagPresentInTags(tags, swaggerObject.tags)) {
70
- swaggerObject.tags.push(tags);
71
- }
72
- } else if (property === "security") {
73
- const { security } = annotation;
74
- swaggerObject.security = security;
75
- } else if (property.startsWith("/")) {
76
- swaggerObject.paths[property] = mergeDeep(swaggerObject.paths[property], annotation[property]);
77
- }
78
- };
79
-
80
- const specificationTemplate = {
81
- v2: ["paths", "definitions", "responses", "parameters", "securityDefinitions"],
82
- v3: ["paths", "definitions", "responses", "parameters", "securityDefinitions", "components"],
83
- v4: ["components", "channels"]
84
- };
85
- const tagsToObjects = (specs, verbose) => specs.map((spec) => {
86
- const hasContent = spec.description !== "" || spec.name.startsWith("/") || spec.name.endsWith(":");
87
- if ((spec.tag === "openapi" || spec.tag === "swagger" || spec.tag === "asyncapi") && hasContent) {
88
- let yamlContent = spec.description;
89
- if (spec.name.startsWith("/") || spec.name.endsWith(":")) {
90
- yamlContent = yamlContent.trim() === "" ? spec.name : `${spec.name}
91
- ${yamlContent}`;
92
- }
93
- const parsed = yaml__default.parseDocument(yamlContent);
94
- if (parsed.errors.length > 0) {
95
- parsed.errors.forEach((error) => {
96
- error.annotation = yamlContent;
97
- });
98
- let errorString = "Error parsing YAML in @openapi spec:";
99
- errorString += verbose ? parsed.errors.map((error) => `${error.toString()}
100
- Imbedded within:
101
- \`\`\`
102
- ${error.annotation?.replaceAll("\n", "\n ")}
103
- \`\`\``).join("\n") : parsed.errors.map((error) => error.toString()).join("\n");
104
- throw new Error(errorString);
105
- }
106
- const parsedDocument = parsed.toJSON();
107
- const specification = {
108
- tags: []
109
- };
110
- specificationTemplate[getSwaggerVersionFromSpec(spec)].forEach((property) => {
111
- specification[property] = specification[property] ?? {};
112
- });
113
- Object.keys(parsedDocument).forEach((property) => {
114
- organizeSwaggerObject(specification, parsedDocument, property);
115
- });
116
- return specification;
117
- }
118
- return {};
119
- });
120
- const commentsToOpenApi = (fileContents, verbose) => {
121
- const jsDocumentComments = commentParser.parse(fileContents, { spacing: "preserve" });
122
- return jsDocumentComments.map((comment) => {
123
- const loc = comment.tags.length + 1;
124
- const result = mergeWith__default({}, ...tagsToObjects(comment.tags, verbose), customizer.customizer);
125
- ["definitions", "responses", "parameters", "securityDefinitions", "components", "tags"].forEach((property) => {
126
- if (result[property] !== void 0 && hasEmptyProperty(result[property])) {
127
- delete result[property];
128
- }
129
- });
130
- const spec = JSON.parse(JSON.stringify(result));
131
- return {
132
- loc,
133
- spec
134
- };
135
- });
136
- };
137
-
138
- module.exports = commentsToOpenApi;
@@ -1,30 +0,0 @@
1
- import SwaggerParser from '@apidevtools/swagger-parser';
2
-
3
- const DEFAULT_EXCLUDE = [
4
- "coverage/**",
5
- ".github/**",
6
- "**/*.d.ts",
7
- "**/test{,s}/**",
8
- "**/test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}",
9
- "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}",
10
- "**/__tests__/**",
11
- "**/{ava,babel,nyc}.config.{js,cjs,mjs}",
12
- "**/jest.config.{js,cjs,mjs,ts}",
13
- "**/{karma,rollup,webpack}.config.js",
14
- "**/.{eslint,mocha}rc.{js,cjs}",
15
- "**/.{travis,yarnrc}.yml",
16
- "**/{docker-compose,docker}.yml",
17
- "**/.yamllint.{yaml,yml}",
18
- "**/node_modules/**",
19
- "**/{pnpm-workspace,pnpm-lock}.yaml",
20
- "**/{package,package-lock}.json",
21
- "**/yarn.lock",
22
- "**/package.json5",
23
- "**/.next/**"
24
- ];
25
-
26
- const validate = async (spec) => {
27
- await SwaggerParser.validate(spec);
28
- };
29
-
30
- export { DEFAULT_EXCLUDE as D, validate as v };
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- const SwaggerParser = require('@apidevtools/swagger-parser');
4
-
5
- const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
6
-
7
- const SwaggerParser__default = /*#__PURE__*/_interopDefaultCompat(SwaggerParser);
8
-
9
- const DEFAULT_EXCLUDE = [
10
- "coverage/**",
11
- ".github/**",
12
- "**/*.d.ts",
13
- "**/test{,s}/**",
14
- "**/test{,-*}.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}",
15
- "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx,yaml,yml}",
16
- "**/__tests__/**",
17
- "**/{ava,babel,nyc}.config.{js,cjs,mjs}",
18
- "**/jest.config.{js,cjs,mjs,ts}",
19
- "**/{karma,rollup,webpack}.config.js",
20
- "**/.{eslint,mocha}rc.{js,cjs}",
21
- "**/.{travis,yarnrc}.yml",
22
- "**/{docker-compose,docker}.yml",
23
- "**/.yamllint.{yaml,yml}",
24
- "**/node_modules/**",
25
- "**/{pnpm-workspace,pnpm-lock}.yaml",
26
- "**/{package,package-lock}.json",
27
- "**/yarn.lock",
28
- "**/package.json5",
29
- "**/.next/**"
30
- ];
31
-
32
- const validate = async (spec) => {
33
- await SwaggerParser__default.validate(spec);
34
- };
35
-
36
- exports.DEFAULT_EXCLUDE = DEFAULT_EXCLUDE;
37
- exports.validate = validate;
@@ -1,14 +0,0 @@
1
- const LINE_SPLIT_REGEX = /\r\n|\r|\n/u;
2
- const COMMENT_OR_EMPTY_REGEX = /^\s*(#\s*(?:\S.*)?)?$/u;
3
- const yamlLoc = (string) => {
4
- const split = string.split(LINE_SPLIT_REGEX);
5
- const filtered = split.filter((line) => {
6
- if (COMMENT_OR_EMPTY_REGEX.test(line)) {
7
- return false;
8
- }
9
- return line.trim().length > 0;
10
- });
11
- return filtered.length;
12
- };
13
-
14
- export { yamlLoc as default };
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- const LINE_SPLIT_REGEX = /\r\n|\r|\n/u;
4
- const COMMENT_OR_EMPTY_REGEX = /^\s*(#\s*(?:\S.*)?)?$/u;
5
- const yamlLoc = (string) => {
6
- const split = string.split(LINE_SPLIT_REGEX);
7
- const filtered = split.filter((line) => {
8
- if (COMMENT_OR_EMPTY_REGEX.test(line)) {
9
- return false;
10
- }
11
- return line.trim().length > 0;
12
- });
13
- return filtered.length;
14
- };
15
-
16
- module.exports = yamlLoc;
@@ -1,9 +0,0 @@
1
- import type { OpenApiObject } from "./exported.d.cts";
2
- declare const parseFile: (file: string, commentsToOpenApi: (fileContent: string, verbose?: boolean) => {
3
- loc: number;
4
- spec: OpenApiObject;
5
- }[], verbose?: boolean) => {
6
- loc: number;
7
- spec: OpenApiObject;
8
- }[];
9
- export = parseFile;
@@ -1,9 +0,0 @@
1
- import type { OpenApiObject } from "./exported.d.mts";
2
- declare const parseFile: (file: string, commentsToOpenApi: (fileContent: string, verbose?: boolean) => {
3
- loc: number;
4
- spec: OpenApiObject;
5
- }[], verbose?: boolean) => {
6
- loc: number;
7
- spec: OpenApiObject;
8
- }[];
9
- export default parseFile;
@@ -1,9 +0,0 @@
1
- import type { OpenApiObject } from "./exported.d.ts";
2
- declare const parseFile: (file: string, commentsToOpenApi: (fileContent: string, verbose?: boolean) => {
3
- loc: number;
4
- spec: OpenApiObject;
5
- }[], verbose?: boolean) => {
6
- loc: number;
7
- spec: OpenApiObject;
8
- }[];
9
- export = parseFile;
@@ -1,14 +0,0 @@
1
- import type { BaseDefinition, ComponentsObject, ExternalDocumentationObject, InfoObject, OpenApiObject, PathsObject, SecurityRequirementObject, ServerObject, TagObject } from "./exported.d.cts";
2
- declare class SpecBuilder implements OpenApiObject {
3
- components?: ComponentsObject;
4
- externalDocs?: ExternalDocumentationObject;
5
- info: InfoObject;
6
- openapi: string;
7
- paths: PathsObject;
8
- security?: SecurityRequirementObject[];
9
- servers?: ServerObject[];
10
- tags?: TagObject[];
11
- constructor(baseDefinition: BaseDefinition);
12
- addData(parsedFile: OpenApiObject[]): void;
13
- }
14
- export = SpecBuilder;
@@ -1,14 +0,0 @@
1
- import type { BaseDefinition, ComponentsObject, ExternalDocumentationObject, InfoObject, OpenApiObject, PathsObject, SecurityRequirementObject, ServerObject, TagObject } from "./exported.d.mts";
2
- declare class SpecBuilder implements OpenApiObject {
3
- components?: ComponentsObject;
4
- externalDocs?: ExternalDocumentationObject;
5
- info: InfoObject;
6
- openapi: string;
7
- paths: PathsObject;
8
- security?: SecurityRequirementObject[];
9
- servers?: ServerObject[];
10
- tags?: TagObject[];
11
- constructor(baseDefinition: BaseDefinition);
12
- addData(parsedFile: OpenApiObject[]): void;
13
- }
14
- export default SpecBuilder;
@@ -1,14 +0,0 @@
1
- import type { BaseDefinition, ComponentsObject, ExternalDocumentationObject, InfoObject, OpenApiObject, PathsObject, SecurityRequirementObject, ServerObject, TagObject } from "./exported.d.ts";
2
- declare class SpecBuilder implements OpenApiObject {
3
- components?: ComponentsObject;
4
- externalDocs?: ExternalDocumentationObject;
5
- info: InfoObject;
6
- openapi: string;
7
- paths: PathsObject;
8
- security?: SecurityRequirementObject[];
9
- servers?: ServerObject[];
10
- tags?: TagObject[];
11
- constructor(baseDefinition: BaseDefinition);
12
- addData(parsedFile: OpenApiObject[]): void;
13
- }
14
- export = SpecBuilder;
@@ -1,6 +0,0 @@
1
- import type { OpenApiObject } from "../exported.d.cts";
2
- declare const commentsToOpenApi: (fileContents: string, verbose?: boolean) => {
3
- loc: number;
4
- spec: OpenApiObject;
5
- }[];
6
- export = commentsToOpenApi;
@@ -1,6 +0,0 @@
1
- import type { OpenApiObject } from "../exported.d.mts";
2
- declare const commentsToOpenApi: (fileContents: string, verbose?: boolean) => {
3
- loc: number;
4
- spec: OpenApiObject;
5
- }[];
6
- export default commentsToOpenApi;
@@ -1,6 +0,0 @@
1
- import type { OpenApiObject } from "../exported.d.ts";
2
- declare const commentsToOpenApi: (fileContents: string, verbose?: boolean) => {
3
- loc: number;
4
- spec: OpenApiObject;
5
- }[];
6
- export = commentsToOpenApi;
@@ -1,7 +0,0 @@
1
- /**
2
- * @param {object} swaggerObject
3
- * @param {object} annotation
4
- * @param {string} property
5
- */
6
- declare const organizeSwaggerObject: (swaggerObject: Record<string, any>, annotation: Record<string, any>, property: string) => void;
7
- export = organizeSwaggerObject;
@@ -1,7 +0,0 @@
1
- /**
2
- * @param {object} swaggerObject
3
- * @param {object} annotation
4
- * @param {string} property
5
- */
6
- declare const organizeSwaggerObject: (swaggerObject: Record<string, any>, annotation: Record<string, any>, property: string) => void;
7
- export default organizeSwaggerObject;
@@ -1,7 +0,0 @@
1
- /**
2
- * @param {object} swaggerObject
3
- * @param {object} annotation
4
- * @param {string} property
5
- */
6
- declare const organizeSwaggerObject: (swaggerObject: Record<string, any>, annotation: Record<string, any>, property: string) => void;
7
- export = organizeSwaggerObject;
@@ -1,22 +0,0 @@
1
- import type { Spec } from "comment-parser";
2
- /**
3
- * A recursive deep-merge that ignores null values when merging.
4
- * This returns the merged object and does not mutate.
5
- * @param first the first object to get merged
6
- * @param second the second object to get merged
7
- */
8
- export declare const mergeDeep: (first?: object, second?: object) => object;
9
- /**
10
- * Checks if there is any properties of the input object which are an empty object.
11
- * @param object the object to check
12
- * @returns boolean
13
- */
14
- export declare const hasEmptyProperty: (object: Record<string, any>) => boolean;
15
- /**
16
- * Checks whether the given tag is present in tags.
17
- * @param tag
18
- * @param tags
19
- * @returns boolean
20
- */
21
- export declare const isTagPresentInTags: (tag: Spec, tags: Spec[]) => boolean;
22
- export declare const getSwaggerVersionFromSpec: (tag: Spec) => "v2" | "v3" | "v4";
@@ -1,22 +0,0 @@
1
- import type { Spec } from "comment-parser";
2
- /**
3
- * A recursive deep-merge that ignores null values when merging.
4
- * This returns the merged object and does not mutate.
5
- * @param first the first object to get merged
6
- * @param second the second object to get merged
7
- */
8
- export declare const mergeDeep: (first?: object, second?: object) => object;
9
- /**
10
- * Checks if there is any properties of the input object which are an empty object.
11
- * @param object the object to check
12
- * @returns boolean
13
- */
14
- export declare const hasEmptyProperty: (object: Record<string, any>) => boolean;
15
- /**
16
- * Checks whether the given tag is present in tags.
17
- * @param tag
18
- * @param tags
19
- * @returns boolean
20
- */
21
- export declare const isTagPresentInTags: (tag: Spec, tags: Spec[]) => boolean;
22
- export declare const getSwaggerVersionFromSpec: (tag: Spec) => "v2" | "v3" | "v4";
@@ -1,22 +0,0 @@
1
- import type { Spec } from "comment-parser";
2
- /**
3
- * A recursive deep-merge that ignores null values when merging.
4
- * This returns the merged object and does not mutate.
5
- * @param first the first object to get merged
6
- * @param second the second object to get merged
7
- */
8
- export declare const mergeDeep: (first?: object, second?: object) => object;
9
- /**
10
- * Checks if there is any properties of the input object which are an empty object.
11
- * @param object the object to check
12
- * @returns boolean
13
- */
14
- export declare const hasEmptyProperty: (object: Record<string, any>) => boolean;
15
- /**
16
- * Checks whether the given tag is present in tags.
17
- * @param tag
18
- * @param tags
19
- * @returns boolean
20
- */
21
- export declare const isTagPresentInTags: (tag: Spec, tags: Spec[]) => boolean;
22
- export declare const getSwaggerVersionFromSpec: (tag: Spec) => "v2" | "v3" | "v4";
@@ -1,2 +0,0 @@
1
- declare const customizer: (objectValue: unknown, sourceValue: unknown[]) => unknown[] | undefined;
2
- export = customizer;
@@ -1,2 +0,0 @@
1
- declare const customizer: (objectValue: unknown, sourceValue: unknown[]) => unknown[] | undefined;
2
- export default customizer;
@@ -1,2 +0,0 @@
1
- declare const customizer: (objectValue: unknown, sourceValue: unknown[]) => unknown[] | undefined;
2
- export = customizer;
@@ -1,2 +0,0 @@
1
- declare const objectMerge: <T>(a: T, b: T) => void;
2
- export = objectMerge;
@@ -1,2 +0,0 @@
1
- declare const objectMerge: <T>(a: T, b: T) => void;
2
- export default objectMerge;
@@ -1,2 +0,0 @@
1
- declare const objectMerge: <T>(a: T, b: T) => void;
2
- export = objectMerge;
@@ -1,2 +0,0 @@
1
- declare const yamlLoc: (string: string) => number;
2
- export = yamlLoc;
@@ -1,2 +0,0 @@
1
- declare const yamlLoc: (string: string) => number;
2
- export default yamlLoc;
@@ -1,2 +0,0 @@
1
- declare const yamlLoc: (string: string) => number;
2
- export = yamlLoc;
@@ -1,2 +0,0 @@
1
- declare const validate: (spec: Record<string, unknown>) => Promise<void>;
2
- export = validate;
@@ -1,2 +0,0 @@
1
- declare const validate: (spec: Record<string, unknown>) => Promise<void>;
2
- export default validate;
@@ -1,2 +0,0 @@
1
- declare const validate: (spec: Record<string, unknown>) => Promise<void>;
2
- export = validate;