@redocly/openapi-docs 3.15.0-next.7 → 3.15.0-next.8

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.
@@ -4,5 +4,5 @@ import type { OpenAPIDefinition } from '../../types/index.js';
4
4
  import type { RedocConfig } from '@redocly/config';
5
5
  export declare function loadSingle(spec: any, specUrl: any, options?: RedocConfig): Promise<OpenAPIDefinition>;
6
6
  export declare function loadAndBundleSpecOrMd(url: string, title?: string): Promise<OpenAPIDefinition>;
7
- export declare const AppProvider: ({ options, definitionUrl, disableTelemetry: _, definition, activeSampleLanguage, children, }: PropsWithChildren<AppProviderProps>) => ReactElement | null;
8
- export declare function RedoclyOpenAPIDocsStandalone({ definition, definitionUrl, disableTelemetry, options, activeItemId, activeSampleLanguage, activeDeepLink, router, }: RedoclyOpenAPIDocsStandaloneProps): ReactElement;
7
+ export declare const AppProvider: ({ options, definitionUrl, definition, activeSampleLanguage, children, }: PropsWithChildren<AppProviderProps>) => ReactElement | null;
8
+ export declare function RedoclyOpenAPIDocsStandalone({ definition, definitionUrl, options, activeItemId, activeSampleLanguage, activeDeepLink, router, }: RedoclyOpenAPIDocsStandaloneProps): ReactElement;
@@ -1 +1 @@
1
- import{jsx as s}from"react/jsx-runtime";import{cloneElement as x,isValidElement as A,useEffect as h,useMemo as O,useState as l}from"react";import{Loading as D}from"@redocly/theme/components/Loaders/Loading";import{useDeepCompareMemoize as E,fixSpec as L}from"./utils.js";import{argValueToBoolean as P}from"../../utils/index.js";import{RedoclyOpenAPIDocs as B}from"./RedoclyOpenAPIDocs.js";import{loadAndBundleDefinition as f,loadOpenapiConfig as I}from"../../utils/loadAndBundleSpec.js";import{ErrorPage as k}from"./Error.js";async function C(e,o,n){let t;if(n?.skipBundle){if(!e)throw new Error('spec must be specified when using "skipBundleAndConvert"');t=e}else t=await f(e||o);try{L(t)}catch{}return t}function $(e,o){return e.endsWith(".md")?f({openapi:"3.0.0",info:{title:o||"",version:"1.0",description:{$ref:e}},paths:{}}):f(e)}const b=({options:e,definitionUrl:o,disableTelemetry:n,definition:t,activeSampleLanguage:d,children:r})=>{const[i,c]=l(),[y,m]=l(!0),[p,S]=l(null),[g,v]=l(e||{});h(()=>{async function w(){m(!0);try{const u=await I();v({...e,...u}),S(await C(t,o,e))}catch(u){c(u.message)}}w()},[t,o,e]);const a=O(()=>{if(p)return{definition:p,options:g,definitionUrl:o,activeSampleLanguage:d}},E([p,o,g]));return h(()=>{a&&m(!1)},[a]),i?s(k,{description:i||"Please check path to your OpenAPI description"}):a?y?P(e?.hideLoading,!1)?null:s(D,{color:"--loading-spinner-color"}):A(r)?x(r,{store:a}):null:null};function q({definition:e,definitionUrl:o,disableTelemetry:n=!1,options:t={},activeItemId:d,activeSampleLanguage:r,activeDeepLink:i,router:c}){return s(b,{definition:e,definitionUrl:o,disableTelemetry:n,options:t,activeItemId:d,activeSampleLanguage:r,activeDeepLink:i,children:s(B,{withCommonStyles:!0,router:c||"hash"})})}export{b as AppProvider,q as RedoclyOpenAPIDocsStandalone,$ as loadAndBundleSpecOrMd,C as loadSingle};
1
+ import{jsx as u}from"react/jsx-runtime";import{cloneElement as w,isValidElement as x,useEffect as g,useMemo as A,useState as a}from"react";import{Loading as D}from"@redocly/theme/components/Loaders/Loading";import{useDeepCompareMemoize as L,fixSpec as O}from"./utils.js";import{argValueToBoolean as B}from"../../utils/index.js";import{RedoclyOpenAPIDocs as E}from"./RedoclyOpenAPIDocs.js";import{loadAndBundleDefinition as p,loadOpenapiConfig as C}from"../../utils/loadAndBundleSpec.js";async function I(e,o,t){let n;if(t?.skipBundle){if(!e)throw new Error('spec must be specified when using "skipBundleAndConvert"');n=e}else n=await p(e||o);try{O(n)}catch{}return n}function T(e,o){return e.endsWith(".md")?p({openapi:"3.0.0",info:{title:o||"",version:"1.0",description:{$ref:e}},paths:{}}):p(e)}const k=({options:e,definitionUrl:o,definition:t,activeSampleLanguage:n,children:r})=>{const[s,l]=a(),[h,f]=a(!0),[d,y]=a(null),[m,S]=a(e||{});g(()=>{async function v(){f(!0);try{const c=await C();S({...e,...c}),y(await I(t,o,e))}catch(c){l(c.message)}}v()},[t,o,e]);const i=A(()=>{if(d)return{definition:d,options:m,definitionUrl:o,activeSampleLanguage:n}},L([d,o,m]));return g(()=>{i&&f(!1)},[i]),s||!i?null:h?B(e?.hideLoading,!1)?null:u(D,{color:"--loading-spinner-color"}):x(r)?w(r,{store:i}):null};function W({definition:e,definitionUrl:o,options:t={},activeItemId:n,activeSampleLanguage:r,activeDeepLink:s,router:l}){return u(k,{definition:e,definitionUrl:o,options:t,activeItemId:n,activeSampleLanguage:r,activeDeepLink:s,children:u(E,{withCommonStyles:!0,router:l||"hash"})})}export{k as AppProvider,W as RedoclyOpenAPIDocsStandalone,T as loadAndBundleSpecOrMd,I as loadSingle};
@@ -48,4 +48,5 @@ export interface RedoclyOpenAPIDocsStandaloneProps {
48
48
  activeSampleLanguage?: CodeSampleConfig['lang'];
49
49
  activeDeepLink?: string;
50
50
  router?: 'hash' | 'history';
51
+ typeOfUsage?: 'html' | 'cli' | 'react' | 'docker';
51
52
  }
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{render as s}from"@testing-library/react";import*as o from"jotai";import{SchemaCatalogLink as a}from"../SchemaCatalogLink";jest.mock("jotai",()=>({...jest.requireActual("jotai"),useAtomValue:jest.fn()})),describe("SchemaCatalogLink",()=>{it("should render correctly",()=>{jest.spyOn(o,"useAtomValue").mockReturnValue({parser:{definition:{"x-schema-catalog-link":"/_bundle/test.yaml"}}});const e=s(t(a,{schemaRef:"#/components/schemas/test"}));expect(e.baseElement).toMatchSnapshot()}),it("should not render if x-schema-catalog-link is not defined",()=>{jest.spyOn(o,"useAtomValue").mockReturnValue({parser:{definition:{}}});const e=s(t(a,{schemaRef:"#/components/schemas/test"}));expect(e.baseElement).toMatchSnapshot()})});
1
+ import{jsx as t}from"react/jsx-runtime";import{render as s,fireEvent as l}from"@testing-library/react";import*as o from"jotai";import{SchemaCatalogLink as a}from"../SchemaCatalogLink";jest.mock("jotai",()=>({...jest.requireActual("jotai"),useAtomValue:jest.fn()})),jest.mock("../../../utils/dom",()=>({...jest.requireActual("../../../utils/dom"),IS_BROWSER:!0})),describe("SchemaCatalogLink",()=>{beforeEach(()=>{jest.clearAllMocks(),jest.useFakeTimers(),Object.defineProperty(global,"navigator",{value:{clipboard:{writeText:jest.fn()}},writable:!0})}),afterEach(()=>{jest.useRealTimers()}),it("should render correctly",()=>{jest.spyOn(o,"useAtomValue").mockReturnValue({parser:{definition:{"x-schema-catalog-link":"/_bundle/test.yaml"}}});const e=s(t(a,{schemaRef:"#/components/schemas/test"}));expect(e.baseElement).toMatchSnapshot()}),it("should not render if x-schema-catalog-link is not defined",()=>{jest.spyOn(o,"useAtomValue").mockReturnValue({parser:{definition:{}}});const e=s(t(a,{schemaRef:"#/components/schemas/test"}));expect(e.baseElement).toMatchSnapshot()}),it("should render correctly on server",()=>{jest.mock("../../../utils/dom",()=>({...jest.requireActual("../../../utils/dom"),IS_BROWSER:jest.fn().mockReturnValue(!1)})),jest.spyOn(o,"useAtomValue").mockReturnValue({parser:{definition:{"x-schema-catalog-link":"/_bundle/test.yaml"}}});const e=s(t(a,{schemaRef:"#/components/schemas/test"}));expect(e.baseElement).toMatchSnapshot()}),it("should copy link to clipboard when copy button is clicked",async()=>{jest.mock("../../../utils/dom",()=>({...jest.requireActual("../../../utils/dom"),IS_BROWSER:jest.fn().mockReturnValue(!0)})),jest.spyOn(o,"useAtomValue").mockReturnValue({parser:{definition:{"x-schema-catalog-link":"/_bundle/test.yaml"}}});const{getByRole:e,findByText:n}=s(t(a,{schemaRef:"#/components/schemas/test"})),c=e("button");l.click(c),expect(await n("Copied!")).toBeDefined()})});
@@ -1 +1 @@
1
- import{BrowserRouter as s,HashRouter as m,MemoryRouter as n}from"react-router-dom";const u={history:s,memory:n,hash:m},a=(o,r)=>{const e=u[o],t={...o!=="memory"&&{basename:r}};return{Router:e,routerProps:t}};export{a as useRouter};
1
+ import{BrowserRouter as s,HashRouter as a,MemoryRouter as n}from"react-router-dom";const m={history:s,memory:n,hash:a},R=(e,o)=>{const r=m[e],t={...e!=="memory"&&{basename:o,feature:{v7_startTransition:!1,v7_relativeSplatPath:!1}}};return{Router:r,routerProps:t}};export{R as useRouter};
@@ -6,7 +6,6 @@ export { setParameterValue } from './utils/parameters.js';
6
6
  export declare function hydrate(store: StoreProviderProps, element?: Element | null): void;
