@redocly/cli 2.60.0 → 2.62.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 (141) hide show
  1. package/THIRD_PARTY_NOTICES +24 -3
  2. package/lib/chunks/{AP2GA7RS.js → 22EANOP2.js} +87 -87
  3. package/lib/chunks/{B5GZ7KU2.js → 2EP764NP.js} +1 -1
  4. package/lib/chunks/2OVI7BIW.js +105 -0
  5. package/lib/chunks/{GYKYFMW3.js → 2XK7ML3U.js} +1 -1
  6. package/lib/chunks/{DAAOXDSB.js → 37WWN4MA.js} +1 -1
  7. package/lib/chunks/{IAN3UOJT.js → 3C6UUCEW.js} +1 -1
  8. package/lib/chunks/{S27TE7KZ.js → 3DEJQSYG.js} +1 -1
  9. package/lib/chunks/{SDNESV5E.js → 3JYY42DL.js} +1 -1
  10. package/lib/chunks/{SNR3DAVL.js → 4WO6ZSKT.js} +1 -1
  11. package/lib/chunks/53INGMTO.js +20 -0
  12. package/lib/chunks/5NOJ76EP.js +9 -0
  13. package/lib/chunks/{SXOXAG7R.js → 5PG3ST2N.js} +2 -2
  14. package/lib/chunks/{BHUCIWQF.js → 66GKT2TZ.js} +1 -1
  15. package/lib/chunks/{V46KUEYR.js → 6DO6IN4A.js} +1 -1
  16. package/lib/chunks/{2F2YM4RD.js → 6EGJEFXO.js} +1 -1
  17. package/lib/chunks/{MJYI42E6.js → 6NB3FKVN.js} +8 -8
  18. package/lib/chunks/{GHPOEF7A.js → 75SLMDAN.js} +1 -1
  19. package/lib/chunks/{CAJM6OL3.js → AB2EMYEK.js} +1 -1
  20. package/lib/chunks/{PKYNMOKV.js → AZO6SCNH.js} +1 -1
  21. package/lib/chunks/{LF35KJ5M.js → B2J7WNDG.js} +1 -1
  22. package/lib/chunks/C67OKMFJ.js +11 -0
  23. package/lib/chunks/{ZJAFKITR.js → DC2HDHGE.js} +1 -1
  24. package/lib/chunks/{XZKUPNLZ.js → DFWXX7E2.js} +1 -1
  25. package/lib/chunks/{HFGKPU2P.js → FDMXHRDK.js} +1 -1
  26. package/lib/chunks/{SL6UQOKE.js → G5N3UXMR.js} +1 -1
  27. package/lib/chunks/{HVO5F4MP.js → GVQMC2WB.js} +1 -1
  28. package/lib/chunks/{RDMFHSDB.js → HBENVUR4.js} +1 -1
  29. package/lib/chunks/HN2ZK7LZ.js +20 -0
  30. package/lib/chunks/I6AAWNTY.js +20 -0
  31. package/lib/chunks/{HSHAARAO.js → KPPPJNVL.js} +1 -1
  32. package/lib/chunks/{52MW7SRF.js → KRCCY64H.js} +1 -1
  33. package/lib/chunks/LNYTDBAU.js +12 -0
  34. package/lib/chunks/{4XDEFJCF.js → LRLGVYCG.js} +1 -1
  35. package/lib/chunks/{3MPID4OC.js → LVGVWPDB.js} +1 -1
  36. package/lib/chunks/{XHDOW23C.js → MNH2K4WM.js} +1 -1
  37. package/lib/chunks/{J4NCFMOR.js → N3GO4LRW.js} +1 -1
  38. package/lib/chunks/{GD6WKI2C.js → NBI4EQPC.js} +1 -1
  39. package/lib/chunks/{G4ZIYGF5.js → NENSYJQB.js} +1 -1
  40. package/lib/chunks/NFRA6IE2.js +7 -0
  41. package/lib/chunks/{O5WCU6SC.js → OMIM3KH6.js} +10 -10
  42. package/lib/chunks/{YNPWONFN.js → OP7NIAI7.js} +1 -1
  43. package/lib/chunks/{CKZ35ARL.js → OT7Y7FIM.js} +1 -1
  44. package/lib/chunks/{ACVFQG4D.js → PTNNX4IU.js} +1 -1
  45. package/lib/chunks/{UPHYYNN3.js → PXCT44HL.js} +5 -5
  46. package/lib/chunks/{HQUG6XPO.js → QAUXTHD6.js} +2 -2
  47. package/lib/chunks/{N4AA4DRD.js → R2TPTKNR.js} +1 -1
  48. package/lib/chunks/{UXSV2J6V.js → REIGI2Y7.js} +1 -1
  49. package/lib/chunks/{S5G22GL5.js → RGU6OZYB.js} +1 -1
  50. package/lib/chunks/{W3K4YAMS.js → RPHIT72T.js} +1 -1
  51. package/lib/chunks/{7C244K4X.js → RUIEI3YV.js} +1 -1
  52. package/lib/chunks/{NADFEIIN.js → S3STDXJN.js} +1 -1
  53. package/lib/chunks/{DJWI7SF7.js → S6NFOZ34.js} +1 -1
  54. package/lib/chunks/{VCV3FKMW.js → SLQPKXO2.js} +1 -1
  55. package/lib/chunks/{4WAQNM63.js → SS6PCAMM.js} +58 -12
  56. package/lib/chunks/{CEPC3LL4.js → SXBAAS4M.js} +1 -1
  57. package/lib/chunks/{7ED6ZTTH.js → SYWAPWW7.js} +1 -1
  58. package/lib/chunks/{S46ENZHC.js → T4Y6M5MJ.js} +1 -1
  59. package/lib/chunks/{O4RAFGZA.js → TBZEEKTV.js} +1 -1
  60. package/lib/chunks/{HNKSHJLU.js → TF4PPK4N.js} +1 -1
  61. package/lib/chunks/TWWNWQRB.js +7 -0
  62. package/lib/chunks/{EXCIOEBN.js → US7X4XPD.js} +1 -1
  63. package/lib/chunks/VGM6NIVC.js +8 -0
  64. package/lib/chunks/{QGUZ4KFX.js → VX2VONNO.js} +1 -1
  65. package/lib/chunks/{DTMC35L3.js → VXLODB3S.js} +1 -1
  66. package/lib/chunks/{4HEJ6GQB.js → WEOCCL26.js} +2 -2
  67. package/lib/chunks/{Q526MFO3.js → WQ3XMPU7.js} +1 -1
  68. package/lib/chunks/{2U6O26CV.js → XJE2OFDN.js} +116 -16
  69. package/lib/chunks/{WFIIXHF3.js → XJTGJYVS.js} +1 -1
  70. package/lib/chunks/YDVWNFMS.js +24 -0
  71. package/lib/chunks/{HZZP3BZQ.js → YPYZCXVX.js} +1 -1
  72. package/lib/chunks/{72ZX5WSN.js → ZYQDPQVA.js} +1 -1
  73. package/lib/eject-assets/AGENTS.md +24 -23
  74. package/lib/eject-assets/generators/cli/docs.ts +1 -1
  75. package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
  76. package/lib/eject-assets/generators/cli/index.ts +2 -2
  77. package/lib/eject-assets/generators/cli/render.ts +1 -1
  78. package/lib/eject-assets/generators/go/client.ts +1 -1
  79. package/lib/eject-assets/generators/go/descriptor.ts +1 -1
  80. package/lib/eject-assets/generators/go/index.ts +2 -2
  81. package/lib/eject-assets/generators/go/models.ts +1 -1
  82. package/lib/eject-assets/generators/go/naming.ts +1 -1
  83. package/lib/eject-assets/generators/go/operations.ts +35 -3
  84. package/lib/eject-assets/generators/go/pagination.ts +1 -1
  85. package/lib/eject-assets/generators/go/types.ts +1 -1
  86. package/lib/eject-assets/generators/mock/faker.ts +1 -1
  87. package/lib/eject-assets/generators/mock/index.ts +2 -2
  88. package/lib/eject-assets/generators/mock/render.ts +1 -1
  89. package/lib/eject-assets/generators/mock/sample.ts +1 -1
  90. package/lib/eject-assets/generators/mock/values.ts +1 -1
  91. package/lib/eject-assets/generators/php/client.ts +1 -1
  92. package/lib/eject-assets/generators/php/descriptor.ts +1 -1
  93. package/lib/eject-assets/generators/php/index.ts +2 -2
  94. package/lib/eject-assets/generators/php/models.ts +1 -1
  95. package/lib/eject-assets/generators/php/naming.ts +1 -1
  96. package/lib/eject-assets/generators/php/operations.ts +21 -3
  97. package/lib/eject-assets/generators/php/pagination.ts +1 -1
  98. package/lib/eject-assets/generators/php/types.ts +1 -1
  99. package/lib/eject-assets/generators/python/client.ts +1 -1
  100. package/lib/eject-assets/generators/python/descriptor.ts +1 -1
  101. package/lib/eject-assets/generators/python/index.ts +2 -2
  102. package/lib/eject-assets/generators/python/models.ts +1 -1
  103. package/lib/eject-assets/generators/python/naming.ts +1 -1
  104. package/lib/eject-assets/generators/python/operations.ts +19 -6
  105. package/lib/eject-assets/generators/python/pagination.ts +1 -1
  106. package/lib/eject-assets/generators/python/types.ts +1 -1
  107. package/lib/eject-assets/generators/swr/index.ts +2 -2
  108. package/lib/eject-assets/generators/swr/render.ts +1 -1
  109. package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
  110. package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
  111. package/lib/eject-assets/generators/transformers/index.ts +2 -2
  112. package/lib/eject-assets/generators/transformers/render.ts +1 -1
  113. package/lib/eject-assets/generators/typescript/banner.ts +1 -1
  114. package/lib/eject-assets/generators/typescript/client.ts +1 -1
  115. package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
  116. package/lib/eject-assets/generators/typescript/index.ts +2 -2
  117. package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  118. package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
  119. package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
  120. package/lib/eject-assets/generators/typescript/operations.ts +3 -4
  121. package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
  122. package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
  123. package/lib/eject-assets/generators/typescript/types.ts +1 -1
  124. package/lib/eject-assets/generators/zod/index.ts +2 -2
  125. package/lib/eject-assets/generators/zod/schemas.ts +1 -1
  126. package/lib/eject-assets/skills/client-generators/SKILL.md +24 -23
  127. package/lib/eject-assets/skills/go-generator/SKILL.md +11 -0
  128. package/lib/eject-assets/skills/php-generator/SKILL.md +16 -0
  129. package/lib/eject-assets/skills/python-generator/SKILL.md +13 -0
  130. package/lib/eject-assets/skills/typescript-generator/SKILL.md +16 -0
  131. package/lib/index.js +55 -55
  132. package/package.json +1 -1
  133. package/lib/chunks/BZBFESBB.js +0 -11
  134. package/lib/chunks/DJXBNZCO.js +0 -7
  135. package/lib/chunks/GC26XZYZ.js +0 -20
  136. package/lib/chunks/IJ43XWPG.js +0 -20
  137. package/lib/chunks/MCJLOALK.js +0 -22
  138. package/lib/chunks/OKTLNLO3.js +0 -7
  139. package/lib/chunks/PGZIUA7J.js +0 -105
  140. package/lib/chunks/W7VT3BOM.js +0 -9
  141. package/lib/chunks/XQA4EEZA.js +0 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/cli",
