@visulima/jsdoc-open-api 3.0.0-alpha.37 → 3.0.0-alpha.38
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/CHANGELOG.md +41 -0
- package/bin/index.js +12 -9
- package/dist/cli/commander/index.js +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/index.js +1 -0
- package/dist/packem_shared/SwaggerCompilerPlugin-PUOALp2i.js +1 -0
- package/dist/packem_shared/{generateCommand-CkcShFNr.mjs → generateCommand-C_XPsbS6.js} +1 -1
- package/dist/packem_shared/generateCommand-ClL9Mnc3.js +1 -0
- package/dist/packem_shared/initCommand-TixxsVQU.js +1 -0
- package/dist/packem_shared/jsDocumentCommentsToOpenApi-TjPhUj5G.js +1 -0
- package/dist/packem_shared/parseFile-RDlR4tEF.js +1 -0
- package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-Bm9R1BnW.js +10 -0
- package/package.json +10 -28
- package/dist/cli/commander/index.cjs +0 -1
- package/dist/cli/commander/index.d.cts +0 -1000
- package/dist/cli/commander/index.d.mts +0 -1000
- package/dist/cli/commander/index.mjs +0 -1
- package/dist/cli/index.cjs +0 -1
- package/dist/cli/index.d.cts +0 -9
- package/dist/cli/index.d.mts +0 -9
- package/dist/cli/index.mjs +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -266
- package/dist/index.d.mts +0 -266
- package/dist/index.mjs +0 -1
- package/dist/packem_shared/DEFAULT_OPTIONS-CP1lNs-k.cjs +0 -1
- package/dist/packem_shared/SpecBuilder-C_KcIxW-.cjs +0 -1
- package/dist/packem_shared/SwaggerCompilerPlugin-Bd9L4Djt.cjs +0 -1
- package/dist/packem_shared/SwaggerCompilerPlugin-wRdVpHJS.mjs +0 -1
- package/dist/packem_shared/constants-DnbfJ7Id.cjs +0 -1
- package/dist/packem_shared/customizer-Bo8QD_ti.cjs +0 -1
- package/dist/packem_shared/generateCommand-CEP0sWth.cjs +0 -5
- package/dist/packem_shared/generateCommand-CmoN8jyY.cjs +0 -1
- package/dist/packem_shared/generateCommand-DEhmHbRZ.mjs +0 -1
- package/dist/packem_shared/initCommand-1O6IuWJv.mjs +0 -1
- package/dist/packem_shared/initCommand-C8s0kkim.cjs +0 -1
- package/dist/packem_shared/initCommand-DvNH61Z4.cjs +0 -35
- package/dist/packem_shared/jsDocumentCommentsToOpenApi-BEQrWgpQ.mjs +0 -1
- package/dist/packem_shared/jsDocumentCommentsToOpenApi-CMbdb0uR.cjs +0 -1
- package/dist/packem_shared/loadDefinition-ah20Zy-G.cjs +0 -1
- package/dist/packem_shared/parseFile-CPb-Kglh.cjs +0 -1
- package/dist/packem_shared/parseFile-Wxs3O0wy.mjs +0 -1
- package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-BnPWbZoe.mjs +0 -10
- package/dist/packem_shared/swaggerJsDocumentCommentsToOpenApi-rMEaS4lg.cjs +0 -10
- package/dist/packem_shared/validate-DLmCjOPl.cjs +0 -1
- package/dist/packem_shared/yamlLoc-DC_7PYVS.cjs +0 -1
- /package/dist/packem_shared/{DEFAULT_OPTIONS-C7o6qjwP.mjs → DEFAULT_OPTIONS-C7o6qjwP.js} +0 -0
- /package/dist/packem_shared/{SpecBuilder-Vbq42UbW.mjs → SpecBuilder-Vbq42UbW.js} +0 -0
- /package/dist/packem_shared/{constants-CdEv9ZcD.mjs → constants-CdEv9ZcD.js} +0 -0
- /package/dist/packem_shared/{customizer-BXFVpImq.mjs → customizer-BXFVpImq.js} +0 -0
- /package/dist/packem_shared/{initCommand-Ca1hGdYS.mjs → initCommand-Ca1hGdYS.js} +0 -0
- /package/dist/packem_shared/{loadDefinition-7r9qpfuE.mjs → loadDefinition-7r9qpfuE.js} +0 -0
- /package/dist/packem_shared/{validate-9Rwe2A3r.mjs → validate-9Rwe2A3r.js} +0 -0
- /package/dist/packem_shared/{yamlLoc-DPq-xUM4.mjs → yamlLoc-DPq-xUM4.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
## @visulima/jsdoc-open-api [3.0.0-alpha.38](https://github.com/visulima/visulima/compare/@visulima/jsdoc-open-api@3.0.0-alpha.37...@visulima/jsdoc-open-api@3.0.0-alpha.38) (2026-06-30)
|
|
2
|
+
|
|
3
|
+
### ⚠ BREAKING CHANGES
|
|
4
|
+
|
|
5
|
+
* the listed packages no longer publish a CommonJS build —
|
|
6
|
+
consumers must use ESM (import) or dynamic import(). @visulima/connect,
|
|
7
|
+
@visulima/crud, @visulima/prisma-dmmf-transformer and @visulima/api-platform
|
|
8
|
+
are removed and deprecated.
|
|
9
|
+
|
|
10
|
+
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* resolve eslint errors in fmt, jsdoc-open-api, vis ([43bf450](https://github.com/visulima/visulima/commit/43bf45081e46b042a08b555c3fcb60391b82d06f))
|
|
15
|
+
* **security:** resolve CodeQL alerts on alpha→main ([541e206](https://github.com/visulima/visulima/commit/541e206517b2f78532d19638c18be95ff97e48ae)), closes [#713](https://github.com/visulima/visulima/issues/713)
|
|
16
|
+
|
|
17
|
+
### Styles
|
|
18
|
+
|
|
19
|
+
* cs fixes ([2a960bb](https://github.com/visulima/visulima/commit/2a960bb1772c9dc70080e2d75d3a0d827034e294))
|
|
20
|
+
|
|
21
|
+
### Miscellaneous Chores
|
|
22
|
+
|
|
23
|
+
* add fallow code-intelligence across all packages ([a3b4821](https://github.com/visulima/visulima/commit/a3b48215002e86fed20f2973038b5d4a0aa1ce04))
|
|
24
|
+
|
|
25
|
+
### Code Refactoring
|
|
26
|
+
|
|
27
|
+
* ship esm-only; remove deprecated api packages ([6e58351](https://github.com/visulima/visulima/commit/6e58351e73ac7d8f8ec88be4d77871e4de5d5405))
|
|
28
|
+
|
|
29
|
+
### Build System
|
|
30
|
+
|
|
31
|
+
* emit .js instead of .mjs for esm output ([c8a6026](https://github.com/visulima/visulima/commit/c8a602665a59f0441a61a5a510cdfed9353101e6))
|
|
32
|
+
|
|
33
|
+
### Continuous Integration
|
|
34
|
+
|
|
35
|
+
* **fallow:** make fallow:health advisory (--report-only) ([d57148e](https://github.com/visulima/visulima/commit/d57148ea0e3556b4c24d8d336b9fa14987f5dc7d))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Dependencies
|
|
39
|
+
|
|
40
|
+
* **@visulima/fs:** upgraded to 5.0.0-alpha.33
|
|
41
|
+
|
|
1
42
|
## @visulima/jsdoc-open-api [3.0.0-alpha.37](https://github.com/visulima/visulima/compare/@visulima/jsdoc-open-api@3.0.0-alpha.36...@visulima/jsdoc-open-api@3.0.0-alpha.37) (2026-06-23)
|
|
2
43
|
|
|
3
44
|
## @visulima/jsdoc-open-api [3.0.0-alpha.36](https://github.com/visulima/visulima/compare/@visulima/jsdoc-open-api@3.0.0-alpha.35...@visulima/jsdoc-open-api@3.0.0-alpha.36) (2026-06-23)
|
package/bin/index.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { argv, exit } from "node:process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// eslint-disable-next-line import/no-extraneous-dependencies -- commander is an optional CLI dependency; the bin only runs when a consumer has installed it
|
|
8
|
+
import { Command } from "commander";
|
|
8
9
|
|
|
9
|
-
// eslint-disable-next-line no-
|
|
10
|
-
|
|
10
|
+
// eslint-disable-next-line antfu/no-import-dist -- bin entry point loads the built ESM dist after build
|
|
11
|
+
import { generateCommand, initCommand } from "../dist/cli/commander/index.js";
|
|
12
|
+
|
|
13
|
+
const { version } = JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8"));
|
|
11
14
|
|
|
12
15
|
const program = new Command();
|
|
13
16
|
|
|
14
|
-
program.name("@visulima/jsdoc-open-api").description("CLI to generate OpenAPI (Swagger) documentation from JSDoc's").version(
|
|
17
|
+
program.name("@visulima/jsdoc-open-api").description("CLI to generate OpenAPI (Swagger) documentation from JSDoc's").version(version);
|
|
15
18
|
|
|
16
19
|
initCommand(program);
|
|
17
20
|
generateCommand(program);
|
|
18
21
|
|
|
19
|
-
program.parse(
|
|
22
|
+
program.parse(argv);
|
|
20
23
|
|
|
21
|
-
if (
|
|
24
|
+
if (argv.slice(2).length === 0) {
|
|
22
25
|
program.help();
|
|
23
26
|
exit(1);
|
|
24
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as m}from"../../packem_shared/generateCommand-ClL9Mnc3.js";import{default as t}from"../../packem_shared/initCommand-TixxsVQU.js";export{m as generateCommand,t as initCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as m}from"../packem_shared/generateCommand-C_XPsbS6.js";import{default as t}from"../packem_shared/initCommand-Ca1hGdYS.js";export{m as generateCommand,t as initCommand};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as a}from"./packem_shared/jsDocumentCommentsToOpenApi-TjPhUj5G.js";import{default as r}from"./packem_shared/DEFAULT_OPTIONS-C7o6qjwP.js";import{default as l,parseFileMulti as m}from"./packem_shared/parseFile-RDlR4tEF.js";import{default as s}from"./packem_shared/SpecBuilder-Vbq42UbW.js";import{default as d}from"./packem_shared/swaggerJsDocumentCommentsToOpenApi-Bm9R1BnW.js";import{default as n}from"./packem_shared/loadDefinition-7r9qpfuE.js";import{default as g}from"./packem_shared/yamlLoc-DPq-xUM4.js";import{default as D}from"./packem_shared/validate-9Rwe2A3r.js";import{default as T}from"./packem_shared/SwaggerCompilerPlugin-PUOALp2i.js";export{r as DEFAULT_OPTIONS,s as SpecBuilder,T as SwaggerCompilerPlugin,a as jsDocumentCommentsToOpenApi,n as loadDefinition,l as parseFile,m as parseFileMulti,d as swaggerJsDocumentCommentsToOpenApi,D as validate,g as yamlLoc};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdir as c,writeFile as m}from"node:fs/promises";import{dirname as f}from"node:path";import{collect as p}from"@visulima/fs";import{D as u}from"./constants-CdEv9ZcD.js";import w from"./jsDocumentCommentsToOpenApi-TjPhUj5G.js";import{parseFileMulti as d}from"./parseFile-RDlR4tEF.js";import b from"./SpecBuilder-Vbq42UbW.js";import v from"./swaggerJsDocumentCommentsToOpenApi-Bm9R1BnW.js";import y from"./validate-9Rwe2A3r.js";const D=[w,v],E=r=>r instanceof Error?r:new Error(String(r));class J{assetsPath;ignore;silent;sources;swaggerDefinition;verbose;constructor(t,n,o,s){this.assetsPath=t,this.swaggerDefinition=o,this.sources=n,this.verbose=s.verbose??!1,this.silent=s.silent??!1,this.ignore=s.ignore??[]}apply(t){const n=new Set([...u,...this.ignore]);t.hooks.make.tapAsync("SwaggerCompilerPlugin",async(o,s)=>{this.log("Build paused, switching to swagger build");const e=new b(this.swaggerDefinition);try{for(const i of this.sources){const l=await p(i,{extensions:[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],includeDirs:!1,skip:[...n]});this.verbose&&(this.log(`Found ${String(l.length)} files in ${i}`),this.log(JSON.stringify(l))),l.forEach(g=>{this.verbose&&this.log(`Parsing file ${g}`),e.addData(d(g,D,this.verbose).map(h=>h.spec))})}this.verbose&&(this.log("Validating swagger spec"),this.log(JSON.stringify(e,void 0,2))),await y(structuredClone(e));const{assetsPath:a}=this;await c(f(a),{recursive:!0}),await m(a,JSON.stringify(e,void 0,2)),this.verbose&&this.log(`Written swagger spec to "${this.assetsPath}" file`)}catch(a){const i=E(a);Array.isArray(o.errors)&&o.errors.push(i),s(i);return}this.log("switching back to normal build"),s()})}log(t){this.silent||console.log(t)}}export{J as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{mkdir as D,writeFile as b,lstat as E,realpath as O}from"node:fs/promises";import{dirname as S,extname as _,normalize as F}from"node:path";import{stdout as U}from"node:process";import{pathToFileURL as x}from"node:url";import{collect as L}from"@visulima/fs";import{MultiBar as N,Presets as j}from"cli-progress";import R from"yaml";import{D as k}from"./constants-CdEv9ZcD.
|
|
1
|
+
import{mkdir as D,writeFile as b,lstat as E,realpath as O}from"node:fs/promises";import{dirname as S,extname as _,normalize as F}from"node:path";import{stdout as U}from"node:process";import{pathToFileURL as x}from"node:url";import{collect as L}from"@visulima/fs";import{MultiBar as N,Presets as j}from"cli-progress";import R from"yaml";import{D as k}from"./constants-CdEv9ZcD.js";import C from"./jsDocumentCommentsToOpenApi-TjPhUj5G.js";import{parseFileMulti as g}from"./parseFile-RDlR4tEF.js";import M from"./SpecBuilder-Vbq42UbW.js";import V from"./swaggerJsDocumentCommentsToOpenApi-Bm9R1BnW.js";import P from"./loadDefinition-7r9qpfuE.js";import T from"./validate-9Rwe2A3r.js";const A=new Set([".yaml",".yml"]),u="-",p=[C,V],J=async t=>{try{let e=await import(x(F(t)).href);return e?.default&&(e=e.default),e}catch(e){if(e?.code==="ERR_MODULE_NOT_FOUND"||e?.code==="MODULE_NOT_FOUND"||e?.code==="ERR_LOAD_URL")throw new Error(`No config file found, on: ${t}
|
|
2
2
|
`,{cause:e});const o=e instanceof Error?e.message:String(e);throw new Error(`Failed to load config file "${t}": ${o}`,{cause:e})}},z=async(t,e,o)=>{const r=await J(o.config??t),i=o.definition??r.definition;let{swaggerDefinition:c}=r;i&&(c={...P(i),...c});const f=o.output===u?void 0:new N({clearOnComplete:!1,format:"{value}/{total} | {bar} | {filename}",hideCursor:!0},j.shades_grey),s=new M(c),w=new Set([...k,...r.exclude]);for(const m of e){const y=(await E(m)).isDirectory(),a=await O(m);if(!y){s.addData(g(a,p,o.verbose).map(l=>l.spec));continue}const n=await L(a,{extensions:r.extensions??[".js",".cjs",".mjs",".ts",".tsx",".jsx",".yaml",".yml"],followSymlinks:r.followSymlinks??!1,match:r.include,skip:[...w]});(o.verbose??o.veryVerbose)&&console.log(`
|
|
3
3
|
Found ${String(n.length)} files in ${a}`),o.veryVerbose&&console.log(n);const h=f?.create(n.length,0);n.forEach(l=>{o.verbose&&console.log(`Parsing file ${l}`),h?.increment(1,{filename:a}),s.addData(g(l,p,o.verbose).map(v=>v.spec))})}return o.verbose&&console.log("Validating swagger spec"),o.veryVerbose&&console.log(JSON.stringify(s,void 0,2)),await T(structuredClone(s)),f?.stop(),s},d=(t,e)=>A.has(_(e))?R.stringify(structuredClone(t)):JSON.stringify(t,void 0,2),te=async(t,e,o)=>{const r=await z(t,e,o),i=o.output??"swagger.json";if(i===u){U.write(`${d(r,"swagger.json")}
|
|
4
4
|
`);return}o.verbose&&console.log(`Written swagger spec to "${i}" file`),await D(S(i),{recursive:!0}),await b(i,d(r,i)),console.log(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{watch as u}from"node:fs";import s,{exit as p}from"node:process";import f from"./generateCommand-C_XPsbS6.js";const c=o=>{console.error(o)},h=async(o,a,r)=>{const e=async()=>{await f(o,a,r)},t=a.map(i=>u(i,{recursive:!0},()=>{e().catch(c)})),n=()=>{t.forEach(i=>{i.close()}),p(0)};s.once("SIGINT",n),s.once("SIGTERM",n);try{await e()}catch(i){c(i)}console.log("Watching for changes... (press Ctrl+C to exit)")},d=(o,a="generate",r=".openapirc.js")=>{o.command(a).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("-d, --definition [definition.yaml]","Base OpenAPI definition file (YAML/JSON) to seed info/servers/components.").option("-o, --output [swaggerSpec.json]",'Output swagger specification. Use "-" to write to stdout, or a .yaml/.yml path for YAML output.').option("-w, --watch","Re-generate the specification whenever a watched path changes.").option("-v, --verbose","Verbose output.").option("--very-verbose","Very verbose output.").action(async(e,t)=>{if(t.watch){await h(r,e,t);return}try{await f(r,e,t)}catch(n){c(n),p(1)}})};export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{exit as c}from"node:process";import e from"./initCommand-Ca1hGdYS.js";const s=(o,i="init",r="Inits a pre-configured @visulima/jsdoc-open-api config file.",n=".openapirc.js")=>{o.command(i).description(r).action(()=>{try{e(n)}catch(t){console.error(t),c(1)}})};export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parse as d}from"comment-parser";import{mergeWith as l}from"es-toolkit";import{u as y}from"./customizer-BXFVpImq.js";const f=/\[\]$/,b=/^- /u,$=/Param$/u,g=/^(GET|PUT|POST|DELETE|OPTIONS|HEAD|PATCH|TRACE) \/.*$/,h=t=>{t.security&&(t.security=Object.keys(t.security).map(o=>({[o]:t.security[o]})))},T=new Set(["array","boolean","integer","number","object","string"]),m={binary:"string",byte:"string",date:"string","date-time":"string",double:"number",float:"number",int32:"integer",int64:"integer",password:"string"},w=t=>{const o=t.type,c=o.endsWith("[]"),e=o.replace(f,""),n=T.has(e),r=Object.keys(m).includes(e);let s;if(t.default)switch(e){case"double":case"float":case"number":{s=Number.parseFloat(t.default);break}case"int32":case"int64":case"integer":{s=Number.parseInt(t.default,10);break}default:{s=t.default;break}}let a;n?a={default:s,type:e}:r?a={default:s,format:e,type:m[e]}:a={$ref:`#/components/schemas/${e}`};let p=c?{items:{...a},type:"array"}:{...a};e===""&&(p=void 0);let i=t.description.trim().replace(b,"");return i===""&&(i=void 0),{description:i,name:t.name,rawType:o,required:!t.optional,schema:p}},k=(t,o)=>t.map(c=>{const e=w(c);let n="";switch(e.name&&(n+=e.name),e.description&&(n+=` ${e.description.trim()}`),c.tag){case"bodyComponent":return{requestBody:{$ref:`#/components/requestBodies/${e.rawType}`}};case"bodyContent":return{requestBody:{content:{[e.name.replaceAll(String.raw`*\/*`,"*/*")]:{schema:e.schema}}}};case"bodyDescription":return{requestBody:{description:n}};case"bodyExample":{const[r,s]=e.name.split(".");return{requestBody:{content:{[r]:{examples:{[s]:{$ref:`#/components/examples/${e.rawType}`}}}}}}}case"bodyRequired":return{requestBody:{required:!0}};case"callback":return{callbacks:{[e.name]:{$ref:`#/components/callbacks/${e.rawType}`}}};case"cookieParam":case"headerParam":case"pathParam":case"queryParam":return{parameters:[{description:e.description,in:c.tag.replace($,""),name:e.name,required:e.required,schema:e.schema}]};case"deprecated":return{deprecated:!0};case"description":case"operationId":case"summary":return{[c.tag]:n};case"externalDocs":return{externalDocs:{description:e.description,url:e.name}};case"paramComponent":return{parameters:[{$ref:`#/components/parameters/${e.rawType}`}]};case"response":return{responses:{[e.name]:{description:e.description}}};case"responseComponent":return{responses:{[e.name]:{$ref:`#/components/responses/${e.rawType}`}}};case"responseContent":{const[r,s]=e.name.split(".");return{responses:{[r]:{content:{[s]:{schema:e.schema}}}}}}case"responseExample":{const[r,s,a]=e.name.split(".");return{responses:{[r]:{content:{[s]:{examples:{[a]:{$ref:`#/components/examples/${e.rawType}`}}}}}}}}case"responseHeader":{const[r,s]=e.name.split(".");return{responses:{[r]:{headers:{[s]:{description:e.description,schema:e.schema}}}}}}case"responseHeaderComponent":{const[r,s]=e.name.split(".");return{responses:{[r]:{headers:{[s]:{$ref:`#/components/headers/${e.rawType}`}}}}}}case"responseLink":{const[r,s]=e.name.split(".");return{responses:{[r]:{links:{[s]:{$ref:`#/components/links/${e.rawType}`}}}}}}case"security":{const[r,s]=e.name.split(".");let a=[];return s&&(a=[s]),{security:{[r]:a}}}case"server":return{servers:[{description:e.description,url:e.name}]};case"tag":return{tags:[n]};default:return{}}}),C=(t,o,c)=>(c??d(t,{spacing:"preserve"})).filter(e=>g.test(e.description.trim())).map(e=>{const n=e.tags.length+1,r={};for(const u of k(e.tags))l(r,u,y);h(r);const[s,a]=e.description.split(" "),p={[a.trim()]:{[s.toLowerCase().trim()]:{...r}}},i=JSON.parse(JSON.stringify({paths:p}));return{loc:n,spec:i}});export{C as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as f}from"node:fs";import p from"node:path";import{parse as u}from"comment-parser";import y from"yaml";import d from"./yamlLoc-DPq-xUM4.js";const i=new Set(["components","externalDocs","info","openapi","paths","security","servers","tags"]);class g extends Error{filePath}const l=new Set([".yaml",".yml"]),h=(t,o)=>{const r=y.parse(o);if(r===null||typeof r!="object")return[];const n=Object.keys(r).filter(e=>!i.has(e));if(n.length>0){const e=new g(`Unexpected keys: ${n.join(", ")}`);throw e.filePath=t,e}return Object.keys(r).some(e=>i.has(e))?[{loc:d(o),spec:r}]:[]},k=(t,o,r)=>{const n=f(t,{encoding:"utf8"}),e=p.extname(t);if(l.has(e))return h(t,n);try{return o(n,r)}catch(s){throw s.filePath=t,s}},O=(t,o,r)=>{const n=f(t,{encoding:"utf8"}),e=p.extname(t);if(l.has(e))return h(t,n);const s=u(n,{spacing:"preserve"}),c=[];for(const m of o)try{c.push(...m(n,r,s))}catch(a){throw a.filePath=t,a}return c};export{k as default,O as parseFileMulti};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{parse as f}from"comment-parser";import{mergeWith as m}from"es-toolkit";import y from"yaml";import{u as l}from"./customizer-BXFVpImq.js";const g=(s,t)=>{if(t===null)return s},h=(s,t)=>{const e=m({},s??{},g);return m(e,t??{},g)},d=s=>Object.keys(s).map(t=>s[t]).every(t=>typeof t=="object"&&Object.keys(t).every(e=>!(e in t))),u=(s,t)=>t.some(e=>s.name===e.name),v=s=>{switch(s.tag){case"asyncapi":return"v4";case"openapi":return"v3";case"swagger":return"v2";default:return"v2"}},w=(s,t,e)=>{if(e==="x-webhooks"&&(s[e]=t[e]),!e.startsWith("x-"))if(["components","consumes","produces","paths","schemas","securityDefinitions","responses","parameters","definitions","channels"].includes(e))Object.keys(t[e]).forEach(r=>{s[e][r]=h(s[e][r],t[e][r])});else if(e==="tags"){const{tags:r}=t;Array.isArray(r)?r.forEach(n=>{u(n,s.tags)||s.tags.push(n)}):u(r,s.tags)||s.tags.push(r)}else if(e==="security"){const{security:r}=t;s.security=r}else e.startsWith("/")&&(s.paths[e]=h(s.paths[e],t[e]))},E={v2:["paths","definitions","responses","parameters","securityDefinitions"],v3:["paths","definitions","responses","parameters","securityDefinitions","components"],v4:["components","channels"]},S=(s,t)=>s.map(e=>{const r=e.description!==""||e.name.startsWith("/")||e.name.endsWith(":");if((e.tag==="openapi"||e.tag==="swagger"||e.tag==="asyncapi")&&r){let n=e.description;(e.name.startsWith("/")||e.name.endsWith(":"))&&(n=n.trim()===""?e.name:`${e.name}
|
|
2
|
+
${n}`);const a=y.parseDocument(n);if(a.errors.length>0){a.errors.forEach(p=>{p.annotation=n});let i="Error parsing YAML in @openapi spec:";throw i+=t?a.errors.map(p=>`${p.toString()}
|
|
3
|
+
Imbedded within:
|
|
4
|
+
\`\`\`
|
|
5
|
+
${p.annotation?.replaceAll(`
|
|
6
|
+
`,`
|
|
7
|
+
`)}
|
|
8
|
+
\`\`\``).join(`
|
|
9
|
+
`):a.errors.map(p=>p.toString()).join(`
|
|
10
|
+
`),new Error(i)}const c=a.toJSON(),o={tags:[]};return E[v(e)].forEach(i=>{o[i]=o[i]??{}}),Object.keys(c).forEach(i=>{w(o,c,i)}),o}return{}}),O=new Set(["asyncapi","openapi","swagger"]),k=(s,t,e)=>(e??f(s,{spacing:"preserve"})).filter(r=>r.tags.some(n=>O.has(n.tag))).map(r=>{const n=r.tags.length+1,a={};for(const o of S(r.tags,t))m(a,o,l);["definitions","responses","parameters","securityDefinitions","components","tags"].forEach(o=>{a[o]!==void 0&&d(a[o])&&delete a[o]});const c=JSON.parse(JSON.stringify(a));return{loc:n,spec:c}});export{k as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/jsdoc-open-api",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.38",
|
|
4
4
|
"description": "Generates swagger doc based on JSDoc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -37,41 +37,23 @@
|
|
|
37
37
|
"email": "d.bannert@anolilab.de"
|
|
38
38
|
},
|
|
39
39
|
"sideEffects": false,
|
|
40
|
+
"type": "module",
|
|
40
41
|
"exports": {
|
|
41
42
|
".": {
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"default": "./dist/index.mjs"
|
|
45
|
-
},
|
|
46
|
-
"require": {
|
|
47
|
-
"types": "./dist/index.d.cts",
|
|
48
|
-
"default": "./dist/index.cjs"
|
|
49
|
-
}
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"default": "./dist/index.js"
|
|
50
45
|
},
|
|
51
46
|
"./cli": {
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
"default": "./dist/cli/index.mjs"
|
|
55
|
-
},
|
|
56
|
-
"require": {
|
|
57
|
-
"types": "./dist/cli/index.d.cts",
|
|
58
|
-
"default": "./dist/cli/index.cjs"
|
|
59
|
-
}
|
|
47
|
+
"types": "./dist/cli/index.d.ts",
|
|
48
|
+
"default": "./dist/cli/index.js"
|
|
60
49
|
},
|
|
61
50
|
"./cli/commander": {
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
"default": "./dist/cli/commander/index.mjs"
|
|
65
|
-
},
|
|
66
|
-
"require": {
|
|
67
|
-
"types": "./dist/cli/commander/index.d.cts",
|
|
68
|
-
"default": "./dist/cli/commander/index.cjs"
|
|
69
|
-
}
|
|
51
|
+
"types": "./dist/cli/commander/index.d.ts",
|
|
52
|
+
"default": "./dist/cli/commander/index.js"
|
|
70
53
|
},
|
|
71
54
|
"./package.json": "./package.json"
|
|
72
55
|
},
|
|
73
|
-
"
|
|
74
|
-
"module": "dist/index.mjs",
|
|
56
|
+
"module": "dist/index.js",
|
|
75
57
|
"types": "dist/index.d.ts",
|
|
76
58
|
"typesVersions": {
|
|
77
59
|
">=5.0": {
|
|
@@ -99,7 +81,7 @@
|
|
|
99
81
|
],
|
|
100
82
|
"dependencies": {
|
|
101
83
|
"@apidevtools/swagger-parser": "^12.1.0",
|
|
102
|
-
"@visulima/fs": "5.0.0-alpha.
|
|
84
|
+
"@visulima/fs": "5.0.0-alpha.33",
|
|
103
85
|
"comment-parser": "1.4.7",
|
|
104
86
|
"es-toolkit": "^1.47.1",
|
|
105
87
|
"yaml": "2.9.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../packem_shared/generateCommand-CmoN8jyY.cjs"),t=require("../../packem_shared/initCommand-C8s0kkim.cjs");exports.generateCommand=e;exports.initCommand=t;
|