7
7
  export declare function init(definitionOrDefinitionUrl: string | OpenAPIDefinition, options?: RedocConfig & {
8
8
  router?: 'hash' | 'history';
9
- disableTelemetry?: boolean;
10
9
  }, element?: Element | null): void;
11
10
  export declare const version: string;
12
11
  export declare const revision: string;
package/lib/standalone.js CHANGED
@@ -1 +1 @@
1
- import{jsx as p}from"react/jsx-runtime";import{createElement as l}from"react";import{createRoot as u,hydrateRoot as m}from"react-dom/client";import{querySelector as i}from"./utils/dom.js";import{RedoclyOpenAPIDocs as f}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js";import{RedoclyOpenAPIDocsStandalone as d}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js";import{setSecurityDetails as V,setSecurityDetailsVariants as j}from"./utils/security-details.js";import{setParameterValue as F}from"./utils/parameters.js";function E(e){const o={},t=e.attributes;for(let r=0;r<t.length;r++){const s=t[r];o[s.name]=s.value}return o}function _(e){const o=E(e),t={};for(const r in o){const s=r.replace(/-(.)/g,(a,n)=>n.toUpperCase());t[s]=o[r]}return t}function N(e,o=document.querySelector("redoc")){m(o,p(f,{store:e}),{onRecoverableError:(t,r)=>{t.message.includes("Minified React error #418")||console.error(t.message,r)}})}function R(e,o={},t=i("redoc")){if(t===null)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');const{router:r,disableTelemetry:s,...a}={...o,..._(t)};let n,c;typeof e=="string"?n=e:typeof e=="object"&&(c=e),u(t).render(l(d,{definition:c,definitionUrl:n,disableTelemetry:s,options:a,router:r??"hash"},["Loading..."]))}const v=__REDOCLY_API_REFERENCE_VERSION__,C=__REDOCLY_API_REFERENCE_REVISION__;function y(){const e=i("redoc");if(!e)return;const o=e.getAttribute("spec-url");if(o){const t=e.getAttribute("disable-telemetry")==="true";R(o,{disableTelemetry:t},e)}}y();export{N as hydrate,R as init,C as revision,F as setParameterValue,V as setSecurityDetails,j as setSecurityDetailsVariants,v as version};
1
+ import{jsx as i}from"react/jsx-runtime";import{createElement as p}from"react";import{createRoot as u,hydrateRoot as m}from"react-dom/client";import{querySelector as a}from"./utils/dom.js";import{RedoclyOpenAPIDocs as l}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js";import{RedoclyOpenAPIDocsStandalone as f}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js";import{setSecurityDetails as P,setSecurityDetailsVariants as V}from"./utils/security-details.js";import{setParameterValue as D}from"./utils/parameters.js";function d(t){const e={},o=t.attributes;for(let r=0;r<o.length;r++){const n=o[r];e[n.name]=n.value}return e}function E(t){const e=d(t),o={};for(const r in e){const n=r.replace(/-(.)/g,(c,s)=>s.toUpperCase());o[n]=e[r]}return o}function A(t,e=document.querySelector("redoc")){m(e,i(l,{store:t}),{onRecoverableError:(o,r)=>{o.message.includes("Minified React error #418")||console.error(o.message,r)}})}function _(t,e={},o=a("redoc")){if(o===null)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');const{router:r,...n}={...e,...E(o)};let c,s;typeof t=="string"?c=t:typeof t=="object"&&(s=t),u(o).render(p(f,{definition:s,definitionUrl:c,options:n,router:r??"hash"},["Loading..."]))}const N=__REDOCLY_API_REFERENCE_VERSION__,v=__REDOCLY_API_REFERENCE_REVISION__;function R(){const t=a("redoc");if(!t)return;const e=t.getAttribute("spec-url");e&&_(e,{},t)}R();export{A as hydrate,_ as init,v as revision,D as setParameterValue,P as setSecurityDetails,V as setSecurityDetailsVariants,N as version};
@@ -1 +1 @@
1
- import{bundle as a,loadConfig as r}from"@redocly/openapi-core";import{combineUrls as s}from"@redocly/theme/core/openapi";import{convertSwagger2OpenAPI as c}from"./convertSwagger2OpenAPI.js";import{IS_BROWSER as t}from"./dom.js";import{REDOCLY_CONFIG_FILE as f}from"../constants.js";async function w(){const o=t?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():"";try{return(await r({configPath:s(o,f)}))?.resolvedConfig.openapi||{}}catch{return{}}}async function b(o){const n=await r(),e={config:n,base:t?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():""};t&&(n.resolve.http.customFetch=globalThis.fetch),typeof o=="object"&&o!==null?e.doc=d(o):e.ref=o;const{bundle:{parsed:i}}=await a(e);return i.swagger!==void 0?c(i):i}function d(o){return{source:{absoluteRef:""},parsed:o}}export{b as loadAndBundleDefinition,w as loadOpenapiConfig};
1
+ import{bundleOas as r,createEmptyRedoclyConfig as i}from"@redocly/openapi-core/lib/bundle-oas";import{convertSwagger2OpenAPI as c}from"./convertSwagger2OpenAPI.js";import{IS_BROWSER as a}from"./dom.js";async function l(){try{return(await i())?.resolvedConfig.openapi||{}}catch{return{}}}async function p(o){const t=await i(),e={config:t,base:a?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():""};a&&(t.resolve.http.customFetch=globalThis.fetch),typeof o=="object"&&o!==null?e.doc=s(o):e.ref=o;const{bundle:{parsed:n}}=await r(e);return n.swagger!==void 0?c(n):n}function s(o){return{source:{absoluteRef:""},parsed:o}}export{p as loadAndBundleDefinition,l as loadOpenapiConfig};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-docs",
3
- "version": "3.15.0-next.7",
3
+ "version": "3.15.0-next.8",
4
4
  "description": "Redocly OpenAPI Docs",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -37,7 +37,7 @@
37
37
  "util": "~0.12.5",
38
38
  "web-vitals": "3.3.1",
39
39
  "@redocly/config": "0.36.1",
40
- "@redocly/replay": "0.18.0-next.7"
40
+ "@redocly/replay": "0.18.0-next.8"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@jest/globals": "29.5.0",
@@ -75,7 +75,7 @@
75
75
  "typescript": "5.9.3",
76
76
  "url": "~0.11.0",
77
77
  "vite": "7.1.9",
78
- "@redocly/theme": "0.59.0-next.6"
78
+ "@redocly/theme": "0.59.0-next.7"
79
79
  },
80
80
  "scripts": {
81
81
  "start": "npm run copy-highlight-hook && vite",
@@ -85,7 +85,9 @@
85
85
  "prepare:community-source": "npx tsx scripts/prepare-community-source.ts --",
86
86
  "prepare:community-source-only": "npm run prepare:community-source --ignore /src/* private-readme.md",
87
87
  "prepare:community-dependencies": "npx tsx scripts/prepare-community-dependencies.ts",
88
+ "apply:community-source": "npx tsx scripts/apply-changes-from-community-source.ts",
88
89
  "test": "npm run prepare:community-source && cd redoc && npm install && npm run lint && npm run unit && cd ../ && jest -w 2",
90
+ "unit": "jest -w 2",
89
91
  "test:update": "jest -u",
90
92
  "test:watch": "jest --watch",
91
93
  "test:coverage": "jest --coverage",
@@ -1,3 +0,0 @@
1
- export declare function ErrorPage({ description }: {
2
- description: string;
3
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,25 +0,0 @@
1
- import{jsx as e,jsxs as r,Fragment as i}from"react/jsx-runtime";import t from"styled-components";import{GlobalStyle as a}from"@redocly/theme/core/openapi";function f({description:o}){return console.error(o),r(i,{children:[e(a,{}),r(n,{children:[e(s,{children:";("}),e(l,{children:"Something went wrong..."}),r(g,{children:["Please check the console to get more error details. You can troubleshoot your setup by visiting our"," ",e("a",{target:"_blank",rel:"noopener noreferrer",href:"https://redocly.com/docs/redoc",children:"documentation"}),"."]})]})]})}const n=t.div`
2
- height: 100vh;
3
- max-width: var(--page-404-max-width);
4
- display: flex;
5
- flex-direction: column;
6
- justify-content: center;
7
- margin: var(--page-404-margin-vertical) var(--page-404-margin-horizontal);
8
- font-family: var(--page-404-font-family);
9
- gap: var(--page-404-gap);
10
- `,s=t.div`
11
- color: var(--page-404-status-text-color);
12
- font-size: var(--page-404-status-font-size);
13
- line-height: var(--page-404-status-line-height);
14
- font-weight: var(--page-404-status-font-weight);
15
- `,l=t.div`
16
- color: var(--page-404-title-text-color);
17
- font-size: var(--page-404-title-font-size);
18
- line-height: var(--page-404-title-line-height);
19
- font-weight: var(--page-404-title-font-weight);
20
- `,g=t.div`
21
- color: var(--page-404-description-text-color);
22
- font-size: var(--page-404-description-font-size);
23
- line-height: var(--page-404-description-line-height);
24
- font-weight: var(--page-404-description-font-weight);
25
- `;export{f as ErrorPage};