@redocly/api-docs 0.2.0-next.0 → 0.2.0-next.1

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.
@@ -1 +1 @@
1
- import{parseMarkdown as M}from"../../utils/parseMarkdown.js";import{JsonPointer as B}from"../utils/JsonPointer.js";import{DEFAULT_WEBHOOKS_TAG_NAME as I}from"../../../constants/openapi.js";import{SUPPORTED_MCP_TYPES as S}from"../constants.js";import{titleize as C}from"../utils/helpers.js";import{resolveRef as b,readRbacScope as N,rbacProp as v}from"../../helpers.js";import{resolvePathItemRef as P}from"../utils/resolvePathItemRef.js";import{HTTP_METHODS as R}from"../../../utils/http-methods.js";import{REDOCLY_TEAMS_RBAC as _}from"@redocly/config";function T(t){return t.kind==="badge"||t.kind==="audience"}function X({document:t,options:e,basePath:a,storeCtx:c,processContent:p=!0}){const n=new Map,i=!!t.tags?.length;for(const r of t.tags||[]){const o=r;n.set(r.name,{tag:o,operations:[],description:r.description,children:[]})}for(const r of t.tags||[]){const o=r;o.parent&&!T(r)&&n.get(o.parent)?.children.push(r.name)}e?.schemaDefinitionsTagName&&A(n,e.schemaDefinitionsTagName);const s=(t.tags||[]).filter(T),f={document:t,options:e,basePath:a,tagsMap:n,hasTopLevelTags:i,collectedTagOrder:[],downloadUrls:e.downloadUrls,storeCtx:c,badgeTags:s,processContent:p};return L(t,f),$(t,f),f}function A(t,e){t.has(e)||t.set(e,{tag:{name:e},operations:[],children:[]})}function L(t,e){t.paths&&x(t.paths,!1,e);const a=t["x-webhooks"]||t.webhooks;a&&x(a,!0,e)}function $(t,e){const a=t["x-mcp"];if(a)for(const c of S){const p=a[c];if(p?.length)for(const n of p){const i=n.tags&&n.tags.length>0?n.tags:[C(c)];for(const s of i)e.tagsMap.has(s)||(e.tagsMap.set(s,{tag:{name:s},operations:[],children:[]}),e.collectedTagOrder.push(s))}}}function k(t,e){return{...e,summary:e.summary??t.summary,description:e.description??t.description,servers:e.servers??t.servers}}function x(t,e,a){const c=a.document,p=a.document.openapi;for(const[n,i]of Object.entries(t)){if(!i)continue;let s;try{s=P(c,i,p)}catch{console.warn(`[OpenAPI] Skipping path "${n}": failed to resolve path item $ref`);continue}if(!s)continue;const f=s.parameters??[];for(const o of Object.keys(s).filter(d=>!["parameters","servers","description","summary","additionalOperations","$ref"].includes(d))){const d=s[o];!d||typeof d!="object"||w(k(s,d),n,o,e,!1,a,f)}const r=s.additionalOperations;if(r)for(const[o,d]of Object.entries(r))w(k(s,d),n,o,e,!0,a,f)}}function j(t){return typeof t=="object"&&t!==null?t:{}}function q(t,e,a,c){if(!t.length&&!e?.length||!t.length)return e;if(!e?.length)return t;const p=new Set(e.map(i=>{const s=b(a,i,c)??i,f=j(s);return`${f.in}:${f.name}`})),n=[...e];for(const i of t){const s=b(a,i,c)??i,f=j(s),r=`${f.in}:${f.name}`;p.has(r)||n.push(i)}return n}function w(t,e,a,c,p,n,i=[]){const s=t.tags||(c?[I]:[""]),f=H(n.badgeTags,t,e,a,c,p,s,i,n);for(const r of s){let o=n.tagsMap.get(r);o||(o={tag:{name:r},operations:[],children:[]},n.tagsMap.set(r,o),n.collectedTagOrder.push(r)),!T(o.tag)&&(o.tag["x-traitTag"]||o.operations.push(f))}}function D(t){return t.toLowerCase()==="x-query"?"query":t}function H(t,e,a,c,p,n,i,s=[],f){const{options:r,storeCtx:o}=f,d=e.externalDocs,g=e["x-badges"]?.map(m=>({name:m.name,color:m.color,position:m.position}))??[];if(e.tags&&t.length>0)for(const m of e.tags){const l=t.find(u=>u.name===m);l&&g.push({name:l.summary??l.name,color:l.kind==="audience"?"grey":"blue",icon:l.kind==="audience"?"user-group":void 0,position:"after",description:typeof l.description=="string"?l.description:void 0})}return{...e,pointer:B.compile(["paths",a,c]),pathName:a,httpVerb:D(c),operationId:e.operationId,summary:e.summary,description:M(e.description,r),deprecated:e.deprecated,isWebhook:p,isAdditionalOperation:n,tags:i,parameters:q(s,e.parameters,o.document,r.ignoreNamedSchemas),requestBody:e.requestBody,responses:e.responses,servers:e.servers,security:e.security??f.document.security,callbacks:U(e.callbacks,o?.document??{},r.ignoreNamedSchemas),externalDocs:d?{url:d.url,description:d.description}:void 0,"x-seo":e?.["x-seo"],"x-badges":g.length>0?g:void 0}}function U(t,e,a){if(!t||typeof t!="object")return;const c=[];for(const[p,n]of Object.entries(t)){const i=b(e,n,a)??n;if(!i||typeof i!="object")continue;const s=N(i),f=i;for(const[r,o]of Object.entries(f)){if(r===_||!o||typeof o!="object")continue;const d=o.servers,O=o.parameters,g=[];for(const[m,l]of Object.entries(o)){if(!R.has(m.toLowerCase())||!l||typeof l!="object")continue;const u=l,h={httpVerb:D(m.toLowerCase()),pathName:r,summary:u.summary,operationId:u.operationId,description:u.description,deprecated:u.deprecated,requestBody:u.requestBody,responses:u.responses,security:u.security,servers:u.servers??d,parameters:u.parameters??O,externalDocs:u.externalDocs};for(const[y,E]of Object.entries(u))y.startsWith("x-")&&!(y in h)&&(h[y]=E);g.push(h)}g.length>0?c.push({name:p,url:r,operations:g,...v(s)}):c.push({name:p,url:r,...v(s)})}}return c.length>0?c:void 0}export{X as createBuildContext,U as normalizeCallbacks};
1
+ import{parseMarkdown as M}from"../../utils/parseMarkdown.js";import{JsonPointer as B}from"../utils/JsonPointer.js";import{DEFAULT_WEBHOOKS_TAG_NAME as I}from"../../../constants/openapi.js";import{SUPPORTED_MCP_TYPES as N}from"../constants.js";import{titleize as S}from"../utils/helpers.js";import{resolveRef as b,readRbacScope as C,rbacProp as v}from"../../helpers.js";import{resolvePathItemRef as P}from"../utils/resolvePathItemRef.js";import{HTTP_METHODS as R,isOperationName as _}from"../../../utils/http-methods.js";import{REDOCLY_TEAMS_RBAC as A}from"@redocly/config";function T(t){return t.kind==="badge"||t.kind==="audience"}function Z({document:t,options:e,basePath:a,storeCtx:c,processContent:p=!0}){const n=new Map,i=!!t.tags?.length;for(const o of t.tags||[]){const r=o;n.set(o.name,{tag:r,operations:[],description:o.description,children:[]})}for(const o of t.tags||[]){const r=o;r.parent&&!T(o)&&n.get(r.parent)?.children.push(o.name)}e?.schemaDefinitionsTagName&&L(n,e.schemaDefinitionsTagName);const s=(t.tags||[]).filter(T),f={document:t,options:e,basePath:a,tagsMap:n,hasTopLevelTags:i,collectedTagOrder:[],downloadUrls:e.downloadUrls,storeCtx:c,badgeTags:s,processContent:p};return q(t,f),$(t,f),f}function L(t,e){t.has(e)||t.set(e,{tag:{name:e},operations:[],children:[]})}function q(t,e){t.paths&&x(t.paths,!1,e);const a=t["x-webhooks"]||t.webhooks;a&&x(a,!0,e)}function $(t,e){const a=t["x-mcp"];if(a)for(const c of N){const p=a[c];if(p?.length)for(const n of p){const i=n.tags&&n.tags.length>0?n.tags:[S(c)];for(const s of i)e.tagsMap.has(s)||(e.tagsMap.set(s,{tag:{name:s},operations:[],children:[]}),e.collectedTagOrder.push(s))}}}function k(t,e){return{...e,summary:e.summary??t.summary,description:e.description??t.description,servers:e.servers??t.servers}}function x(t,e,a){const c=a.document,p=a.document.openapi;for(const[n,i]of Object.entries(t)){if(!i)continue;let s;try{s=P(c,i,p)}catch{console.warn(`[OpenAPI] Skipping path "${n}": failed to resolve path item $ref`);continue}if(!s)continue;const f=s.parameters??[];for(const r of Object.keys(s).filter(_)){const l=s[r];!l||typeof l!="object"||w(k(s,l),n,r,e,!1,a,f)}const o=s.additionalOperations;if(o)for(const[r,l]of Object.entries(o))w(k(s,l),n,r,e,!0,a,f)}}function j(t){return typeof t=="object"&&t!==null?t:{}}function H(t,e,a,c){if(!t.length&&!e?.length||!t.length)return e;if(!e?.length)return t;const p=new Set(e.map(i=>{const s=b(a,i,c)??i,f=j(s);return`${f.in}:${f.name}`})),n=[...e];for(const i of t){const s=b(a,i,c)??i,f=j(s),o=`${f.in}:${f.name}`;p.has(o)||n.push(i)}return n}function w(t,e,a,c,p,n,i=[]){const s=t.tags||(c?[I]:[""]),f=U(n.badgeTags,t,e,a,c,p,s,i,n);for(const o of s){let r=n.tagsMap.get(o);r||(r={tag:{name:o},operations:[],children:[]},n.tagsMap.set(o,r),n.collectedTagOrder.push(o)),!T(r.tag)&&(r.tag["x-traitTag"]||r.operations.push(f))}}function D(t){return t.toLowerCase()==="x-query"?"query":t}function U(t,e,a,c,p,n,i,s=[],f){const{options:o,storeCtx:r}=f,l=e.externalDocs,g=e["x-badges"]?.map(m=>({name:m.name,color:m.color,position:m.position}))??[];if(e.tags&&t.length>0)for(const m of e.tags){const d=t.find(u=>u.name===m);d&&g.push({name:d.summary??d.name,color:d.kind==="audience"?"grey":"blue",icon:d.kind==="audience"?"user-group":void 0,position:"after",description:typeof d.description=="string"?d.description:void 0})}return{...e,pointer:B.compile(["paths",a,c]),pathName:a,httpVerb:D(c),operationId:e.operationId,summary:e.summary,description:M(e.description,o),deprecated:e.deprecated,isWebhook:p,isAdditionalOperation:n,tags:i,parameters:H(s,e.parameters,r.document,o.ignoreNamedSchemas),requestBody:e.requestBody,responses:e.responses,servers:e.servers,security:e.security??f.document.security,callbacks:V(e.callbacks,r?.document??{},o.ignoreNamedSchemas),externalDocs:l?{url:l.url,description:l.description}:void 0,"x-seo":e?.["x-seo"],"x-badges":g.length>0?g:void 0}}function V(t,e,a){if(!t||typeof t!="object")return;const c=[];for(const[p,n]of Object.entries(t)){const i=b(e,n,a)??n;if(!i||typeof i!="object")continue;const s=C(i),f=i;for(const[o,r]of Object.entries(f)){if(o===A||!r||typeof r!="object")continue;const l=r.servers,O=r.parameters,g=[];for(const[m,d]of Object.entries(r)){if(!R.has(m.toLowerCase())||!d||typeof d!="object")continue;const u=d,h={httpVerb:D(m.toLowerCase()),pathName:o,summary:u.summary,operationId:u.operationId,description:u.description,deprecated:u.deprecated,requestBody:u.requestBody,responses:u.responses,security:u.security,servers:u.servers??l,parameters:u.parameters??O,externalDocs:u.externalDocs};for(const[y,E]of Object.entries(u))y.startsWith("x-")&&!(y in h)&&(h[y]=E);g.push(h)}g.length>0?c.push({name:p,url:o,operations:g,...v(s)}):c.push({name:p,url:o,...v(s)})}}return c.length>0?c:void 0}export{Z as createBuildContext,V as normalizeCallbacks};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/api-docs",
3
- "version": "0.2.0-next.0",
3
+ "version": "0.2.0-next.1",
4
4
  "description": "Redocly API Documentation Library",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -47,11 +47,11 @@
47
47
  "swagger2openapi": "^7.0.8",
48
48
  "url-template": "^2.0.8",
49
49
  "web-vitals": "3.3.1",
50
- "@redocly/config": "0.53.1",
51
50
  "@redocly/redoc-opentelemetry": "0.2.2",
52
- "@redocly/replay": "0.28.0-next.0",
53
- "@redocly/theme": "^0.69.0-next.0",
54
- "@redocly/allof-merge": "0.6.9"
51
+ "@redocly/replay": "0.28.0-next.1",
52
+ "@redocly/theme": "^0.69.0-next.1",
53
+ "@redocly/allof-merge": "0.6.9",
54
+ "@redocly/config": "0.53.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@testing-library/jest-dom": "6.6.3",