3
- "version": "2.60.0",
3
+ "version": "2.62.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,11 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{a as f,m as u}from"./UW4UC7ZI.js";function m(e,t){let n=t??{},i=e.specName??e.name;if(Array.isArray(n.exclude)&&n.exclude.includes(i))return;let r=(n.operations??{})[i]??e.paginationExtension;if(r===void 0&&typeof n.style=="string"){let{exclude:c,operations:B,...l}=n,g=l.style==="cursor"?l.cursorParam:l.offsetParam;(l.style==="link"?e.successResponseHeaders?.some(p=>p.name==="link")===!0:typeof g=="string"&&e.queryParams.some(p=>p.name===g))&&(r=l)}if(r===void 0||typeof r.style!="string")return;let s=r.style==="cursor"?r.cursorParam:r.offsetParam;return{style:r.style,...typeof s=="string"?{param:s}:{},...typeof r.nextCursor=="string"?{nextCursor:r.nextCursor}:{},...typeof r.hasMore=="string"?{hasMore:r.hasMore}:{},...typeof r.limitParam=="string"?{limitParam:r.limitParam}:{},...typeof r.items=="string"?{items:r.items}:{}}}function h(e){return e.successResponses.find(t=>t.contentType.toLowerCase().includes("json"))?.schema}function x(e){return e.successResponses.find(t=>t.contentType.toLowerCase().includes("text/event-stream"))}function k(e){return e.requestBody?.contentType.toLowerCase().includes("multipart")??!1}var R=["application/octet-stream","application/pdf","image/","audio/","video/","font/","application/x-font-","application/zip","application/x-zip-compressed","application/gzip","application/x-gzip","application/x-bzip2","application/x-tar","application/x-rar-compressed","application/x-7z-compressed","application/vnd.openxmlformats-officedocument","application/vnd.ms-excel","application/vnd.ms-powerpoint","application/msword","application/x-shockwave-flash"];function d(e){let t=e.split(";")[0].trim().toLowerCase();return R.some(n=>t.startsWith(n))}function b(e){let t=new Set(e.variables.map(s=>s.name)),n=[],i="",a=e.url,r=/\{([^{}]+)\}/;for(let s=r.exec(a);s!==null;s=r.exec(a))i+=a.slice(0,s.index),t.has(s[1])?(i!==""&&n.push({kind:"literal",value:i}),i="",n.push({kind:"variable",name:s[1]})):i+=s[0],a=a.slice(s.index+s[0].length);return i+=a,(i!==""||n.length===0)&&n.push({kind:"literal",value:i}),n}function S(e,t){return e.security.map(n=>n.flatMap(i=>{let a=t.securitySchemes.find(r=>r.key===i);return a===void 0?[]:a.kind==="bearer"||a.kind==="basic"?[{scheme:i,kind:a.kind}]:a.kind==="apiKeyHeader"?[{scheme:i,kind:"apiKey",name:a.headerName,in:"header"}]:a.kind==="apiKeyQuery"?[{scheme:i,kind:"apiKey",name:a.paramName,in:"query"}]:[{scheme:i,kind:"apiKey",name:a.cookieName,in:"cookie"}]})).filter(n=>n.length>0)}function $(e,t,n){if(e===void 0||t===void 0)return;let i=u(e,t,n);return i?.kind==="array"?i.items:void 0}function y(e){return(e??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function o(e){switch(e.kind){case"ref":return e.name;case"omit":return e.base;case"scalar":return e.scalar;case"array":return`array of ${o(e.items)}`;case"record":return`map of ${o(e.value)}`;case"enum":{let t=e.values.map(String),n=t.slice(0,6).join(", ");return t.length>6?`enum: ${n}, and ${t.length-6} more`:`enum: ${n}`}case"literal":return String(e.value);case"union":return e.members.map(o).join(" or ");case"intersection":return e.members.map(o).join(" and ");case"object":return"object";case"null":return"null";case"unknown":return"any"}}function P(e){return e.successResponses.some(t=>t.contentType.toLowerCase().includes("json"))?!1:e.successResponses.some(t=>d(t.contentType))}function T(e,t){e.line("| Parameter | In | Type | Required | Description |"),e.line("| --------- | -- | ---- | -------- | ----------- |");for(let n of t)e.line(`| \`${n.name}\` | ${n.in} | ${y(o(n.schema))} | ${n.required?"yes":"no"} | ${y(n.description)} |`);e.blank()}function C(e,t,n){e.line(`### \`${t.specName??t.name}\``),e.blank(),t.summary!==void 0&&(e.line(y(t.summary)),e.blank()),e.line(`\`${t.method.toUpperCase()} ${t.path}\``),e.blank();let i=n.sample(t);if(i!==void 0){e.line("```"+n.language.fence);for(let c of i.source.replace(/\n+$/,"").split(`
8
- `))e.line(c);e.line("```"),e.blank()}let a=[...t.pathParams,...t.queryParams,...t.headerParams];a.length>0&&T(e,a),t.requestBody!==void 0&&e.line(`Body: \`${t.requestBody.contentType}\`${t.requestBody.required?", required":", optional"}, of type ${o(t.requestBody.schema)}.`);let r=t.successResponses[0];e.line(r===void 0?"Returns no content.":`Returns \`${r.contentType}\`, of type ${o(r.schema)}.`),(n.paginated!==void 0?n.paginated.has(t.name):m(t,n.pagination)!==void 0)&&e.line("This operation is paginated, so the SDK gives it page and item iterators."),t.successResponses.some(c=>c.contentType==="text/event-stream")&&e.line("This operation streams server-sent events, so the SDK iterates the events."),P(t)&&e.line("This operation returns binary content."),e.blank()}function v(e,t){let n=new f;if(t.frontmatter&&(n.line("---"),n.line(`title: ${t.title}`),n.line("---"),n.blank()),n.line(`# ${t.title}`),n.blank(),n.line(`Generated reference for the ${t.language.label} SDK, produced from the API description by \`redocly generate-client\`.`),n.line("Re-run generation to update it \u2014 this file is not hand-edited."),n.blank(),n.line(t.language.requires),n.blank(),n.line("## Authentication"),n.blank(),e.securitySchemes.length===0)n.line("The description declares no security schemes.");else{n.line("The description declares these schemes, which you pass to the client:"),n.blank(),n.line("| Scheme | Kind | Sent as |"),n.line("| ------ | ---- | ------- |");for(let r of e.securitySchemes){let s=r.kind==="bearer"?"`Authorization: Bearer <token>`":r.kind==="basic"?"`Authorization: Basic <base64>`":r.kind==="apiKeyHeader"?`the \`${r.headerName}\` header`:r.kind==="apiKeyQuery"?`the \`${r.paramName}\` query parameter`:`the \`${r.cookieName}\` cookie`;n.line(`| \`${r.key}\` | ${r.kind} | ${s} |`)}}n.blank();let i=e.services.flatMap(r=>r.operations),a=[...new Set(i.map(r=>r.tags[0]))];for(let r of a){n.line(r===void 0?"## Operations":`## ${r}`),n.blank();for(let s of i.filter(c=>c.tags[0]===r))C(n,s,t)}return n.toString().replace(/\n{3,}/g,`
9
-
10
- `).trimEnd()+`
11
- `}var ee=["Printer","casing","identifierFor","uniqueIdentifiers","RESERVED_WORDS","flattenAllOf","deref","discriminatorCases","jsonSuccessSchema","sseResponse","isMultipartBody","isBinaryContentType","serverUrlParts","securityRequirements","paginationItemSchema","isNullable","unwrapNullable","enumValues","docText","headerCoerceType","schemaAtPointer","paginationRuleFor","renderReferencePage","NotSupportedError"];function E(e){return e}function w(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-")}function A(e){return e.replace(/[^A-Za-z0-9]+/g,"_").replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}function q(e,t){let n={...e};for(let[i,a]of Object.entries(t))a!==void 0&&(n[i]=a);return n}function de(e){return e}async function ke(e){return(await import("./SL6UQOKE.js")).generateClient(e)}export{m as a,h as b,x as c,k as d,d as e,b as f,S as g,$ as h,v as i,ee as j,E as k,w as l,A as m,q as n,de as o,ke as p};
@@ -1,7 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{a as R,b as u,c as f,d}from"./XZKUPNLZ.js";import{d as y,e as G,f as x}from"./XQA4EEZA.js";import{c as g,d as S,e as h}from"./IJ43XWPG.js";import{c as k,d as v,e as b}from"./GC26XZYZ.js";import{a as D,b as E,c as q,d as z}from"./Q526MFO3.js";import{a as o}from"./BHUCIWQF.js";import{a,b as p,c as s}from"./ZJAFKITR.js";import"./2U6O26CV.js";import{a as m}from"./J4NCFMOR.js";import{a as i}from"./JM7BMZLD.js";import{a as c}from"./LF35KJ5M.js";import"./NADFEIIN.js";import{a as I,d as M,e as N}from"./O5WCU6SC.js";import{a as l}from"./PKYNMOKV.js";import{a as H,b as er,c as tr,d as or,e as nr,f as ar,g as pr,h as sr,i as mr,j as ir}from"./BZBFESBB.js";import"./4WAQNM63.js";import{a as U}from"./WZXA5XPB.js";import"./AP2GA7RS.js";import"./NEWT5A6S.js";import{e as T,h as j,k as w}from"./LD5MEXEL.js";import{a as _,b as B,c as F,d as J,e as Q,f as K,g as P,h as V,i as W,j as X,k as Y,l as Z,m as $,n as rr}from"./UW4UC7ZI.js";import"./RFWIIJFG.js";var A={typescript:{run:a,sample:s,docs:p},zod:{run:m},transformers:{run:i},"tanstack-query":{run:o("react")},"tanstack-query-vue":{run:o("vue")},"tanstack-query-svelte":{run:o("svelte")},"tanstack-query-solid":{run:o("solid")},swr:{run:c},mock:{run:l},cli:{run:u,sample:d,docs:f},python:{run:y,sample:G,docs:x},go:{run:g,sample:S,docs:h},php:{run:k,sample:v,docs:b}},L=Object.fromEntries(Object.entries(D).map(([e,{load:r,...t}])=>[e,{...t,...A[e]}]));function n(){return new Map(Object.entries(L))}function C(e,r,t=n(),O){E(e,r,t,O)}function Dr(e,r){let t=r.registry??n();return C(r.generators,r.emit,t,r.outputMode),q(e,{...r,registry:t})}export{ir as AUTHORING_HELPER_NAMES,U as NotSupportedError,_ as Printer,F as RESERVED_WORDS,B as casing,j as codeLiteral,Dr as collectGeneratedFiles,K as deref,V as discriminatorCases,Z as docText,Y as enumValues,P as flattenAllOf,z as generateClient,rr as headerCoerceType,J as identifierFor,nr as isBinaryContentType,or as isMultipartBody,W as isNullable,er as jsonSuccessSchema,I as operationSignature,sr as paginationItemSchema,H as paginationRuleFor,w as pascalCase,R as renderComposedCliEntry,mr as renderReferencePage,T as safeIdent,$ as schemaAtPointer,pr as securityRequirements,ar as serverUrlParts,tr as sseResponse,M as tsJsdoc,N as tsType,Q as uniqueIdentifiers,X as unwrapNullable};
@@ -1,20 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{b as B}from"./2U6O26CV.js";import{b as E,c as T,d as W,f as ee,g as ne,h as te,i as re}from"./BZBFESBB.js";import{a as Y,c as C,d as p,e as w,f as x,g as D,h as O,i as X,j,k as I,l as F,n as Z}from"./UW4UC7ZI.js";var U=C.php,q=class extends Y{constructor(){super(" ")}typeName(n){return p(n,{style:"pascal",reserved:U})}memberName(n){return p(n,{style:"camel",reserved:U})}identifier(n){return p(n,{style:"camel",reserved:U})}identifiers(n,s){return w(n,{style:"camel",reserved:U,taken:s})}string(n){return`'${n.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}literal(n){return n==null?"null":typeof n=="boolean"||typeof n=="number"?String(n):typeof n=="string"?this.string(n):Array.isArray(n)?`[${n.map(i=>this.literal(i)).join(", ")}]`:`[${Object.entries(n).map(([i,r])=>`${this.string(i)} => ${this.literal(r)}`).join(", ")}]`}comment(n){for(let s of F(n))this.line(s===""?"//":`// ${s}`);return this}doc(n,s,i=[]){let r=F(s);if(r.length===0&&i.length===0)return this;let t=r.length===0?n:`${n} \u2014 ${r.join(" ")}`;if(i.length===0)return this.line(`/** ${t} */`);this.line("/**"),this.line(` * ${t}`),this.line(" *");for(let a of i)this.line(` * ${a}`);return this.line(" */")}};var h=C.php,G=new q;function y(e){return G.typeName(e)}function b(e){return G.memberName(e)}function c(e){return G.string(e)}function ie(e){return p(e.name,{style:"camel",reserved:h})}function K(e){let n=e.services.flatMap(i=>i.operations),s=w(n.map(i=>i.name),{style:"camel",reserved:h});return new Map(n.map((i,r)=>[i.name,s[r]]))}function de(e){return ee(e).map(s=>s.kind==="literal"?c(s.value):`$${b(s.name)}`).join(" . ")}function se(e,n){let s=n.servers??[];if(s.length===0)return;let i=new Set;e.line("/** The declared servers; variables default to the values from the description. */"),e.line("final class Servers"),e.block("{",()=>{s.forEach((r,t)=>{let a=p(r.description??`server${t+1}`,{style:"camel",reserved:h});i.has(a)&&(a=`${a}${t+1}`),i.add(a);let o=r.variables.map(l=>`string $${b(l.name)} = ${c(l.default)}`);t>0&&e.blank(),e.line(`public static function ${a}(${o.join(", ")}): string`),e.block("{",()=>{e.line(`return ${de(r)};`)},"}")})},"}"),e.blank()}function ae(e,n){let s=ne(e,n).map(i=>`[${i.map(t=>t.kind==="apiKey"?`['kind' => 'apiKey', 'scheme' => ${c(t.scheme)}, 'name' => ${c(t.name)}, 'in' => ${c(t.in)}]`:`['kind' => ${c(t.kind)}, 'scheme' => ${c(t.scheme)}]`).join(", ")}]`);if(s.length!==0)return`[${s.join(", ")}]`}function oe(e){return`[${[`'style' => ${c(e.style)}`,...e.param!==void 0?[`'param' => ${c(e.param)}`]:[],...e.nextCursor!==void 0?[`'nextCursor' => ${c(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`'hasMore' => ${c(e.hasMore)}`]:[],...e.limitParam!==void 0?[`'limitParam' => ${c(e.limitParam)}`]:[],...e.items!==void 0?[`'items' => ${c(e.items)}`]:[]].join(", ")}]`}function ce(e,n){let s=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let t=p(r.name,{style:"camel",reserved:h}),a=2;for(;s.has(t);)t=`${p(r.name,{style:"camel",reserved:h})}_${a++}`;s.add(t);let o=Z(r.schema,n);return`[${c(r.name)}, ${c(t)}, ${c(o)}]`}).join(", ")}]`}function _(e,n){let s=n.schemas.find(t=>t.name===e);if(s===void 0)return"other";let i=s.schema,r=I(i);return r!==void 0&&(r.scalar==="string"||r.scalar==="integer")?"enum":(i.kind==="object"||i.kind==="intersection")&&D(i,n)!==void 0?"class":"other"}function m(e,n,s="string"){if(X(e)){let i=m(j(e),n,s);return A(i)}switch(e.kind){case"scalar":return s==="Date"&&e.scalar==="string"&&L(e)?"\\DateTimeImmutable":{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":case"record":return"array";case"ref":{let i=_(e.name,n);if(i==="class"||i==="enum")return y(e.name);let r=x(e,n);return r===void 0?"mixed":m(r,n,s)}case"enum":return{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float";case"omit":return y(e.base);case"union":return me(e.members,n,s);case"null":case"object":case"intersection":case"unknown":return"mixed"}}function L(e){let n=e.metadata?.format;return n==="date"||n==="date-time"}function A(e){return e==="mixed"||e.startsWith("?")||e.endsWith("|null")?e:e.includes("|")?`${e}|null`:`?${e}`}function me(e,n,s){let i=[];for(let r of e){if(r.kind==="null")continue;let t=m(r,n,s);if(t==="mixed")return"mixed";let a=t.startsWith("?")?t.slice(1):t;i.includes(a)||i.push(a),t.startsWith("?")&&!i.includes("null")&&i.push("null")}return i.length===0?"mixed":i.join("|")}function J(e,n,s){if(e===void 0)return;let i=j(e);if(i.kind==="ref"){let t=x(i,n);return _(i.name,n)==="other"?J(t,n,s):void 0}if(i.kind!=="array")return;let r=m(i.items,n,s);return r==="mixed"?void 0:r}function le(e,n){let s=n.schemas.find(i=>i.name===e);return s!==void 0&&O(s.schema,n)!==void 0}function v(e,n,s,i){let r=j(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"&&L(r))return`new \\DateTimeImmutable(${n})`;if(r.kind==="omit")return v({kind:"ref",name:r.base},n,s,i);if(r.kind==="ref"){let t=_(r.name,s);if(t==="class")return`${y(r.name)}::fromArray(${n})`;if(t==="enum")return`${y(r.name)}::from(${n})`;if(le(r.name,s))return`unmarshal${y(r.name)}(${n})`;let a=x(r,s);return a===void 0?void 0:v(a,n,s,i)}if(r.kind==="array"){let t=v(r.items,"$item",s,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}if(r.kind==="record"){let t=v(r.value,"$item",s,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}}function N(e,n,s,i="string"){let r=j(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"){if(r.metadata?.format==="date")return`${n}->format('Y-m-d')`;if(r.metadata?.format==="date-time")return`${n}->format(\\DateTimeInterface::ATOM)`}if(r.kind==="omit")return N({kind:"ref",name:r.base},n,s,i);if(r.kind==="ref"){let t=_(r.name,s);if(t==="class")return`${n}->toArray()`;if(t==="enum")return`${n}->value`;if(le(r.name,s))return`is_object(${n}) ? ${n}->toArray() : ${n}`;let a=x(r,s);return a===void 0?void 0:N(a,n,s,i)}if(r.kind==="array"||r.kind==="record"){let t=r.kind==="array"?r.items:r.value,a=N(t,"$item",s,i);return a===void 0?void 0:`array_map(static fn ($item) => ${a}, ${n})`}}function pe(e,n,s,i,r,t){let a=[...s.filter(o=>o.required),...s.filter(o=>!o.required)];e.doc(y(n),t),e.line(`final class ${y(n)}`),e.block("{",()=>{e.block("public function __construct(",()=>{for(let o of a){let l=m(o.schema,i,r);if(o.required)e.line(`public ${l} $${b(o.name)},`);else{let u=A(l);e.line(`public ${u} $${b(o.name)} = null,`)}}},") {"),e.line("}"),e.blank(),e.line("public static function fromArray(array $data): self"),e.block("{",()=>{e.block("return new self(",()=>{for(let o of a){let l=`$data[${c(o.name)}]`,u=v(o.schema,l,i,r),f=b(o.name);o.required?e.line(`${f}: ${u??l},`):u===void 0?e.line(`${f}: ${l} ?? null,`):e.line(`${f}: isset(${l}) ? ${u} : null,`)}},");")},"}"),e.blank(),e.line("public function toArray(): array"),e.block("{",()=>{e.line("$data = [];");for(let o of a){let l=`$this->${b(o.name)}`,u=N(o.schema,l,i,r)??l;o.required?e.line(`$data[${c(o.name)}] = ${u};`):e.block(`if (${l} !== null) {`,()=>{e.line(`$data[${c(o.name)}] = ${u};`)},"}")}e.line("return $data;")},"}")},"}"),e.blank()}function V(e,n="string"){let s=new q;for(let{name:i,schema:r}of e.schemas){let t=I(r);if(t!==void 0&&(t.scalar==="string"||t.scalar==="integer")){let o=t.scalar==="string"?"string":"int";s.doc(y(i),r.description),s.line(`enum ${y(i)}: ${o}`),s.block("{",()=>{let l=w(t.values.map(u=>String(u)),{style:"pascal",reserved:h});t.values.forEach((u,f)=>{let g=typeof u=="string"?c(u):String(u);s.line(`case ${l[f]} = ${g};`)})},"}"),s.blank();continue}if(r.kind==="object"||r.kind==="intersection"){let o=D(r,e);if(o!==void 0){pe(s,i,o.properties,e,n,o.description??r.description);continue}}let a=O(r,e);if(a!==void 0){let o=y(i),l=a.cases.map(u=>`${u.value} -> ${y(u.schemaName)}`).join(", ");s.line(`/** ${o} is a discriminated union (${c(a.property)}): ${l}. */`),s.line(`function unmarshal${o}(array $data): mixed`),s.block("{",()=>{s.block(`return match ($data[${c(a.property)}] ?? null) {`,()=>{for(let u of a.cases)s.line(`${c(u.value)} => ${y(u.schemaName)}::fromArray($data),`);s.line("default => $data,")},"};")},"}"),s.blank();continue}}return s.toString()}var ue=new Set(["post","put","patch"]),he=["body","headers","idempotencyKey"];function z(e,n,s,i){let r=w([...e.pathParams,...e.queryParams].map(l=>l.name),{style:"camel",reserved:h,taken:he}),t=e.pathParams.map((l,u)=>({php:r[u],wire:l.name,type:m(l.schema,n,i)})),a=e.queryParams.map((l,u)=>{let f=r[e.pathParams.length+u];return{php:f,wire:l.name,type:m(l.schema,n,i),value:N(l.schema,`$${f}`,n,i)??`$${f}`}}),o=[...t.map(({php:l,type:u})=>`${u} $${l}`),...s&&e.requestBody?[`${W(e)?"array":m(e.requestBody.schema,n,i)} $body`]:[],...a.map(({php:l,type:u})=>`${A(u)} $${l} = null`),"?array $headers = null",...s&&ue.has(e.method.toLowerCase())?["?string $idempotencyKey = null"]:[]];return{pathArgs:t,queryArgs:a,signature:o}}function ye(e,n,s){e.line(`$op = self::OPERATIONS[${c(n.specName??n.name)}];`),e.line("[$authHeaders, $query, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);");for(let{php:r,wire:t,value:a}of s.queryArgs)e.block(`if ($${r} !== null) {`,()=>{e.line(`$query[${c(t)}] = ${a};`)},"}");let i=s.pathArgs.map(({php:r,wire:t})=>`${c(t)} => $${r}`).join(", ");e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${i}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}")}function Q(e,n,s,i,r,t=!1){let a=z(n,i,!0,r),o=T(n),l=E(n),u=o===void 0&&l===void 0&&n.successResponses.some(k=>k.contentType!==""),f=t?"Envelope":o!==void 0?"\\Generator":l!==void 0?m(l,i,r):u?"string":"void",g=t?`${s}WithHeaders`:s,H=t?void 0:J(l,i,r);e.doc(g,t?`Like ${s}(), returning an Envelope with the declared response headers.`:n.summary??`${n.method.toUpperCase()} ${n.path}`,H===void 0?[]:[`@return ${H}[]`]),e.line(`public function ${g}(${a.signature.join(", ")}): ${f}`),e.block("{",()=>{if(ye(e,n,a),o!==void 0){let d=o.schema!==void 0&&o.schema.kind!=="unknown";e.line("$url = appendQuery($url, $query);"),e.block("$open = function (array $extraHeaders) use ($url, $requestHeaders): \\CurlHandle {",()=>{e.line("$handle = curl_init($url);"),e.line("$lines = [];"),e.block("foreach (array_merge($requestHeaders, $extraHeaders) as $name => $value) {",()=>{e.line("$lines[] = $name . ': ' . $value;")},"}"),e.line("curl_setopt($handle, CURLOPT_HTTPHEADER, $lines);"),e.line("return $handle;")},"};"),e.line(`yield from iterSse($open, ${d?"true":"false"});`);return}let k=["'operationId' => $op['id']","'method' => $op['method']","'url' => $url","'headers' => $requestHeaders","'query' => $query"];if(n.requestBody&&W(n))e.line("[$contentType, $encoded] = toMultipart($body);"),k.push("'body' => $encoded","'contentType' => $contentType");else if(n.requestBody){let d=N(n.requestBody.schema,"$body",i,r)??"$body";e.line(`$payload = json_encode(${d});`),k.push("'body' => $payload",`'contentType' => ${c(n.requestBody.contentType)}`)}ue.has(n.method.toLowerCase())&&n.requestBody&&k.push("'idempotencyKey' => $idempotencyKey"),e.line(`$response = send($this->config, [${k.join(", ")}]);`),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}");let $=u?"$response['body']":(l===void 0?void 0:v(l,"decodeJson($response)",i,r))??"decodeJson($response)";if(t){e.line(`$data = ${$};`),e.line(`return new Envelope(data: $data, headers: readEnvelopeHeaders($response, ${ce(n,i)}), status: $response['status']);`);return}if(u){e.line("return $response['body'];");return}if(f==="void"){e.line("decodeJson($response);");return}e.line(`return ${$};`)},"}"),e.blank()}function $e(e,n,s,i,r,t,a,o,l){let u=z(n,i,!1,r),f=s,g=()=>{e.line(`$op = self::OPERATIONS[${c(n.specName??n.name)}];`),e.line("$base = [];");for(let{php:d,wire:P,value:S}of u.queryArgs)e.block(`if ($${d} !== null) {`,()=>{e.line(`$base[${c(P)}] = ${S};`)},"}");let $=u.pathArgs.map(({php:d,wire:P})=>`${c(P)} => $${d}`).join(", ");e.block("$call = function (array $params) use ($op, $headers): array {",()=>{e.line("[$authHeaders, $authQuery, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);"),e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${$}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}"),e.line("$response = send($this->config, ['operationId' => $op['id'], 'method' => $op['method'], 'url' => $url, 'headers' => $requestHeaders, 'query' => array_merge($params, $authQuery)]);"),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}"),e.line("return [decodeJson($response), $response];")},"};")},H=m(E(n)??{kind:"unknown"},i,r),k=H==="mixed"?"mixed":H;e.line("/**"),e.line(` * ${f} response pages, following the pagination rule automatically.`),e.line(" *"),e.line(` * @return \\Generator<int, ${k}>`),e.line(" */"),e.line(`public function ${f}Pages(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`yield ${t??"$page"};`)},"}")},"}"),e.blank(),e.line("/**"),e.line(` * The items of every ${f} page.`),e.line(" *"),e.line(` * @return \\Generator<int, ${l}>`),e.line(" */"),e.line(`public function ${f}Items(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`$items = resolvePointer($page, ${c(o??"")});`),e.block("foreach (is_array($items) ? $items : [] as $item) {",()=>{e.line(`yield ${a??"$item"};`)},"}")},"}")},"}"),e.blank()}function ge(e){let n=e.split(`
8
- `),s=0;for(let i=0;i<n.length;i++)if(n[i].trim().startsWith("namespace ")){s=i+1;break}return n.slice(s).join(`
9
- `).trim()}var ln=({model:e,output:n,banner:s,emit:i,pagination:r})=>{let t=new q,a=i.dateType??"string",o=p(e.title,{style:"pascal",reserved:h});t.line("<?php"),t.blank(),t.line(`// Code generated by @redocly/client-generator (php) from ${c(e.title)} ${e.version}. DO NOT EDIT.`),t.line("// Regenerate with `redocly generate-client`. PHP >= 8.1, curl extension \u2014 zero Composer dependencies."),t.blank(),t.line("declare(strict_types=1);"),t.blank(),t.line(`namespace ${o};`),t.blank(),t.line(V(e,a)),se(t,e),i.runtime==="module"?(t.line("// \u2500\u2500\u2500 Runtime (a real file beside this one, written by the same run) \u2500\u2500\u2500"),t.line("require_once __DIR__ . '/runtime.php';"),t.blank()):(t.line("// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator php runtime) \u2500\u2500\u2500"),t.line(ge(B)),t.blank());let l=e.services.flatMap($=>$.operations),u=K(e),f=new Map;for(let $ of l){let d=r?.get($.name)?.spec;d!==void 0&&f.set($.name,d)}t.doc("Client",`Client for ${e.title} (${e.version}).`),t.line("class Client"),t.block("{",()=>{t.block("public const OPERATIONS = [",()=>{for(let $ of l){let d=$.specName??$.name,P=ae($,e),S=f.get($.name),M=[`'id' => ${c(d)}`,`'method' => ${c($.method.toUpperCase())}`,`'path' => ${c($.path)}`,...P!==void 0?[`'security' => ${P}`]:[],...S!==void 0?[`'pagination' => ${oe(S)}`]:[]];t.line(`${c(d)} => [${M.join(", ")}],`)}},"];"),t.blank(),t.line("public function __construct(private Config $config)"),t.block("{",()=>{t.block("if ($this->config->serverUrl === '') {",()=>{t.line(`$this->config->serverUrl = ${c(i.serverUrl??e.serverUrl??"")};`)},"}")},"}"),t.blank();for(let $ of l){let d=u.get($.name);Q(t,$,d,e,a),T($)===void 0&&($.successResponseHeaders?.length??0)>0&&Q(t,$,d,e,a,!0);let P=f.get($.name);if(P===void 0)continue;let S=E($),M=S===void 0?void 0:v(S,"$page",e,a),R=te(S,P.items,e),fe=R===void 0?void 0:v(R,"$item",e,a);$e(t,$,d,e,a,M,fe,P.items,R===void 0?"mixed":m(R,e,a))}},"}");let g={path:n.path.replace(/\.[^.\\/]+$/,".php"),content:t.toString()};if(i.runtime!=="module")return[g];let H=s.map($=>`// ${$}`).join(`
10
- `),k=B.replace(/^namespace .*$/m,`namespace ${o};`).replace(/^<\?php\n/,`<?php
11
-
12
- ${H}
13
- `).trimEnd();return[g,{path:g.path.replace(/[^\\/]+$/,"runtime.php"),content:`${k}
14
- `}]};function be(e,n){let s=[...e.pathParams.map(t=>`${c(`<${b(t.name)}>`)}`),...e.requestBody?["$body"]:[],...e.queryParams.length>0?[`${b(e.queryParams[0].name)}: ${c("<value>")}`]:[]],i=p(n.model.title,{style:"pascal",reserved:h});return{lang:"php",label:"PHP SDK",source:`require '${n.outputPath.replace(/^.*[\\/]/,"").replace(/\.[^.]+$/,".php")}';
15
-
16
- use ${i}\\{Client, Config};
17
-
18
- $client = new Client(new Config());
19
- $result = $client->${K(n.model).get(e.name)??ie(e)}(${s.join(", ")});
20
- `}}var un=({model:e,output:n,emit:s,pagination:i})=>[{path:n.path.replace(/\.[^.\\/]+$/,".php.md"),content:re(e,{title:`${e.title} PHP SDK reference`,frontmatter:s.docsFrontmatter===!0,language:{name:"php",label:"PHP",fence:"php",requires:"The SDK needs the curl extension."},sample:r=>be(r,{model:e,emit:s,outputPath:n.path}),paginated:new Set(i?.keys()??[])})}];export{m as a,V as b,ln as c,be as d,un as e};
@@ -1,20 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{a as O}from"./2U6O26CV.js";import{b as j,c as N,d as J,f as V,g as Q,h as Z,i as Y}from"./BZBFESBB.js";import{a as H}from"./WZXA5XPB.js";import{a as F,b as T,c as C,d as P,e as W,g as B,h as M,i as _,j as A,k as z,l as U,n as K}from"./UW4UC7ZI.js";var G=C.go,S=class extends F{constructor(){super(" ")}typeName(t){return d(t)}memberName(t){return d(t)}identifier(t){return P(t,{style:"camel",reserved:G})}identifiers(t,n){let r=new Set(n??[]);return t.map(o=>{let s=d(o),a=s;for(let i=2;r.has(a);i++)a=`${s}${i}`;return r.add(a),a})}packageName(t){let n=t.toLowerCase().replace(/[^a-z0-9]/g,"");return n===""||/^[0-9]/.test(n)?"client":n}string(t){let n='"';for(let r of t){let o=r.codePointAt(0);r==="\\"?n+="\\\\":r==='"'?n+='\\"':r===`
8
- `?n+="\\n":r==="\r"?n+="\\r":r===" "?n+="\\t":o<32||o===127?n+=`\\x${o.toString(16).padStart(2,"0")}`:o>=55296&&o<=57343?n+="\\uFFFD":n+=r}return n+'"'}literal(t){return t==null?"nil":typeof t=="boolean"||typeof t=="number"?String(t):typeof t=="string"?this.string(t):Array.isArray(t)?`[]any{${t.map(r=>this.literal(r)).join(", ")}}`:`map[string]any{${Object.entries(t).map(([r,o])=>`${this.string(r)}: ${this.literal(o)}`).join(", ")}}`}comment(t){for(let n of U(t))this.line(n===""?"//":`// ${n}`);return this}doc(t,n){let r=U(n);if(r.length===0)return this;this.line(`// ${t} \u2014 ${r[0]}`);let o=!1;for(let s of r.slice(1)){if(s===""){o||this.line("//"),o=!0;continue}this.line(`// ${s}`),o=!1}return this}layout(t){return ie(le(t))}toString(){return this.layout(super.toString())}};function d(e){let t=P(e,{style:"pascal",reserved:G});return t.startsWith("_")?`N${t.slice(1)}`:t}function ie(e){return`${e.replace(/\n{3,}/g,`
9
-
10
- `).trimEnd()}
11
- `}function le(e){let t=e.split(`
12
- `),n=[...t],r=/^(\t+)([A-Za-z_]\w*) (\S+)( `[^`]*`)?$/,o=/^(\t+)([A-Za-z_]\w*) (\S+) = (.+)$/,s=/^(\t+)("(?:[^"\\]|\\.)*":) (.+)$/,a=l=>{if(l.length<2)return;let m=[];for(let{parts:f}of l)f.forEach((g,b)=>{b<f.length-1&&(m[b]=Math.max(m[b]??0,g.length))});for(let{index:f,parts:g,indent:b}of l){let $=g.map((y,h)=>h<g.length-1?y.padEnd(m[h]??0):y);n[f]=b+$.join(" ").trimEnd()}},i=[],c;return t.forEach((l,m)=>{let f=s.exec(l),g=f===null?o.exec(l):null,b=f===null&&g===null?r.exec(l):null,$=b!==null&&!G.has(b[2])?b:null,y=f!==null?"entry":g!==null?"const":$!==null?"field":void 0;if((y===void 0||y!==c)&&(a(i),i=[],c=y),f!==null){i.push({index:m,indent:f[1],parts:[f[2],f[3]]});return}if(g!==null){i.push({index:m,indent:g[1],parts:[g[2],g[3],"=",g[4]]});return}if($!==null){let h=[$[2],$[3]];$[4]!==void 0&&h.push($[4].trimStart()),i.push({index:m,indent:$[1],parts:h})}}),a(i),n.join(`
13
- `)}var u=new S,w=C.go;function X(e){if(e===void 0)return"client";if(!/^[a-z_][a-z0-9_]*$/.test(e)||w.has(e))throw new H(`goPackage "${e}" is not a valid Go package name: use lowercase letters, digits, and underscores, don't start with a digit, and avoid Go keywords.`);return e}function v(e){let t=new Set,n=[];for(let r of e.services)for(let o of r.operations){let s=d(o.name),a=2;for(;t.has(s);)s=`${d(o.name)}${a++}`;t.add(s),n.push({op:o,ident:s})}return n}function ce(e){return V(e).map(n=>n.kind==="literal"?u.string(n.value):P(n.name,{style:"camel",reserved:w})).join(" + ")}function ee(e,t){let n=t.servers??[];if(n.length===0)return;let r=new Set;n.forEach((o,s)=>{let a=`${d(o.description??`server${s+1}`)}URL`;r.has(a)&&(a=`${a}${s+1}`),r.add(a);let i=o.variables.map(l=>`${P(l.name,{style:"camel",reserved:w})} string`),c=o.variables.map(l=>`${P(l.name,{style:"camel",reserved:w})} default: ${u.string(l.default)}`).join(", ");e.line(`// ${a} returns the ${u.string(o.description??o.url)} base URL${c===""?".":` (${c}).`}`),e.block(`func ${a}(${i.join(", ")}) string {`,()=>{e.line(`return ${ce(o)}`)},"}"),e.blank()})}function ne(e,t){let n=Q(e,t).map(r=>r.map(o=>o.kind==="apiKey"?`{Scheme: ${u.string(o.scheme)}, Kind: "apiKey", Name: ${u.string(o.name)}, In: ${u.string(o.in)}}`:`{Scheme: ${u.string(o.scheme)}, Kind: ${u.string(o.kind)}}`));if(n.length!==0)return`[][]SecuritySpec{${n.map(r=>`{${r.join(", ")}}`).join(", ")}}`}function te(e){return`&PaginationSpec{${[`Style: ${u.string(e.style)}`,...e.param!==void 0?[`Param: ${u.string(e.param)}`]:[],...e.nextCursor!==void 0?[`NextCursor: ${u.string(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`HasMore: ${u.string(e.hasMore)}`]:[],...e.limitParam!==void 0?[`LimitParam: ${u.string(e.limitParam)}`]:[],...e.items!==void 0?[`Items: ${u.string(e.items)}`]:[]].join(", ")}}`}function p(e,t="string"){if(_(e)){let n=p(A(e),t);return n.startsWith("*")||n==="any"?n:`*${n}`}switch(e.kind){case"scalar":if(t==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"time.Time";if(e.metadata?.format==="date")return"Date"}return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"array":return`[]${p(e.items,t)}`;case"record":return`map[string]${p(e.value,t)}`;case"ref":return d(e.name);case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float64";case"enum":return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"omit":return d(e.base);case"union":case"null":case"object":case"intersection":case"unknown":return"any"}}function ue(e,t,n,r,o){e.doc(d(t),o),e.block(`type ${d(t)} struct {`,()=>{for(let s of n){let a=d(s.name),i=p(s.schema,r),c=`\`json:"${s.name}"\``;s.required||(!i.startsWith("*")&&!i.startsWith("[]")&&!i.startsWith("map[")&&i!=="any"&&(i=`*${i}`),c=`\`json:"${s.name},omitempty"\``),e.line(`${a} ${i} ${c}`)}},"}"),e.blank()}function L(e,t="string"){let n=new S;n.line("package client"),n.blank(),e.schemas.some(({schema:s})=>M(s,e)!==void 0)&&(n.line('import "encoding/json"'),n.blank());let o=fe(e,t);return t==="Date"&&o.includes("time.Time")&&(n.line('import "time"'),n.blank()),n.line(o),n.toString()}function fe(e,t){let n=new S;for(let{name:r,schema:o}of e.schemas){let s=z(o);if(s!==void 0){let i=s.scalar==="string"?"string":"int64";n.doc(d(r),o.description),n.line(`type ${d(r)} ${i}`),n.blank(),n.block("const (",()=>{let c=new Set;s.values.forEach(l=>{let m=T.pascal(String(l))||"Value",f="";for(let b=2;c.has(m+f);b++)f=String(b);c.add(m+f);let g=d(r)+m+f;n.line(`${g} ${d(r)} = ${u.literal(l)}`)})},")"),n.blank();continue}if(o.kind==="object"||o.kind==="intersection"){let i=B(o,e);if(i!==void 0){ue(n,r,i.properties,t,i.description??o.description);continue}}let a=M(o,e);if(a!==void 0){let i=d(r),c=a.cases.map(l=>`${l.value} -> ${d(l.schemaName)}`).join(", ");n.line(`// ${i} is a discriminated union ("${a.property}"): ${c}.`),n.line(`type ${i} = any`),n.blank(),n.line(`// Unmarshal${i} decodes into the member selected by "${a.property}".`),n.block(`func Unmarshal${i}(data []byte) (${i}, error) {`,()=>{n.block("var probe struct {",()=>{n.line(`Discriminant string \`json:"${a.property}"\``)},"}"),n.block("if err := json.Unmarshal(data, &probe); err != nil {",()=>{n.line("return nil, err")},"}"),n.line("switch probe.Discriminant {");for(let l of a.cases)n.block(`case ${u.string(l.value)}:`,()=>{n.line(`var value ${d(l.schemaName)}`),n.line("err := json.Unmarshal(data, &value)"),n.line("return value, err")});n.line("}"),n.line("var fallback any"),n.line("err := json.Unmarshal(data, &fallback)"),n.line("return fallback, err")},"}"),n.blank();continue}n.doc(d(r),o.description),n.line(`type ${d(r)} = ${p(o,t)}`),n.blank()}return n.toString()}function R(e,t){if(t==="string")return e;let n=e.startsWith("*")?`(${e})`:e;return t==="time.Time"?`${n}.Format(time.RFC3339)`:t==="Date"?`${n}.Format("2006-01-02")`:t==="int64"?`strconv.FormatInt(${e}, 10)`:t==="float64"?`strconv.FormatFloat(${e}, 'f', -1, 64)`:t==="bool"?`strconv.FormatBool(${e})`:`fmt.Sprint(${e})`}var de=["c","ctx","body","params","out","op"];function I(e,t){let n=W(e.pathParams.map(r=>r.name),{style:"camel",reserved:w,taken:de});return e.pathParams.map((r,o)=>({param:r,go:n[o],type:p(r.schema,t)}))}function me(e,t){let n=new Set;return(e.successResponseHeaders??[]).map(r=>{let o=d(r.name),s=o,a=2;for(;n.has(s);)s=`${o}${a++}`;n.add(s);let i=K(r.schema,t),c={integer:{goType:"*int64",helper:"headerInt64"},number:{goType:"*float64",helper:"headerFloat64"},boolean:{goType:"*bool",helper:"headerBool"},string:{goType:"*string",helper:"headerString"}}[i];return{field:s,name:r.name,...c}})}function E(e,t,n,r,o,s=!1){let a=I(t,r),i=t.queryParams.length>0,c=j(t),l=c===void 0?void 0:p(c,r),m=s?me(t,o):[];s&&(e.line(`// ${n}Headers carries the declared response headers of ${n}WithHeaders (nil when absent or unparsable).`),e.block(`type ${n}Headers struct {`,()=>{for(let h of m)e.line(`${h.field} ${h.goType}`)},"}"),e.blank());let f=["ctx context.Context",...a.map(({go:h,type:x})=>`${h} ${x}`),...t.requestBody?[`body ${p(t.requestBody.schema,r)}`]:[],...i?[`params *${n}Params`]:[]],g=N(t),b=s?l===void 0?`(${n}Headers, error)`:`(${l}, ${n}Headers, error)`:g!==void 0?"func(yield func(ServerSentEvent, error) bool)":l===void 0?"error":`(${l}, error)`,$=h=>s?l===void 0?`return headers, ${h}`:`return out, headers, ${h}`:l===void 0?`return ${h}`:`return out, ${h}`,y=s?`${n}WithHeaders`:n;e.doc(y,s?`Like ${n}, also returning the declared response headers.`:t.summary),e.block(`func (c *Client) ${y}(${f.join(", ")}) ${b} {`,()=>{g===void 0&&l!==void 0&&e.line(`var out ${l}`),s&&e.line(`var headers ${n}Headers`),e.line(`op := operations[${u.string(t.specName??t.name)}]`),e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),i&&e.block("if params != nil {",()=>{for(let k of t.queryParams){let q=d(k.name);e.block(`if params.${q} != nil {`,()=>{if(k.schema.kind==="array"){let D=p(k.schema.items,r);e.block(`for _, item := range *params.${q} {`,()=>{e.line(`query.Add(${u.string(k.name)}, ${R("item",D)})`)},"}")}else e.line(`query.Set(${u.string(k.name)}, ${R(`*params.${q}`,p(k.schema,r))})`)},"}")}},"}");let h=a.map(({param:k,go:q,type:D})=>`${u.string(k.name)}: ${R(q,D)}`).join(", ");if(e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${h}})`),g!==void 0){e.block("open := func(extraHeaders map[string]string) (*http.Response, error) {",()=>{e.line("merged := map[string]string{}"),e.block("for key, value := range authHeaders {",()=>{e.line("merged[key] = value")},"}"),e.block("for key, value := range extraHeaders {",()=>{e.line("merged[key] = value")},"}"),e.line("return send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: merged, Query: query})")},"}"),e.line(`return iterSSE(open, ${g.schema!==void 0&&g.schema.kind!=="unknown"})`);return}let x=["OperationID: op.ID","Method: op.Method","URL: requestURL","Headers: authHeaders","Query: query"];if(t.requestBody&&J(t)?(e.line("contentType, reader, err := toMultipart(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),x.push("Body: reader"),x.push("ContentType: contentType")):t.requestBody&&(e.line("payload, err := json.Marshal(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),x.push("Body: bytes.NewReader(payload)"),x.push(`ContentType: ${u.string(t.requestBody.contentType)}`)),e.line(`resp, err := send(ctx, &c.config, requestSpec{${x.join(", ")}})`),e.block("if err != nil {",()=>{e.line($("err"))},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line($("apiErrorFrom(resp, requestURL)"))},"}"),s){e.block(`if err := decodeJSON(resp, ${l===void 0?"nil":"&out"}); err != nil {`,()=>{e.line($("err"))},"}");for(let k of m)e.line(`headers.${k.field} = ${k.helper}(resp.Header, ${u.string(k.name)})`);e.line(l===void 0?"return headers, nil":"return out, headers, nil")}else l===void 0?e.line("return decodeJSON(resp, nil)"):(e.block("if err := decodeJSON(resp, &out); err != nil {",()=>{e.line("return out, err")},"}"),e.line("return out, nil"))},"}"),e.blank()}function re(e,t,n,r,o,s){let a=I(t,r),i=t.queryParams.length>0,c=["ctx context.Context",...a.map(({go:m,type:f})=>`${m} ${f}`),...i?[`params *${n}Params`]:[]].join(", "),l=()=>{e.line(`op := operations[${u.string(t.specName??t.name)}]`),e.line("base := url.Values{}"),i&&e.block("if params != nil {",()=>{for(let m of t.queryParams){let f=d(m.name);e.block(`if params.${f} != nil {`,()=>{e.line(`base.Set(${u.string(m.name)}, ${R(`*params.${f}`,p(m.schema,r))})`)},"}")}},"}"),e.block("call := func(pageParams url.Values) (any, *http.Response, error) {",()=>{e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),e.block("for key, values := range pageParams {",()=>{e.block("for _, value := range values {",()=>{e.line("query.Set(key, value)")},"}")},"}");let m=a.map(({param:f,go:g,type:b})=>`${u.string(f.name)}: ${R(g,b)}`).join(", ");e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${m}})`),e.line("resp, err := send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: authHeaders, Query: query})"),e.block("if err != nil {",()=>{e.line("return nil, nil, err")},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line("return nil, resp, apiErrorFrom(resp, requestURL)")},"}"),e.line("var raw any"),e.block("if err := decodeJSON(resp, &raw); err != nil {",()=>{e.line("return nil, resp, err")},"}"),e.line("return raw, resp, nil")},"}"),e.line("pages := iterPages(call, *op.Pagination, base)")};e.line(`// ${n}Pages iterates ${n} response pages; use with \`for page, err := range\`.`),e.block(`func (c *Client) ${n}Pages(${c}) func(yield func(${o}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${o}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.line(`var page ${o}`),e.block("if err == nil {",()=>{e.line("err = reencode(raw, &page)")},"}"),e.line("return yield(page, err)")},"})")},"}")},"}"),e.blank(),e.line(`// ${n}Items iterates the items of every ${n} page.`),e.block(`func (c *Client) ${n}Items(${c}) func(yield func(${s}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${s}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.block("if err != nil {",()=>{e.line(`var zero ${s}`),e.line("return yield(zero, err)")},"}"),e.line("pageItems, _ := resolvePointer(raw, op.Pagination.Items).([]any)"),e.block("for _, item := range pageItems {",()=>{e.line(`var typed ${s}`),e.block("if err := reencode(item, &typed); err != nil {",()=>{e.line("return yield(typed, err)")},"}"),e.block("if !yield(typed, nil) {",()=>{e.line("return false")},"}")},"}"),e.line("return true")},"})")},"}")},"}"),e.blank()}function oe(e){let t=e.split(`
14
- `),n=[],r=!1;for(let o of t)if(!o.startsWith("package ")){if(o.startsWith("import (")){r=!0;continue}if(r){o.startsWith(")")&&(r=!1);continue}o.startsWith("import ")||n.push(o)}return n.join(`
15
- `).trim()}var se=["bytes","context","encoding/base64","encoding/json","errors","fmt","io","math/rand","mime/multipart","net/http","net/url","strconv","strings","time"];function ae(e,t,n,r,o,s){e.line(oe(L(t,r))),e.blank(),ee(e,t),s&&(e.line("// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator go runtime) \u2500\u2500\u2500"),e.line(oe(O)),e.blank()),e.block("type operationMeta struct {",()=>{e.line("ID string"),e.line("Method string"),e.line("Path string"),e.line("Security [][]SecuritySpec"),e.line("Pagination *PaginationSpec")},"}"),e.blank(),e.block("var operations = map[string]operationMeta{",()=>{for(let{op:a,ident:i}of v(t)){let c=a.specName??a.name,l=ne(a,t),m=o.get(i),f=[`ID: ${u.string(c)}`,`Method: ${u.string(a.method.toUpperCase())}`,`Path: ${u.string(a.path)}`,...l!==void 0?[`Security: ${l}`]:[],...m!==void 0?[`Pagination: ${te(m)}`]:[]];e.line(`${u.string(c)}: {${f.join(", ")}},`)}},"}"),e.blank();for(let{op:a,ident:i}of v(t))a.queryParams.length!==0&&(e.block(`type ${i}Params struct {`,()=>{for(let c of a.queryParams){let l=p(c.schema,r);e.line(`${d(c.name)} ${l.startsWith("*")?l:`*${l}`}`)}},"}"),e.blank());e.doc("Client",`Client for ${t.title} (${t.version}).`),e.block("type Client struct {",()=>{e.line("config Config")},"}"),e.blank(),e.block("func New(config Config) *Client {",()=>{e.block('if config.ServerURL == "" {',()=>{e.line(`config.ServerURL = ${u.string(n.serverUrl??t.serverUrl??"")}`)},"}"),e.line("return &Client{config: config}")},"}"),e.blank();for(let{op:a,ident:i}of v(t)){E(e,a,i,r),N(a)===void 0&&(a.successResponseHeaders?.length??0)>0&&E(e,a,i,r,t,!0);let c=o.get(i);if(c===void 0)continue;let l=j(a),m=l===void 0?"any":p(l,r),f=Z(l,c.items,t);re(e,a,i,r,m,f===void 0?"any":p(f,r))}}var rn=({model:e,output:t,banner:n,emit:r,pagination:o})=>{let s=new S,a=r.dateType??"string",i=X(r.goPackage),c=new Map;for(let{op:$,ident:y}of v(e)){let h=o?.get($.name)?.spec;h!==void 0&&c.set(y,h)}s.line(`// Code generated by @redocly/client-generator (go) from "${e.title}" ${e.version}. DO NOT EDIT.`),s.line("// Regenerate with `redocly generate-client`. Standard library only \u2014 zero dependencies."),s.line(`package ${i}`),s.blank();let l=r.runtime!=="module",m=l?se:(()=>{let $=new S;ae($,e,r,a,c,!1);let y=$.toString();return se.filter(h=>new RegExp(`\\b${h.split("/").pop()}\\.`).test(y))})();s.block("import (",()=>{for(let $ of m)s.line(u.string($))},")"),s.blank(),ae(s,e,r,a,c,l);let f={path:t.path.replace(/\.[^.\\/]+$/,".go"),content:s.toString()};if(l)return[f];let g=n.map($=>`// ${$}`).join(`
16
- `),b=O.replace(/^package .*$/m,`package ${i}`);return[f,{path:f.path.replace(/[^\\/]+$/,"runtime.go"),content:`${g}
17
- ${b.trimEnd()}
18
- `}]};function ge(e,t){let n=t.emit.dateType??"string",r=t.emit.goPackage??"client",o=v(t.model).find(c=>c.op.name===e.name)?.ident??d(e.name),s=["ctx",...e.pathParams.map(c=>`"<${P(c.name,{style:"camel",reserved:w})}>"`),...e.requestBody?[`${p(e.requestBody.schema,n)}{ /* \u2026 */ }`]:[],...e.queryParams.length>0?["nil"]:[]],a=`client.${o}(${s.join(", ")})`,i=N(e)!==void 0?`stream := ${a}`:j(e)===void 0?`err := ${a}`:`result, err := ${a}`;return{lang:"go",label:"Go SDK",source:`client := ${r}.New(${r}.Config{})
19
- ${i}
20
- `}}var on=({model:e,output:t,emit:n,pagination:r})=>[{path:t.path.replace(/\.[^.\\/]+$/,".go.md"),content:Y(e,{title:`${e.title} Go SDK reference`,frontmatter:n.docsFrontmatter===!0,language:{name:"go",label:"Go",fence:"go",requires:"The SDK needs the standard library only."},sample:o=>ge(o,{model:e,emit:n,outputPath:t.path}),paginated:new Set(r?.keys()??[])})}];export{p as a,L as b,rn as c,ge as d,on as e};
@@ -1,22 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{a as ye,e as ve,f as Se,g as we,h as O,i as Re,k,l as A,m as Ie,n as Pe,v as be,w as Oe}from"./52MW7SRF.js";import{$,K as ot,V as ce,Y as at,Z as pe,_ as g,aa as de,ba as E,c as d,ca as q,ea as S,ga as v,ia as R,ja as le,ka as fe,la as me,ma as he,q as ae,ra as ge,w as ue}from"./AP2GA7RS.js";import{e as oe}from"./RFWIIJFG.js";import ke from"node:path";function I(t){return t?t.trim():""}function B(t){let e=I(t.operationId)||I(t.path);return[I(t.ruleId),I(t.severity),I(t.message),e,I(t.target),I(t.schemaPath)].join("")}var _=t=>pe(S(t));function ut(t){return t==="error"?"error":t==="warning"?"warning":"note"}function ct(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
8
- `)?e:`"${e.replace(/"/g,'""')}"`}function pt(t){return ke.isAbsolute(t)?ke.relative(process.cwd(),t)||".":t}function dt(t){if(!t)return null;let e=t.operationPathTemplate;return typeof e=="string"&&e.length>0?e:null}function lt(t){return Object.entries(t).sort((e,r)=>{let n=r[1]-e[1];return n!==0?n:e[0].localeCompare(r[0])})}function ft(t){let e=[],r=new Map;for(let n of t){let s=B({ruleId:n.ruleId,severity:n.severity,message:n.message,operationId:n.operationId,path:n.path,target:n.target,schemaPath:n.schemaPath}),i=r.get(s);if(i!==void 0){e[i].occurrences+=1;continue}r.set(s,e.length),e.push({finding:n,occurrences:1})}return e}function mt(t){let e=ft(t.findings).map(n=>({occurrences:n.occurrences,exchangeIndex:n.finding.exchangeIndex,ruleId:n.finding.ruleId,severity:n.finding.severity,category:n.finding.category,message:n.finding.message,operationId:n.finding.operationId,specSource:n.finding.specSource,target:n.finding.target,schemaPath:n.finding.schemaPath,dataPath:n.finding.dataPath,details:n.finding.details,method:n.finding.method,url:n.finding.url,path:n.finding.path,status:n.finding.status})),r={run:{id:t.runId,specSource:t.meta.specSource,trafficPath:t.meta.trafficPath,format:t.meta.format,matchMode:t.meta.matchMode,server:t.meta.server,totalExchanges:t.summary.totalExchanges,documentedExchanges:t.summary.documentedExchanges,undocumentedExchanges:t.summary.undocumentedExchanges,skippedExchanges:t.summary.skippedExchanges,findingsBySeverity:t.summary.findingsBySeverity,findingsByRule:t.summary.findingsByRule,totalProblems:t.summary.totalProblemGroups,durationMs:t.summary.durationMs},problems:e};return`${JSON.stringify(r,null,2)}
9
- `}function ht(t){let e=["run_id","finding_id","exchange_index","severity","category","rule_id","message","method","path","url","status","operation_id","spec_source","target","schema_path","data_path"],r=t.findings.map(s=>[t.runId,s.id,s.exchangeIndex,s.severity,s.category,s.ruleId,s.message,s.method,s.path,s.url,s.status,s.operationId,s.specSource,s.target,s.schemaPath,s.dataPath]);return`${[e,...r].map(s=>s.map(ct).join(",")).join(`
10
- `)}
11
- `}function gt(t){let e=new Map;for(let s of t.findings)e.has(s.ruleId)||e.set(s.ruleId,{id:s.ruleId,name:s.ruleId,shortDescription:{text:`${s.category} detection`}});let r=t.findings.map(s=>{let i=s.specSource??s.url??void 0;return{ruleId:s.ruleId,level:ut(s.severity),message:{text:s.message},locations:i?[{physicalLocation:{artifactLocation:{uri:i}}}]:void 0,properties:{runId:t.runId,exchangeIndex:s.exchangeIndex,method:s.method,path:s.path,status:s.status,operationId:s.operationId,target:s.target,schemaPath:s.schemaPath,dataPath:s.dataPath}}}),n={$schema:"https://json.schemastore.org/sarif-2.1.0.json",version:"2.1.0",runs:[{tool:{driver:{name:"drift",rules:Array.from(e.values())}},results:r}]};return`${JSON.stringify(n,null,2)}
12
- `}function yt(t){return t.findingsBySeverity.error+t.findingsBySeverity.warning+t.findingsBySeverity.info}function vt(t){return t>=500?$:t>=400?E:t>=300?q:t>=200?de:v}function St(t,e,r){let n=(f,h)=>e?h(f):f,s=f=>f==="error"?n("\u2716",$):f==="warning"?n("\u25B2",E):n("\u25CF",q),i=f=>f==="error"?n("ERROR",$):f==="warning"?n("WARN",E):n("INFO",q),{summary:o,meta:a}=t,c=yt(o),l=o.previewFindings.slice(0,r),u=[];if(u.push(n("\u250F\u2501 Drift Report",_)),u.push(`\u2503 Run: ${t.runId}`),u.push(`\u2503 Spec: ${a.specSource}`),u.push(`\u2503 Traffic: ${a.trafficPath}`),u.push(a.server?`\u2503 Server: ${a.server} (overrides description servers)`:`\u2503 Match mode: ${a.matchMode}`),u.push(`\u2503 Traffic format: ${a.format}${a.format==="auto"?" (auto-detect)":""}`),u.push(`\u2503 Exchanges: total=${o.totalExchanges} documented=${o.documentedExchanges} undocumented=${o.undocumentedExchanges}${o.skippedExchanges>0?` skipped=${o.skippedExchanges}`:""}`),u.push(`\u2503 Findings: total=${c} ${n(`error=${o.findingsBySeverity.error}`,$)} ${n(`warning=${o.findingsBySeverity.warning}`,E)} ${n(`info=${o.findingsBySeverity.info}`,q)}`),u.push(`\u2503 Problems: total=${o.totalProblemGroups}`),u.push(`\u2517 Duration: ${o.durationMs}ms`),c===0)return u.push(""),u.push(n("\u2714 No findings.",S)),`${u.join(`
13
- `)}
14
- `;u.push(""),u.push(n(`Types (${Object.keys(o.problemGroupsByRule).length})`,_));for(let[f,h]of lt(o.problemGroupsByRule)){let y=o.findingsByRule[f]??h;u.push(` ${n("\u2022",v)} ${f}: ${h} problems / ${y} findings`)}let m=new Map;for(let f of l)m.has(f.ruleId)||m.set(f.ruleId,[]),m.get(f.ruleId).push(f);let w=Array.from(m.keys()).sort((f,h)=>{let y=(o.problemGroupsByRule[h]??0)-(o.problemGroupsByRule[f]??0);return y!==0?y:f.localeCompare(h)});u.push(""),u.push(n(`Problems by type (showing first ${l.length} of ${o.totalProblemGroups})`,_));let j=0;for(let f of w){let h=m.get(f);if(!h||h.length===0)continue;let y=o.problemGroupsByRule[f]??h.length,Y=o.findingsByRule[f]??y;u.push(""),u.push(`${n("\u25C9",S)} ${n(f,_)} ${n(`(${h.length} problems shown / ${y} total, ${Y} findings)`,v)}`);for(let p of h){j+=1;let re=p.occurrences,nt=p.status!==void 0?n(String(p.status),vt(p.status)):n("-",v),rt=dt(p.details)??p.path,st=p.operationId?` ${n(p.operationId,g)}`:"";if(u.push(`${s(p.severity)} ${i(p.severity)} #${j}${re>1?` ${n(`\xD7${re}`,v)}`:""} ${n("\u2192",v)} ${p.message}`),u.push(` \u21B3 sample exchange=${p.exchangeIndex} ${n(p.method,S)} ${rt} (${nt})${st}`),u.push(""),u.push(` ${n(p.url,v)}`),(p.specSource||p.schemaPath||p.dataPath)&&(u.push(""),p.specSource&&u.push(` ${n("spec:",g)} ${n(pt(p.specSource),S)}`),p.schemaPath&&u.push(` ${n("schemaPath=",g)} ${n(p.schemaPath,g)}`),p.dataPath&&u.push(` ${n("dataPath=",g)} ${n(p.dataPath,S)}`)),p.details)if(u.push(""),p.ruleId==="security-baseline"&&typeof p.details.summary=="string")u.push(` ${n("security:",g)} ${p.details.summary}`);else if(p.ruleId==="owasp-api-top10"&&typeof p.details.summary=="string"){let x=typeof p.details.issueId=="string"?p.details.issueId:null,C=typeof p.details.issueTitle=="string"?p.details.issueTitle:null;u.push(` ${n("owasp:",g)} ${p.details.summary}`),(x||C)&&u.push(` ${n("issue:",g)} ${[x,C].filter(Boolean).join(" - ")}`)}else if(p.ruleId==="schema-consistency"&&typeof p.details.summary=="string"){let x=typeof p.details.path=="string"?p.details.path:null,C=typeof p.details.expected=="string"?p.details.expected:null,se=typeof p.details.actual=="string"?p.details.actual:null,ie=typeof p.details.suggestion=="string"?p.details.suggestion:null;if(u.push(` ${n("schema:",g)} ${p.details.summary}`),x&&u.push(` ${n("path:",g)} ${n(x,S)}`),C&&u.push(` ${n("expected:",g)} ${C}`),se&&u.push(` ${n("actual:",g)} ${se}`),ie){u.push(` ${n("hint:",g)}`);for(let it of ie.split(`
15
- `))u.push(` ${it}`)}}else u.push(` ${n("details:",g)} ${JSON.stringify(p.details)}`);u.push("")}}let b=o.totalProblemGroups-l.length;return b>0?(u[u.length-1]!==""&&u.push(""),u.push(n(`\u2026 ${b} problems omitted from terminal output. Use --format json/csv/sarif for the complete export.`,v))):u[u.length-1]===""&&u.pop(),`${u.join(`
16
- `)}
17
- `}function Zn(t,e){let r=e.maxFindings??10;switch(e.format){case"json":return mt(t);case"csv":return ht(t);case"sarif":return gt(t);case"pretty":return St(t,e.color??!1,r);default:throw new Error(`Unsupported report format: ${e.format}`)}}import{randomUUID as Qe}from"node:crypto";function wt(t,e){let r=O(t||"/")||"/",n=O(e.basePath||"/")||"/";return n==="/"?r:r===n?"/":r.startsWith(`${n}/`)?r.slice(n.length)||"/":null}function Rt(t,e){return!t.host||!e?!0:t.host===e.toLowerCase()}function It(t){try{return decodeURIComponent(t)}catch{return t}}function Pt(t,e,r){let n=r==="strict-host"?e.host?20:5:0;return t.pathScore*10+n}function Ae(t,e){let r={};for(let n=0;n<t.pathParams.length;n+=1){let s=t.pathParams[n],i=e[n+1];s&&i!==void 0&&(r[s]=It(i))}return r}function bt(t,e){let r=O(e)||"/";for(let n of t){let s=n.pathRegex.exec(r);if(s)return{operation:n,pathParams:Ae(n,s)}}return null}function xe(t,e,r,n){let s=e.request.method.toLowerCase(),i=t.operationsByMethod.get(s);if(!i||i.length===0)return null;if(n!==void 0)return bt(i,n);let o=null;for(let a of i)for(let c of a.servers){if(r==="strict-host"&&!Rt(c,e.request.host))continue;let l=wt(e.request.path,c);if(!l)continue;let u=a.pathRegex.exec(l);if(!u)continue;let m={score:Pt(a,c,r),matched:{operation:a,pathParams:Ae(a,u)}};(!o||m.score>o.score)&&(o=m)}return o?.matched??null}var Ce=6,Ot=2e3,kt=50,At=5,xt=1e6,Ct=/(?:token|api[_-]?key|apikey|password|passwd|secret|authorization|jwt)/i,$t=/(?:password|passwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token|private[_-]?key|ssn|credit[_-]?card|card[_-]?number|cvv)/i,Et=new Set(["page","limit","offset","cursor","per_page","perpage","size","start","after","before"]),$e=4,qt=$e*2;function Tt(t){return t.length<=qt?"***":`${t.slice(0,$e)}\u2026`}function Ft(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Mt(t){return typeof t=="string"||typeof t=="number"}function jt(t){let e=t.toLowerCase();return e.includes("secret")||e.includes("token")||e.includes("key")?e.startsWith("is")||e.startsWith("has")||e.startsWith("can")||e.startsWith("should")||e.startsWith("enable")||e.startsWith("allow"):!1}function Bt(t){if(typeof t=="number")return t===0||t===1;let e=t.trim().toLowerCase();return e==="true"||e==="false"||e==="0"||e==="1"}function _t(t){if(!d(t)&&!Array.isArray(t))return[];let e=[],r=[{value:t,path:""}],n=0;for(;r.length>0&&n<Ot&&e.length<Ce;){let s=r.pop();if(!s)break;if(n+=1,Array.isArray(s.value)){let i=Math.min(s.value.length,kt);for(let o=0;o<i;o+=1){let a=s.value[o];(d(a)||Array.isArray(a))&&r.push({value:a,path:`${s.path}/${o}`})}continue}if(d(s.value))for(let[i,o]of Object.entries(s.value)){let a=`${s.path}/${Ft(i)}`;if($t.test(i)&&Mt(o)){let c=String(o);if(jt(i)&&Bt(o))continue;if(c.length>0&&(e.push(a||"/"),e.length>=Ce))break}(d(o)||Array.isArray(o))&&r.push({value:o,path:a})}}return e}function Lt(t){for(let e of t.keys())if(Et.has(e.toLowerCase()))return!0;return!1}function P(t,e,r,n,s){return{ruleId:"owasp-api-top10",severity:n,category:"security",message:e,exchangeIndex:t.exchange.index,operationId:t.matchedOperation?.operation.operationId,specSource:t.matchedOperation?.operation.specSource,target:r,details:s}}function Nt(t){let e=[];for(let[r,n]of t.exchange.request.query.entries())if(Ct.test(r)&&(e.push({key:r,valuePreview:Tt(n)}),e.length>=At))break;return e.length===0?[]:[P(t,"Sensitive credential-like query parameters detected","request","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:"Authentication data should not be passed via query parameters because it can leak via logs, browser history, and referrers.",sensitiveQueryParams:e})]}function zt(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["access-control-allow-origin"]?.trim(),n=e.headers["access-control-allow-credentials"]?.trim().toLowerCase();return r!=="*"||n!=="true"?[]:[P(t,"Insecure CORS policy: wildcard origin with credentials enabled","response","error",{issueId:"API8:2023",issueTitle:"Security Misconfiguration",summary:'Access-Control-Allow-Origin is "*" while Access-Control-Allow-Credentials is true. Browsers may expose authenticated API responses to untrusted origins.',headers:{accessControlAllowOrigin:r,accessControlAllowCredentials:n}})]}function Vt(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["set-cookie"];if(!r)return[];let n=[];for(let s of Se(r)){let i=new Set(s.split(";").slice(1).map(o=>o.split("=")[0].trim().toLowerCase()));t.exchange.request.protocol==="https:"&&!i.has("secure")&&n.push(P(t,'Set-Cookie header is missing "Secure" attribute',"response","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:'Session cookies over HTTPS should include "Secure" to prevent transmission over plain HTTP.',setCookiePreview:s.slice(0,200)})),i.has("httponly")||n.push(P(t,'Set-Cookie header is missing "HttpOnly" attribute',"response","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:'Session cookies should include "HttpOnly" to reduce risk of token theft via client-side script access.',setCookiePreview:s.slice(0,200)})),i.has("samesite")||n.push(P(t,'Set-Cookie header is missing "SameSite" attribute',"response","info",{issueId:"API8:2023",issueTitle:"Security Misconfiguration",summary:'Set "SameSite" on session cookies to reduce CSRF risk for state-changing requests.',setCookiePreview:s.slice(0,200)}))}return n}function Ht(t){let e=t.exchange.response;if(!e||e.bodyJson===void 0)return[];let r=_t(e.bodyJson);return r.length===0?[]:[P(t,"Potential sensitive data exposure in response payload","response","warning",{issueId:"API3:2019",issueTitle:"Excessive Data Exposure",summary:`Sensitive-looking fields detected in response payload: ${r.join(", ")}`,exposedPaths:r})]}function Dt(t){let e=t.exchange.response;return!e||e.status>=400||t.exchange.request.method!=="GET"?[]:!e.bodyText||e.bodyText.length<xt?[]:Lt(t.exchange.request.query)?[]:[P(t,"Large response without pagination parameters (possible resource-consumption risk)","response","info",{issueId:"API4:2023",issueTitle:"Unrestricted Resource Consumption",summary:"A large response was returned without common pagination query parameters. Consider explicit page/limit controls for large collections.",responseBytes:e.bodyText.length})]}var L=class{id="owasp-api-top10";analyze(e){return e.matchedOperation?[...Nt(e),...zt(e),...Vt(e),...Ht(e),...Dt(e)]:[]}};function N(t,e){let r=t.replace(/\{([^}]+)\}/g,(i,o)=>{let a=e?.[o];return a?.default!==void 0?String(a.default):Array.isArray(a?.enum)&&a.enum.length>0?String(a.enum[0]):""}),n=we(r),s=!!(n.host&&!ve(n.host));return{rawUrl:t,protocol:s?n.protocol:void 0,host:s?n.host.toLowerCase():void 0,basePath:O(n.pathname||"/")}}function Ee(t){return t?t.startsWith("/")?t:`/${t}`:"/"}function z(t,e){let r=`${Math.floor(t/100)}XX`;return[String(t),r,r.toLowerCase(),"default"].find(n=>e.includes(n))}function qe(t){if(!t)return{};let e={};for(let r of t.split(";")){let[n,...s]=r.trim().split("=");if(!n)continue;let i=s.join("=").trim();e[n]=i}return e}var Kt=/^([^[\]]+)\[([^[\]]+)\]$/;function Q(t){let e=t.match(Kt);return e?{parameterName:e[1],property:e[2]}:void 0}function Ut(t,e){let r;for(let[n,s]of e){let i=Q(n);i?.parameterName===t&&(r??={},r[i.property]=s)}return r}function V(t,e,r,n){switch(t.in){case"path":return r[t.name];case"query":{if(t.style==="deepObject")return Ut(t.name,e.query);let s=e.query.getAll(t.name);return s.length===0?void 0:(d(t.schema)?t.schema.type:void 0)==="array"||s.length>1?s:s[0]}case"header":return e.headers[t.name.toLowerCase()];case"cookie":return n[t.name];default:return}}var Te=200;function Fe(t){return t!==void 0&&t!==""}function Gt(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Jt(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Wt(t){return!t||t==="#"?"":t.startsWith("#")?t.slice(1):t}function X(t){let e=Wt(t);return!e||e==="/"?[]:e.split("/").slice(1).map(r=>Gt(r))}function Me(t,e){return`/${[...X(t),Jt(e)].join("/")}`}function Yt(t,e){let r=X(e),n=t;for(let s of r){if(Array.isArray(n)){let i=Number.parseInt(s,10);if(!Number.isInteger(i)||i<0||i>=n.length)return;n=n[i];continue}if(!d(n))return;n=n[s]}return n}function Z(t){let e=t.instancePath??"",r=t.params??{};return t.keyword==="required"&&typeof r.missingProperty=="string"?Me(e,r.missingProperty):t.keyword==="additionalProperties"&&typeof r.additionalProperty=="string"?Me(e,r.additionalProperty):e}function Qt(t){let e=X(t);if(e.length===0)return"root";let r=[];for(let n of e)/^\d+$/.test(n)?r.push(`[${n}]`):r.length===0?r.push(n):r.push(`.${n}`);return r.join("")}function Xt(t){if(t===void 0)return"[missing]";let e=JSON.stringify(t);return e?e.length>Te?`${e.slice(0,Te)}\u2026`:e:String(t)}function Zt(t){let e=t.params??{};if(t.keyword==="required"&&typeof e.missingProperty=="string")return`required field "${e.missingProperty}"`;if(t.keyword==="type"&&typeof e.type=="string")return`type "${e.type}"`;if(t.keyword==="additionalProperties")return"no additional undocumented properties";if(t.keyword==="format"&&typeof e.format=="string")return`format "${e.format}"`}function en(t,e,r){let n=t==="request"?"Request":"Response",s=e.params??{},i=Qt(r);return e.keyword==="required"&&typeof s.missingProperty=="string"?`${n} is missing required field "${i}".`:e.keyword==="additionalProperties"&&typeof s.additionalProperty=="string"?`${n} has undocumented field "${i}".`:e.keyword==="type"&&typeof s.type=="string"?`${n} field "${i}" must be ${s.type}.`:e.keyword==="enum"?`${n} field "${i}" has a value outside allowed enum values.`:e.keyword==="format"&&typeof s.format=="string"?`${n} field "${i}" does not match format "${s.format}".`:`${n} schema mismatch at "${i}": ${e.message??"validation error"}`}function Be(t,e,r){let n=Z(e),s=Yt(t,n);return{summary:en(r,e,n),keyword:e.keyword??null,path:n||"/",expected:Zt(e)??null,actual:Xt(s),suggestion:null,params:e.params??{},ajvMessage:e.message??"validation error"}}function tn(t,e,r,n){if(e==null||!t.schema)return;let s=r.validateSchema(t.schema,e,{coerce:!0});if(!s.valid)for(let i of s.errors){let o=Be(e,i,"request");n.push({ruleId:"schema-consistency",severity:"error",category:"schema",message:`Invalid ${t.in} parameter "${t.name}": ${typeof o.summary=="string"?o.summary:i.message??"schema mismatch"}`,exchangeIndex:r.exchange.index,operationId:r.matchedOperation?.operation.operationId,specSource:r.matchedOperation?.operation.specSource,target:"request",schemaPath:i.schemaPath,dataPath:Z(i),details:{...o,parameter:{name:t.name,in:t.in}}})}}function nn(t,e){let r=[],n={query:new Set,header:new Set,cookie:new Set},s=new Set;for(let i of e.operation.requestParameters)i.in==="header"?n.header.add(i.name.toLowerCase()):(i.in==="query"||i.in==="cookie")&&(n[i.in].add(i.name),i.in==="query"&&i.style==="deepObject"&&s.add(i.name));for(let i of new Set(t.exchange.request.query.keys())){if(n.query.has(i))continue;let o=Q(i);o&&s.has(o.parameterName)||r.push({ruleId:"schema-consistency",severity:"warning",category:"documentation",message:`Undocumented query parameter in traffic: "${i}"`,exchangeIndex:t.exchange.index,operationId:e.operation.operationId,specSource:e.operation.specSource,target:"request"})}for(let i of Object.keys(t.exchange.request.headers))Pe(i,t.ignoreHeaders)||n.header.has(i.toLowerCase())||r.push({ruleId:"schema-consistency",severity:"info",category:"documentation",message:`Undocumented header in traffic: "${i}"`,exchangeIndex:t.exchange.index,operationId:e.operation.operationId,specSource:e.operation.specSource,target:"request"});return r}function rn(t){let e=t.exchange.response;return e!==void 0&&e.status>=400&&e.status<500}function sn(t,e){let r=t.exchange.response;if(!r)return;let{responseStatuses:n,responseBodyContent:s}=e.operation,i=z(r.status,n);if(!(i===void 0||s[i]===void 0))return A(s[i],r.contentType)}function je(t,e,r,n){let s=r.validateSchema(t,e,{target:n});return s.valid?[]:s.errors.map(i=>{let o=Be(e,i,n);return{ruleId:"schema-consistency",severity:"error",category:"schema",message:typeof o.summary=="string"?o.summary:`Schema mismatch (${n}): ${i.message??"validation error"}`,exchangeIndex:r.exchange.index,operationId:r.matchedOperation?.operation.operationId,specSource:r.matchedOperation?.operation.specSource,target:n,schemaPath:i.schemaPath,dataPath:Z(i),details:o}})}var H=class{id="schema-consistency";analyze(e){let r=e.matchedOperation;if(!r)return[];let n=[];if(n.push(...nn(e,r)),!rn(e)){for(let c of r.operation.requestParameters){if(e.ignoreCookies&&c.in==="cookie")continue;let l=V(c,e.exchange.request,r.pathParams,e.cookies);if(c.required&&l==null){n.push({ruleId:this.id,severity:"error",category:"documentation",message:`Missing required ${c.in} parameter: "${c.name}"`,exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"});continue}tn(c,l,e,n)}let i=e.exchange.request.contentType,o=A(r.operation.requestBodyContent,i),a=Fe(e.exchange.request.bodyText);r.operation.requestBodyRequired&&!a&&n.push({ruleId:this.id,severity:"error",category:"documentation",message:"Missing required request body",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"}),o&&a&&k(i)&&(e.exchange.request.bodyJson===void 0?n.push({ruleId:this.id,severity:"error",category:"schema",message:"Request body is not valid JSON for JSON content-type",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"}):n.push(...je(o,e.exchange.request.bodyJson,e,"request")))}let s=sn(e,r);if(s&&e.exchange.response&&Fe(e.exchange.response.bodyText)){let i=e.exchange.response.contentType;k(i)&&(e.exchange.response.bodyJson===void 0?n.push({ruleId:this.id,severity:"error",category:"schema",message:"Response body is not valid JSON for JSON content-type",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"response"}):n.push(...je(s,e.exchange.response.bodyJson,e,"response")))}return n}};function ee(t){if(!t)return null;let[e]=t.trim().split(/\s+/,1);return e?e.toLowerCase():null}function Le(t){return!!t.exchange.request.headers.authorization}function on(t,e){return t?t.split(";").map(r=>r.trim()).some(r=>r.startsWith(`${e}=`)):!1}function an(t,e){let r=t.matchedOperation?.operation;if(!r)return{schemeName:e,schemeType:"unknown",satisfied:!0,reason:"No matched OpenAPI operation."};let n=r.securitySchemes[e];if(!n)return{schemeName:e,schemeType:"missing",satisfied:!1,reason:"Security scheme is referenced but not defined in components.securitySchemes."};let s=String(n.type??"unknown");if(n.type==="apiKey"){let i=String(n.name??""),o=String(n.in??"header");if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:'apiKey scheme is missing the "name" field in the OpenAPI spec.'};if(o==="header"){let a=!!t.exchange.request.headers[i.toLowerCase()];return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey header "${i}".`:`Missing required apiKey header "${i}".`}}if(o==="query"){let a=t.exchange.request.query.has(i);return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey query parameter "${i}".`:`Missing required apiKey query parameter "${i}".`}}if(o==="cookie"){if(t.ignoreCookies)return{schemeName:e,schemeType:s,satisfied:!0,skipped:!0,reason:`Skipped apiKey cookie "${i}" validation because --ignore-cookies is enabled.`};let a=on(t.exchange.request.headers.cookie,i);return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey cookie "${i}".`:`Missing required apiKey cookie "${i}".`}}return{schemeName:e,schemeType:s,satisfied:!1,reason:`Unsupported apiKey location "${o}" in OpenAPI security scheme.`}}if(n.type==="http"){let i=t.exchange.request.headers.authorization;if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Missing Authorization header."};let o=String(n.scheme??"").toLowerCase(),a=ee(i);if(!o)return{schemeName:e,schemeType:s,satisfied:!0,reason:"Authorization header is present and no specific HTTP auth scheme is documented."};if(!a)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Authorization header is malformed and does not include an auth scheme."};let c=a===o;return{schemeName:e,schemeType:s,satisfied:c,reason:c?`Authorization uses expected "${o}" scheme.`:`Authorization uses "${a}" but "${o}" is required.`}}if(n.type==="oauth2"||n.type==="openIdConnect"){let i=t.exchange.request.headers.authorization;if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Missing Authorization header for OAuth2/OpenID Connect scheme."};let o=ee(i),a=o==="bearer";return{schemeName:e,schemeType:s,satisfied:a,reason:a?"Authorization uses bearer token as expected for OAuth2/OpenID Connect.":`Authorization scheme "${o??"unknown"}" does not satisfy OAuth2/OpenID Connect (expected bearer).`}}return n.type==="mutualTLS"?{schemeName:e,schemeType:s,satisfied:!0,reason:"mutualTLS cannot be validated from HTTP traffic logs alone."}:{schemeName:e,schemeType:s,satisfied:!1,reason:`Unsupported security scheme type "${s}".`}}function un(t){let e=t.matchedOperation?.operation.security;if(!e)return{satisfied:!0,requirements:[]};if(e.length===0)return{satisfied:!0,requirements:[]};let r=e.map((n,s)=>{let i=Object.keys(n);if(i.length===0)return{requirementIndex:s,satisfied:!0,schemeResults:[]};let o=i.map(a=>an(t,a));return{requirementIndex:s,satisfied:o.every(a=>a.satisfied),schemeResults:o}});return{satisfied:r.some(n=>n.satisfied),requirements:r}}function cn(t){let e=[];for(let r of t.requirements)for(let n of r.schemeResults)n.satisfied||e.push({requirement:r.requirementIndex+1,schemeName:n.schemeName,reason:n.reason});return e}function _e(t){let e=[];for(let r of t.requirements)for(let n of r.schemeResults)n.skipped&&e.push({requirement:r.requirementIndex+1,schemeName:n.schemeName,reason:n.reason});return e}function pn(t){if(t.length===0)return"All documented security requirements are satisfied.";let e=new Map;for(let n of t){let s=e.get(n.requirement);s?s.push(n):e.set(n.requirement,[n])}let r=Array.from(e.entries()).sort((n,s)=>n[0]-s[0]).map(([n,s])=>{let i=s.map(a=>a.schemeName).join(" + "),o=s.map(a=>a.reason).join(" ");return`Option ${n} (${i}): ${o}`});return r.length===1?`Authentication check failed. ${r[0]}`:`None of the documented authentication options matched. Any one of these options would satisfy the OpenAPI security requirements: ${r.join(" | ")}`}function dn(t){return Array.from(t.exchange.request.query.keys()).filter(e=>{let r=e.toLowerCase();return r.includes("token")||r.includes("apikey")||r.includes("api_key")||r.includes("access_key")})}var ln=/^(?:(?:.+\.)?localhost|127(?:\.\d{1,3}){3}|::1)$/i;function fn(t){let e;try{e=new URL(t.url).hostname}catch{e=t.host?.replace(/:\d+$/,"")}return e?ln.test(e.replace(/^\[|\]$/g,"")):!1}function mn(t){if(t.exchange.request.protocol!=="http:"||!t.exchange.request.protocolKnown||fn(t.exchange.request))return{flag:!1,hasAuthHeader:!1,sensitiveQueryKeys:[]};let e=Le(t),r=dn(t);return{flag:e||r.length>0,hasAuthHeader:e,sensitiveQueryKeys:r}}var D=class{id="security-baseline";analyze(e){if(!e.matchedOperation)return[];let r=[],n=un(e);if(n.satisfied){let i=_e(n);i.length>0&&r.push({ruleId:this.id,severity:"info",category:"security",message:"Some documented cookie-based security checks were skipped",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{summary:i.map(o=>`Skipped option ${o.requirement} (${o.schemeName}): ${o.reason}`).join(" "),skippedChecks:i}})}else{let i=cn(n);r.push({ruleId:this.id,severity:"error",category:"security",message:"Request does not satisfy documented OpenAPI security requirements",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{summary:pn(i),failedChecks:i,skippedChecks:_e(n),authorizationScheme:ee(e.exchange.request.headers.authorization),hasAuthorizationHeader:Le(e)}})}let s=mn(e);return s.flag&&r.push({ruleId:this.id,severity:"warning",category:"security",message:"Potential credential exposure over insecure HTTP transport",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{protocol:e.exchange.request.protocol,hasAuthorizationHeader:s.hasAuthHeader,sensitiveQueryKeys:s.sensitiveQueryKeys}}),r}};var K=class{id="undocumented-endpoint";analyze(e){if(e.matchedOperation)return[];let{method:r,path:n,host:s}=e.exchange.request,o=e.matchMode==="strict-host"&&!e.hostCompatibleWithSpecServers?`Undocumented server: ${r} ${n} was sent to "${s}", which does not match any server in the description`:`Undocumented endpoint: ${r} ${n}`;return[{ruleId:this.id,severity:"error",category:"documentation",message:o,exchangeIndex:e.exchange.index,target:"request"}]}};var te={"undocumented-endpoint":()=>new K,"schema-consistency":()=>new H,"security-baseline":()=>new D,"owasp-api-top10":()=>new L},hn=Object.keys(te),gn=["undocumented-endpoint","schema-consistency","security-baseline"];function Ne(t){return!t||t.length===0?gn.map(e=>te[e]()):[...new Set(t)].map(e=>{let r=te[e];if(!r)throw new Error(`Unknown rule id: "${e}". Available rules: ${hn.join(", ")}`);return r()})}var He=oe(ot(),1);var De=oe(at(),1),ze=He.default,Ve=De.default;function ne(t,e){if(!d(t))return!1;let r=e==="request"?"readOnly":"writeOnly";return t[r]===!0||Array.isArray(t.allOf)&&t.allOf.some(n=>d(n)&&n[r]===!0)}function Ke(t,e,r,n=new WeakSet){if(!d(t)||n.has(t))return!1;n.add(t);let s=t.properties;return d(s)&&ne(s[e],r)?!0:[t.allOf,t.oneOf,t.anyOf].some(i=>Array.isArray(i)&&i.some(o=>Ke(o,e,r,n)))}var yn=new Set(["items","additionalItems","additionalProperties","unevaluatedItems","unevaluatedProperties","contains","propertyNames","not","if","then","else"]),vn=new Set(["allOf","anyOf","oneOf","prefixItems"]),Sn=new Set(["properties","patternProperties","dependentSchemas","$defs","definitions"]);function Ue(t,e,r=new WeakSet){if(!d(t))return t;if(r.has(t))return!0;r.add(t);let n=i=>Ue(i,e,r),s={};for(let[i,o]of Object.entries(t))yn.has(i)?s[i]=Array.isArray(o)?o.map(n):n(o):vn.has(i)&&Array.isArray(o)?s[i]=o.map(n):Sn.has(i)&&d(o)?s[i]=Object.fromEntries(Object.entries(o).map(([a,c])=>[a,n(c)])):s[i]=o;return Array.isArray(t.required)&&(s.required=t.required.filter(i=>typeof i!="string"||!Ke(t,i,e))),r.delete(t),s}var T=class{ajv;fallbackAjv;objectSchemaCaches={none:new WeakMap,request:new WeakMap,response:new WeakMap};scalarSchemaCache=new Map;constructor(e){let r={strict:!1,allErrors:!0,allowUnionTypes:!0,discriminator:!0,coerceTypes:e?.coerceTypes?"array":!1,validateFormats:!0,verbose:!0,formats:{enum:!0}};this.ajv=new ze(r),this.fallbackAjv=new ze({...r,discriminator:!1}),Ve(this.ajv),Ve(this.fallbackAjv)}validate(e,r,n){if(e===void 0)return{valid:!0,errors:[]};let s;try{s=this.getOrCompileValidator(e,n)}catch(a){return{valid:!1,errors:[{message:`Schema compilation failed: ${a.message}`}]}}let i=!!s(r),o=s.errors??[];return{valid:i,errors:o}}getOrCompileValidator(e,r){if(d(e)){let o=this.objectSchemaCaches[r??"none"],a=o.get(e);if(a)return a;let c=r?Ue(e,r):e,l=this.compileSchema(c);return o.set(e,l),l}let n=`${r??"none"}:${JSON.stringify(e)}`,s=this.scalarSchemaCache.get(n);if(s)return s;let i=this.compileSchema(e);return this.scalarSchemaCache.set(n,i),i}compileSchema(e){try{return this.ajv.compile(e)}catch{return this.fallbackAjv.compile(e)}}};function Ge(t){switch(t.kind){case"operation":return"operation";case"parameter":return`parameter:${t.in}:${t.name}`;case"response":return`response:${t.status}`;case"property":return`property:${t.target}:${t.status??""}:${t.path}`}}function G(t,e){let r=Ge(e);t.has(r)||t.set(r,{item:e,covered:!1})}function J(t,e){let r=t.get(Ge(e));r&&(r.covered=!0)}function Je(t,e){return t?`${t}.${e}`:e}function F(t,e,r,n,s){if(!(!d(t)||s.has(t))){s.add(t);for(let i of[t.allOf,t.oneOf,t.anyOf])if(Array.isArray(i))for(let o of i)F(o,e,r,n,s);if(d(t.properties))for(let[i,o]of Object.entries(t.properties)){if(ne(o,e.target))continue;let a=Je(r,i);G(n,{kind:"property",...e,path:a}),F(o,e,a,n,s)}d(t.items)&&F(t.items,e,`${r}[]`,n,s),s.delete(t)}}function M(t,e,r,n,s,i){if(!(!d(e)||i.has(e))){i.add(e);for(let o of[e.allOf,e.oneOf,e.anyOf])if(Array.isArray(o))for(let a of o)M(t,a,r,n,s,i);if(d(e.properties)&&d(t))for(let[o,a]of Object.entries(e.properties)){if(t[o]===void 0)continue;let c=Je(n,o);J(s,{kind:"property",...r,path:c}),M(t[o],a,r,c,s,i)}if(d(e.items)&&Array.isArray(t))for(let o of t)M(o,e.items,r,`${n}[]`,s,i);i.delete(e)}}function wn(t,e){let r=new Map;G(r,{kind:"operation"});for(let n of t.requestParameters)e&&n.in==="cookie"||G(r,{kind:"parameter",name:n.name,in:n.in});for(let[n,s]of Object.entries(t.requestBodyContent))k(n)&&F(s,{target:"request"},"",r,new Set);for(let n of t.responseStatuses){G(r,{kind:"response",status:n});for(let[s,i]of Object.entries(t.responseBodyContent[n]??{}))k(s)&&F(i,{target:"response",status:n},"",r,new Set)}return{operation:t,entries:r}}function Rn(t){return t.request.bodyJson!==void 0||t.response?.bodyJson!==void 0}function U(t,e){let r={covered:0,total:0};for(let n of t)for(let s of n.entries.values())s.item.kind===e&&(r.total+=1,s.covered&&(r.covered+=1));return r}function In(t){let e={method:t.operation.method.toUpperCase(),path:t.operation.pathTemplate,operationId:t.operation.operationId,missing:[],covered:[]};for(let r of t.entries.values())(r.covered?e.covered:e.missing).push(r.item);return e}var W=class{states=new Map;exchanges={total:0,matched:0,withBody:0};constructor(e){for(let r of e.openApiIndex.operationsByMethod.values())for(let n of r)this.states.set(n,wn(n,e.ignoreCookies))}record(e,r,n){if(this.exchanges.total+=1,!r)return;let s=this.states.get(r.operation);if(!s)return;this.exchanges.matched+=1,Rn(e)&&(this.exchanges.withBody+=1);let{operation:i,pathParams:o}=r,{entries:a}=s;J(a,{kind:"operation"});for(let u of i.requestParameters){let m=V(u,e.request,o,n);m!=null&&J(a,{kind:"parameter",name:u.name,in:u.in})}if(e.request.bodyJson!==void 0){let u=A(i.requestBodyContent,e.request.contentType);M(e.request.bodyJson,u,{target:"request"},"",a,new Set)}let c=e.response;if(!c)return;let l=z(c.status,i.responseStatuses);if(l!==void 0&&(J(a,{kind:"response",status:l}),c.bodyJson!==void 0)){let u=A(i.responseBodyContent[l]??{},c.contentType);M(c.bodyJson,u,{target:"response",status:l},"",a,new Set)}}finalize(){let e=Array.from(this.states.values()).sort((r,n)=>r.operation.pathTemplate.localeCompare(n.operation.pathTemplate)||r.operation.method.localeCompare(n.operation.method));return{exchanges:this.exchanges,totals:{operations:U(e,"operation"),parameters:U(e,"parameter"),properties:U(e,"property"),responses:U(e,"response")},operations:e.map(In)}}};var Pn=10,We={info:0,warning:1,error:2};function bn(){return{totalExchanges:0,documentedExchanges:0,undocumentedExchanges:0,skippedExchanges:0,hostCompatibleExchanges:0,findingsBySeverity:{info:0,warning:0,error:0},findingsByRule:{}}}function On(t,e){t.findingsBySeverity[e.severity]+=1,t.findingsByRule[e.ruleId]=(t.findingsByRule[e.ruleId]??0)+1}function kn(t,e){return{...t,id:Qe(),method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function An(t,e){return{exchangeIndex:t.exchangeIndex,ruleId:t.ruleId,severity:t.severity,category:t.category,message:t.message,occurrences:1,operationId:t.operationId,specSource:t.specSource,target:t.target,schemaPath:t.schemaPath,dataPath:t.dataPath,details:t.details,method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function xn(t,e){if(!e)return;t.operationId||(t.operationId=e.operation.operationId),t.specSource||(t.specSource=e.operation.specSource);let r=t.details??{};if(!d(r)){t.details={operationPathTemplate:e.operation.pathTemplate};return}typeof r.operationPathTemplate!="string"&&(r.operationPathTemplate=e.operation.pathTemplate),t.details=r}function Cn(t){let e=new Set,r=!1;for(let n of t.operationsByMethod.values())for(let s of n)for(let i of s.servers)i.host?e.add(i.host):r=!0;return{specServerHosts:e,hasHostlessSpecServer:r}}async function $n(t,e){let r=[];for(let n of t)try{let s=await n.analyze(e);s.length>0&&r.push(...s)}catch(s){R.warn(`Rule "${n.id}" failed to execute: ${s.message}
18
- `)}return r}var Ye=class t{startedAt=Date.now();runId=Qe();previewLimit;rules;schemaValidator=new T;coercingSchemaValidator=new T({coerceTypes:!0});options;coverage;counters=bn();findings=[];previewFindings=[];problemGroupsByRule={};problemKeyStats=new Map;totalProblemGroups=0;server;ignoreHeaders;minSeverityRank;specServerHosts;hasHostlessSpecServer;constructor(e,r){this.options=e,this.rules=r,this.server=be(e.server),this.ignoreHeaders=e.ignoreHeaders?Ie(e.ignoreHeaders):void 0;let{specServerHosts:n,hasHostlessSpecServer:s}=Cn(e.openApiIndex);this.specServerHosts=n,this.hasHostlessSpecServer=s,this.minSeverityRank=We[e.minSeverity??"info"],this.previewLimit=e.previewFindingsLimit&&e.previewFindingsLimit>0?e.previewFindingsLimit:Pn,this.coverage=e.coverage?new W({openApiIndex:e.openApiIndex,ignoreCookies:e.ignoreCookies??!1}):void 0}static create(e){if(e.openApiIndex.loadedOperations===0)throw new Error("No OpenAPI operations available to validate traffic against.");return new t(e,Ne(e.activeRules))}async process(e){this.counters.totalExchanges+=1;let r=qe(e.request.headers.cookie),n;if(this.server!==void 0&&(n=Oe(e.request,this.server),n===void 0))return this.counters.skippedExchanges+=1,this.coverage?.record(e,null,r),[];let s=this.isHostCompatible(e.request.host);s&&(this.counters.hostCompatibleExchanges+=1);let i=xe(this.options.openApiIndex,e,this.options.matchMode,n);i?this.counters.documentedExchanges+=1:this.counters.undocumentedExchanges+=1,this.coverage?.record(e,i,r);let o=await $n(this.rules,{exchange:e,matchedOperation:i,matchMode:this.options.matchMode,hostCompatibleWithSpecServers:n!==void 0||s,ignoreCookies:this.options.ignoreCookies??!1,ignoreHeaders:this.ignoreHeaders,cookies:r,validateSchema:(c,l,u)=>u?.coerce?this.coercingSchemaValidator.validate(c,l,u?.target):this.schemaValidator.validate(c,l,u?.target)}),a=[];for(let c of o){if(We[c.severity]<this.minSeverityRank)continue;xn(c,i);let l=kn(c,e);this.findings.push(l),a.push(l),On(this.counters,c);let u=B({ruleId:c.ruleId,severity:c.severity,message:c.message,operationId:c.operationId,path:e.request.path,target:c.target,schemaPath:c.schemaPath}),m=this.problemKeyStats.get(u);if(m){m.occurrences+=1,m.previewIndex!==null&&(this.previewFindings[m.previewIndex].occurrences=m.occurrences);continue}if(this.totalProblemGroups+=1,this.problemGroupsByRule[c.ruleId]=(this.problemGroupsByRule[c.ruleId]??0)+1,this.previewFindings.length<this.previewLimit){let w=this.previewFindings.length;this.previewFindings.push(An(c,e)),this.problemKeyStats.set(u,{occurrences:1,previewIndex:w});continue}this.problemKeyStats.set(u,{occurrences:1,previewIndex:null})}return a}isHostCompatible(e){return!e||this.hasHostlessSpecServer||this.specServerHosts.has(e.toLowerCase())}finalize(){let e={runId:this.runId,totalExchanges:this.counters.totalExchanges,documentedExchanges:this.counters.documentedExchanges,undocumentedExchanges:this.counters.undocumentedExchanges,skippedExchanges:this.counters.skippedExchanges,hostCompatibleExchanges:this.counters.hostCompatibleExchanges,findingsBySeverity:this.counters.findingsBySeverity,findingsByRule:this.counters.findingsByRule,problemGroupsByRule:this.problemGroupsByRule,totalProblemGroups:this.totalProblemGroups,durationMs:Date.now()-this.startedAt,previewFindings:this.previewFindings,previewLimit:this.previewLimit,previewTruncated:this.totalProblemGroups>this.previewFindings.length};return{runId:this.runId,summary:e,findings:this.findings,coverage:this.coverage?.finalize()}}};import{stat as En}from"node:fs/promises";var qn=["get","put","post","delete","patch","head","options","trace"],Tn=new Set(["query","header","path","cookie"]),Fn=/^(default|[1-5](\d{2}|xx))$/i;function Mn(t){return qn.includes(t)}function jn(t){return Tn.has(t)}function Xe(t){if(!Array.isArray(t))return[];let e=[];for(let r of t){if(!d(r))continue;let n=r.in;typeof n!="string"||!jn(n)||e.push({name:String(r.name??""),in:n,required:!!r.required||n==="path",style:typeof r.style=="string"?r.style:void 0,schema:r.schema})}return e}function Ze(t){let e=t.in==="header";return`${t.in}:${e?t.name.toLowerCase():t.name}`}function Bn(t,e){let r=new Map;for(let n of t)r.set(Ze(n),n);for(let n of e)r.set(Ze(n),n);return Array.from(r.values())}function tt(t){let e={};if(!d(t))return e;for(let[r,n]of Object.entries(t))d(n)&&"schema"in n&&(e[r.toLowerCase()]=n.schema);return e}function _n(t){return d(t)?tt(t.content):{}}function Ln(t){let e={};for(let[r,n]of Object.entries(t))!d(n)||!("content"in n)||(e[r]=tt(n.content));return e}function Nn(t,e,r){let n=t??e??r;return!Array.isArray(n)||n.length===0?[N("/")]:n.map(s=>{if(!d(s))return N("/");let i=typeof s.url=="string"?s.url:"/",o=d(s.variables)?s.variables:void 0;return N(i,o)})}function zn(t,e,r){return r||`${t.toUpperCase()} ${e}`}function Vn(t){try{let e=fe(t.parsed);return le(e)==="oas3"?e:null}catch{return null}}function et(t){return Array.isArray(t)?t:void 0}function Hn(t,e){let r,n,s={},i="/",o=[],a;return{Root:{enter(c){r=c.servers,n=c.security;let l=d(c.components)?c.components.securitySchemes:void 0;s=d(l)?l:{}}},Paths:{PathItem:{enter(c,l){i=Ee(String(l.key)),o=Xe(c.parameters),a=c.servers},Operation:{enter(c,l){let u=String(l.key);if(!Mn(u))return;let m=Bn(o,Xe(c.parameters)),w=Re(i),j=Nn(c.servers,a,r),b=c.requestBody,f=d(c.responses)?Object.fromEntries(Object.entries(c.responses).filter(([Y])=>Fn.test(Y))):{},h={operationId:zn(u,i,typeof c.operationId=="string"?c.operationId:void 0),method:u,pathTemplate:i,pathRegex:w.regex,pathParams:w.params,pathScore:w.score,servers:j,requestParameters:m,requestBodyContent:_n(b),requestBodyRequired:d(b)&&!!b.required,responseStatuses:Object.keys(f),responseBodyContent:Ln(f),security:et(c.security)??et(n),securitySchemes:s,specSource:t},y=e.get(u)??[];y.push(h),e.set(u,y)}}}}}}function Dn(t,e,r,n,s){let i=ae(r.extendTypes(ue(e),e),r),o=new Map,a={problems:[],specVersion:e,config:r,visitorsData:{}},c=me([{severity:"warn",ruleId:"drift-index",visitor:Hn(n,s)}],i);he({document:t,rootType:i.Root,normalizedVisitors:c,resolvedRefMap:o,ctx:a})}function Kn(t){return`${t.host??""}|${t.basePath}`}function Un(t){for(let e of t.values()){let r=new Map;for(let n of e){let s=r.get(n.pathRegex.source)??[];s.push(n),r.set(n.pathRegex.source,s)}for(let n of r.values()){let s=new Map;for(let i of n)for(let o of i.servers){let a=Kn(o),c=s.get(a)??new Set;c.add(i.specSource),s.set(a,c)}for(let i of s.values())if(i.size>1){let[o]=n;R.warn(`"${o.method.toUpperCase()} ${o.pathTemplate}" is documented for the same server in multiple descriptions (${Array.from(i).join(", ")}). Matching traffic is validated against only one of them.
19
- `);break}}}}function Gn(t,e){for(let n of t.values())n.sort((s,i)=>i.pathScore-s.pathScore);let r=Array.from(t.values()).reduce((n,s)=>n+s.length,0);return{operationsByMethod:t,loadedSpecs:e,loadedOperations:r}}async function Jn(t){return(await En(t)).isDirectory()?{specFiles:await ye(t),fromDirectory:!0}:{specFiles:[t],fromDirectory:!1}}async function Ur(t,e){let{specFiles:r,fromDirectory:n}=await Jn(t),s=new Map,i=new ce(e.resolve),o=0;for(let a of r){let c=await i.resolveDocument(null,a,!0);if(c instanceof Error){R.warn(`Failed to load OpenAPI description ${a}: ${c.message}
20
- `);continue}let l=Vn(c);if(!l){n||R.warn(`Skipping ${a}: not an OpenAPI 3.x description.
21
- `);continue}let u;try{let{bundle:m}=await ge({config:e,doc:c,externalRefResolver:i,dereference:!0});u=m}catch(m){R.warn(`Failed to bundle OpenAPI description ${a}: ${m.message}
22
- `);continue}o+=1,Dn(u,l,e,a,s)}return o>1&&Un(s),Gn(s,o)}function Jr(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}export{Zn as a,Ye as b,Ur as c,Jr as d};
@@ -1,7 +0,0 @@
1
- import { createRequire as __createRequire } from 'node:module';
2
- import { fileURLToPath as __fileURLToPath } from 'node:url';
3
- import { dirname as __pathDirname } from 'node:path';
4
- const require = __createRequire(import.meta.url);
5
- var __filename = __fileURLToPath(import.meta.url);
6
- var __dirname = __pathDirname(__filename);
7
- import{a as g,b as q,c as r,d as s,e as t,f as u,g as v,h as w,i as x,j as y,k as z,l as C,m as D,n as E,o as G,p as H}from"./BZBFESBB.js";import{a as A,e as B,g as F}from"./4WAQNM63.js";import{a}from"./WZXA5XPB.js";import"./AP2GA7RS.js";import"./NEWT5A6S.js";import{a as b,b as c,c as d,d as e,e as f,f as h,g as i,h as j,i as k,j as l,k as m,l as n,m as o,n as p}from"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{y as AUTHORING_HELPER_NAMES,F as GENERATOR_VERSION,a as NotSupportedError,b as Printer,d as RESERVED_WORDS,B as WIRING_NAMES,A as allOperations,c as casing,D as constantCase,z as defineClientSetup,G as defineGenerator,h as deref,j as discriminatorCases,n as docText,m as enumValues,i as flattenAllOf,H as generateClient,C as groupSlug,p as headerCoerceType,e as identifierFor,t as isBinaryContentType,s as isMultipartBody,k as isNullable,q as jsonSuccessSchema,E as mergeConfig,w as paginationItemSchema,g as paginationRuleFor,x as renderReferencePage,o as resolveSchemaPointer,o as schemaAtPointer,v as securityRequirements,u as serverUrlParts,r as sseResponse,f as uniqueIdentifiers,l as unwrapNullable};